Skip to content

Commit a421f18

Browse files
committed
[lldb][DataFormatter] unordered_map: account for new libc++ __hash_node layout
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 df116d1 commit a421f18

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,21 @@ 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+
// Newer libc++ versions wrap the `__value_` in an anonymous union.
172+
auto anon_union_sp = node_sp->GetChildAtIndex(2);
173+
if (!anon_union_sp)
174+
return nullptr;
175+
176+
value_sp = anon_union_sp->GetChildMemberWithName("__value_");
177+
if (!value_sp)
178+
return nullptr;
179+
}
169180
}
170181
m_elements_cache.push_back(
171182
{value_sp.get(), hash_sp->GetValueAsUnsigned(0)});

0 commit comments

Comments
 (0)