Skip to content

[lldb][DataFormatters] Adjust retrieval of unordered_map element type #10701

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class LibcxxStdUnorderedMapSyntheticFrontEnd

private:
CompilerType GetNodeType();
CompilerType GetElementType(CompilerType node_type);
CompilerType GetElementType(CompilerType table_type);
llvm::Expected<size_t> CalculateNumChildrenImpl(ValueObject &table);

CompilerType m_element_type;
Expand Down Expand Up @@ -102,8 +102,8 @@ static bool isUnorderedMap(ConstString type_name) {
}

CompilerType lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::
GetElementType(CompilerType node_type) {
CompilerType element_type = node_type.GetTypeTemplateArgument(0);
GetElementType(CompilerType table_type) {
auto element_type = table_type.GetTypedefedType().GetTypeTemplateArgument(0);

// This synthetic provider is used for both unordered_(multi)map and
// unordered_(multi)set. For unordered_map, the element type has an
Expand All @@ -117,7 +117,7 @@ CompilerType lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::
element_type.GetFieldAtIndex(0, name, nullptr, nullptr, nullptr);
CompilerType actual_type = field_type.GetTypedefedType();
if (isStdTemplate(actual_type.GetTypeName(), "pair"))
element_type = actual_type;
return actual_type;
}

return element_type;
Expand Down Expand Up @@ -164,13 +164,6 @@ lldb::ValueObjectSP lldb_private::formatters::
ValueObjectSP value_sp = node_sp->GetChildMemberWithName("__value_");
ValueObjectSP hash_sp = node_sp->GetChildMemberWithName("__hash_");
if (!hash_sp || !value_sp) {
if (!m_element_type) {
m_node_type = GetNodeType();
if (!m_node_type)
return nullptr;

m_element_type = GetElementType(m_node_type);
}
node_sp = m_next_element->Cast(m_node_type.GetPointerType())
->Dereference(error);
if (!node_sp || error.Fail())
Expand Down Expand Up @@ -274,6 +267,14 @@ lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::Update() {
if (!table_sp)
return lldb::ChildCacheState::eRefetch;

m_node_type = GetNodeType();
if (!m_node_type)
return lldb::ChildCacheState::eRefetch;

m_element_type = GetElementType(table_sp->GetCompilerType());
if (!m_element_type)
return lldb::ChildCacheState::eRefetch;

ValueObjectSP tree_sp = GetTreePointer(*table_sp);
if (!tree_sp)
return lldb::ChildCacheState::eRefetch;
Expand Down