Skip to content

Commit fe0adc5

Browse files
committed
[lldb][DataFormatter] unordered_map: account for new libc++ __hash_node layout (llvm#68574)
Since D101206 (`ba79fb2e1ff7130cde02fbbd325f0f96f8a522ca`) the `__hash_node::__value_` member is wrapped in an anonymous union. `ValueObject::GetChildMemberWithName` doesn't see through the union. This patch accounts for this possible new layout by getting a handle to the union before doing the by-name `__value_` lookup. (cherry picked from commit 7493d45)
1 parent 491ce66 commit fe0adc5

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,27 @@ lldb::ValueObjectSP lldb_private::formatters::
147147
if (!node_sp || error.Fail())
148148
return nullptr;
149149

150-
value_sp = node_sp->GetChildMemberWithName("__value_");
151150
hash_sp = node_sp->GetChildMemberWithName("__hash_");
152-
if (!value_sp || !hash_sp)
151+
if (!hash_sp)
153152
return nullptr;
153+
154+
value_sp = node_sp->GetChildMemberWithName("__value_");
155+
if (!value_sp) {
156+
// clang-format off
157+
// Since D101206 (ba79fb2e1f), libc++ wraps the `__value_` in an
158+
// anonymous union.
159+
// Child 0: __hash_node_base base class
160+
// Child 1: __hash_
161+
// Child 2: anonymous union
162+
// clang-format on
163+
auto anon_union_sp = node_sp->GetChildAtIndex(2);
164+
if (!anon_union_sp)
165+
return nullptr;
166+
167+
value_sp = anon_union_sp->GetChildMemberWithName("__value_");
168+
if (!value_sp)
169+
return nullptr;
170+
}
154171
}
155172
m_elements_cache.push_back(
156173
{value_sp.get(), hash_sp->GetValueAsUnsigned(0)});

0 commit comments

Comments
 (0)