kastiglione updated this revision to Diff 400234. kastiglione added a comment. Herald added a subscriber: JDevlieghere.
some tabs snuck in Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D117383/new/ https://reviews.llvm.org/D117383 Files: lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py =================================================================== --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py @@ -48,12 +48,17 @@ "corrupt_map", ['%s::unordered_map' % ns, 'size=0 {}']) + must_not_contain__cc = r'(?s)^(?!.*\b__cc = )' + self.look_for_content_and_continue( - "map", ['%s::unordered_map' % - ns, 'size=5 {', 'hello', 'world', 'this', 'is', 'me']) + "map", ['%s::unordered_map' % ns, + must_not_contain__cc, + 'size=5 {', 'hello', 'world', 'this', 'is', 'me']) self.look_for_content_and_continue( - "mmap", ['%s::unordered_multimap' % ns, 'size=6 {', 'first = 3', 'second = "this"', + "mmap", ['%s::unordered_multimap' % ns, + must_not_contain__cc, + 'size=6 {', 'first = 3', 'second = "this"', 'first = 2', 'second = "hello"']) self.look_for_content_and_continue( Index: lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp =================================================================== --- lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp +++ lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp @@ -118,10 +118,16 @@ m_element_type = m_element_type.GetPointeeType(); m_node_type = m_element_type; m_element_type = m_element_type.GetTypeTemplateArgument(0); - std::string name; - m_element_type = - m_element_type.GetFieldAtIndex(0, name, nullptr, nullptr, nullptr); - m_element_type = m_element_type.GetTypedefedType(); + if (m_element_type.GetNumFields() > 0) { + // Check for - and use - the underlying key/value container type used + // within std::unordered_map. + std::string name; + auto key_value_type = + m_element_type.GetFieldAtIndex(0, name, nullptr, nullptr, nullptr); + // __cc is a field of __hash_value_type, which is a typedef. + if (name == "__cc") + m_element_type = key_value_type.GetTypedefedType(); + } } if (!m_node_type) return nullptr; @@ -153,7 +159,7 @@ ExecutionContext exe_ctx = val_hash.first->GetExecutionContextRef().Lock( thread_and_frame_only_if_stopped); return CreateValueObjectFromData(stream.GetString(), data, exe_ctx, - val_hash.first->GetCompilerType()); + m_element_type); } bool lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py =================================================================== --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py @@ -48,12 +48,17 @@ "corrupt_map", ['%s::unordered_map' % ns, 'size=0 {}']) + must_not_contain__cc = r'(?s)^(?!.*\b__cc = )' + self.look_for_content_and_continue( - "map", ['%s::unordered_map' % - ns, 'size=5 {', 'hello', 'world', 'this', 'is', 'me']) + "map", ['%s::unordered_map' % ns, + must_not_contain__cc, + 'size=5 {', 'hello', 'world', 'this', 'is', 'me']) self.look_for_content_and_continue( - "mmap", ['%s::unordered_multimap' % ns, 'size=6 {', 'first = 3', 'second = "this"', + "mmap", ['%s::unordered_multimap' % ns, + must_not_contain__cc, + 'size=6 {', 'first = 3', 'second = "this"', 'first = 2', 'second = "hello"']) self.look_for_content_and_continue( Index: lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp =================================================================== --- lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp +++ lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp @@ -118,10 +118,16 @@ m_element_type = m_element_type.GetPointeeType(); m_node_type = m_element_type; m_element_type = m_element_type.GetTypeTemplateArgument(0); - std::string name; - m_element_type = - m_element_type.GetFieldAtIndex(0, name, nullptr, nullptr, nullptr); - m_element_type = m_element_type.GetTypedefedType(); + if (m_element_type.GetNumFields() > 0) { + // Check for - and use - the underlying key/value container type used + // within std::unordered_map. + std::string name; + auto key_value_type = + m_element_type.GetFieldAtIndex(0, name, nullptr, nullptr, nullptr); + // __cc is a field of __hash_value_type, which is a typedef. + if (name == "__cc") + m_element_type = key_value_type.GetTypedefedType(); + } } if (!m_node_type) return nullptr; @@ -153,7 +159,7 @@ ExecutionContext exe_ctx = val_hash.first->GetExecutionContextRef().Lock( thread_and_frame_only_if_stopped); return CreateValueObjectFromData(stream.GetString(), data, exe_ctx, - val_hash.first->GetCompilerType()); + m_element_type); } bool lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits