https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/68574
Since D101206 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. >From b9313eb779d08ceb0a5dd3603db74b04866fc786 Mon Sep 17 00:00:00 2001 From: Michael Buch <michaelbuc...@gmail.com> Date: Mon, 9 Oct 2023 11:54:56 +0100 Subject: [PATCH] [lldb][DataFormatter] unordered_map: account for new libc++ __hash_node layout Since D101206 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 49233f786c986e2796af7a432c728596758495c5) --- .../Language/CPlusPlus/LibCxxUnorderedMap.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp index 14776cdf808157d..03619385b7d9968 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp @@ -162,10 +162,18 @@ lldb::ValueObjectSP lldb_private::formatters:: if (!node_sp || error.Fail()) return nullptr; - value_sp = node_sp->GetChildMemberWithName("__value_"); hash_sp = node_sp->GetChildMemberWithName("__hash_"); - if (!value_sp || !hash_sp) + if (!hash_sp) return nullptr; + + value_sp = node_sp->GetChildMemberWithName("__value_"); + if (!value_sp) { + // Newer libc++ versions wrap the `__value_` in an anonymous union. + auto anon_union = node_sp->GetChildAtIndex(2); + value_sp = anon_union->GetChildMemberWithName("__value_"); + if (!value_sp) + return nullptr; + } } m_elements_cache.push_back( {value_sp.get(), hash_sp->GetValueAsUnsigned(0)}); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits