Skip to content

Conversation

Michael137
Copy link
Member

#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 #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>

…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>`
Copy link

github-actions bot commented Jun 17, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Collaborator

@labath labath left a 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)

@Michael137
Copy link
Member Author

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 std::pair element_type is with the new layout (e.g., could be a std::pair<TypedefToStdPair), we wouldn't try to unwrap it.

@Michael137 Michael137 merged commit 382e3fd into llvm:main Jun 17, 2025
7 checks passed
@Michael137 Michael137 deleted the lldb/unordered_map-value-type branch June 17, 2025 16:37
Michael137 added a commit to swiftlang/llvm-project that referenced this pull request Jun 18, 2025
…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)
Michael137 added a commit to Michael137/llvm-project that referenced this pull request Jul 2, 2025
Michael137 added a commit that referenced this pull request Jul 2, 2025
Michael137 added a commit that referenced this pull request Jul 4, 2025
…der Clang versions

These only work after #143501 and #144517. Skip on older compilers. This currently fails on the macOS matrix bots that run the LLDB test-suite with older Clang versions.

See #146040.
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Jul 4, 2025
…tests on older Clang versions

These only work after llvm/llvm-project#143501 and llvm/llvm-project#144517. Skip on older compilers. This currently fails on the macOS matrix bots that run the LLDB test-suite with older Clang versions.

See llvm/llvm-project#146040.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants