Skip to content

Commit 0b980cd

Browse files
committed
[lldb][Formatter] Get element type for unordered_maps from __hash_table::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>`
1 parent 1bd4f97 commit 0b980cd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ static bool isUnorderedMap(ConstString type_name) {
9999

100100
CompilerType lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::
101101
GetElementType(CompilerType table_type) {
102-
auto element_type = table_type.GetTypedefedType().GetTypeTemplateArgument(0);
102+
auto element_type = table_type.GetDirectNestedTypeWithName("value_type").GetTypedefedType();
103103

104104
// This synthetic provider is used for both unordered_(multi)map and
105-
// unordered_(multi)set. For unordered_map, the element type has an
105+
// unordered_(multi)set. For older unordered_map layouts, the element type has an
106106
// additional type layer, an internal struct (`__hash_value_type`)
107107
// that wraps a std::pair. Peel away the internal wrapper type - whose
108108
// structure is of no value to users, to expose the std::pair. This

0 commit comments

Comments
 (0)