-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lldb][Formatter] Get element type for unordered_maps from __hash_table::value_type #144517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lldb][Formatter] Get element type for unordered_maps from __hash_table::value_type #144517
Conversation
…le::value_type llvm#143501 changes usage of `__hash_value_type` in libcxx to an empty tag type. This type will no longer have a definition in DWARF. Currently the LLDB unordered_map formatter deduces the map's `element_type` by looking at the `__cc_` member of `__hash_value_type`. But that will no longer work because we only have its forward declaration. Since what we're really after is the type that `__hash_value_type` is wrapping, we can just look at the `__hash_table::value_type` typedef. With llvm#143501 that will now point to the `std::pair` element type (which used to be what we got from `__cc_`). TBD: need to double-check this works for older layouts. Quick glance at the code makes me suspicious of cases like `unordered_map<std::pair<int, int>, int>`
✅ With the latest revision this PR passed the C/C++ code formatter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that should work. One thing to look out for when it comes to typedefs is that they are not emitted if they aren't used (in the compilation unit). It should be fine as long as the type is referenced from a non-template member function, and I think that should be the case with the basic form of the insert
method. (references from template member fn's are not enough as these are also only emitted when used)
To be on the safe side I added an early-return for the new layout. Technically it would work for old layouts even without this early-return, but it kind of only worked by chance. This way regardless of what the |
…le::value_type (llvm#144517) llvm#143501 changes usage of `__hash_value_type` in libcxx to an empty tag type. This type will no longer have a definition in DWARF. Currently the LLDB unordered_map formatter deduces the map's `element_type` by looking at the `__cc_` member of `__hash_value_type`. But that will no longer work because we only have its forward declaration. Since what we're really after is the type that `__hash_value_type` is wrapping, we can just look at the `__hash_table::value_type` typedef. With llvm#143501 that will now point to the `std::pair` element type (which used to be what we got from `__cc_`). TBD: need to double-check this works for older layouts. Quick glance at the code makes me suspicious of cases like `unordered_map<std::pair<int, int>, int>` (cherry picked from commit 382e3fd)
…le::value_type (llvm#144517) llvm#143501 changes usage of `__hash_value_type` in libcxx to an empty tag type. This type will no longer have a definition in DWARF. Currently the LLDB unordered_map formatter deduces the map's `element_type` by looking at the `__cc_` member of `__hash_value_type`. But that will no longer work because we only have its forward declaration. Since what we're really after is the type that `__hash_value_type` is wrapping, we can just look at the `__hash_table::value_type` typedef. With llvm#143501 that will now point to the `std::pair` element type (which used to be what we got from `__cc_`). TBD: need to double-check this works for older layouts. Quick glance at the code makes me suspicious of cases like `unordered_map<std::pair<int, int>, int>`
#143501 changes usage of
__hash_value_type
in libcxx to an empty tag type. This type will no longer have a definition in DWARF. Currently the LLDB unordered_map formatter deduces the map'selement_type
by looking at the__cc_
member of__hash_value_type
. But that will no longer work because we only have its forward declaration. Since what we're really after is the type that__hash_value_type
is wrapping, we can just look at the__hash_table::value_type
typedef. With #143501 that will now point to thestd::pair
element type (which used to be what we got from__cc_
).TBD: need to double-check this works for older layouts. Quick glance at the code makes me suspicious of cases like
unordered_map<std::pair<int, int>, int>