Skip to content

Commit 17ebaf8

Browse files
Merge pull request #8695 from Michael137/bugfix/lldb-unordered_map-formatter/to-swift-relase-6.0
[cherry-pick][swift/release/6.0] [lldb][DataFormatter] unordered_map: account for new libc++ __hash_node layout
2 parents d470a64 + fe0adc5 commit 17ebaf8

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)