diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp index 642723dd91132..ffc33395830bb 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp @@ -99,14 +99,20 @@ static bool isUnorderedMap(ConstString type_name) { CompilerType lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd:: GetElementType(CompilerType table_type) { - auto element_type = table_type.GetTypedefedType().GetTypeTemplateArgument(0); + auto element_type = + table_type.GetDirectNestedTypeWithName("value_type").GetTypedefedType(); + + // In newer unordered_map layouts, the std::pair element type isn't wrapped + // in any helper types. So return it directly. + if (isStdTemplate(element_type.GetTypeName(), "pair")) + return element_type; // This synthetic provider is used for both unordered_(multi)map and - // unordered_(multi)set. For unordered_map, the element type has an - // additional type layer, an internal struct (`__hash_value_type`) - // that wraps a std::pair. Peel away the internal wrapper type - whose - // structure is of no value to users, to expose the std::pair. This - // matches the structure returned by the std::map synthetic provider. + // unordered_(multi)set. For older unordered_map layouts, the element type has + // an additional type layer, an internal struct (`__hash_value_type`) that + // wraps a std::pair. Peel away the internal wrapper type - whose structure is + // of no value to users, to expose the std::pair. This matches the structure + // returned by the std::map synthetic provider. if (isUnorderedMap( m_backend.GetCompilerType().GetCanonicalType().GetTypeName())) { std::string name;