Skip to content

Commit 7493d45

Browse files
authored
[lldb][DataFormatter] unordered_map: account for new libc++ __hash_node layout (#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.
1 parent 2c9ddfc commit 7493d45

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
@@ -162,10 +162,27 @@ lldb::ValueObjectSP lldb_private::formatters::
162162
if (!node_sp || error.Fail())
163163
return nullptr;
164164

165-
value_sp = node_sp->GetChildMemberWithName("__value_");
166165
hash_sp = node_sp->GetChildMemberWithName("__hash_");
167-
if (!value_sp || !hash_sp)
166+
if (!hash_sp)
168167
return nullptr;
168+
169+
value_sp = node_sp->GetChildMemberWithName("__value_");
170+
if (!value_sp) {
171+
// clang-format off
172+
// Since D101206 (ba79fb2e1f), libc++ wraps the `__value_` in an
173+
// anonymous union.
174+
// Child 0: __hash_node_base base class
175+
// Child 1: __hash_
176+
// Child 2: anonymous union
177+
// clang-format on
178+
auto anon_union_sp = node_sp->GetChildAtIndex(2);
179+
if (!anon_union_sp)
180+
return nullptr;
181+
182+
value_sp = anon_union_sp->GetChildMemberWithName("__value_");
183+
if (!value_sp)
184+
return nullptr;
185+
}
169186
}
170187
m_elements_cache.push_back(
171188
{value_sp.get(), hash_sp->GetValueAsUnsigned(0)});

0 commit comments

Comments
 (0)