Author: Michael Buch Date: 2024-07-03T10:34:16+02:00 New Revision: e89890e8e510f2b76c8c4a2b2a6fc323b1e837ad
URL: https://github.com/llvm/llvm-project/commit/e89890e8e510f2b76c8c4a2b2a6fc323b1e837ad DIFF: https://github.com/llvm/llvm-project/commit/e89890e8e510f2b76c8c4a2b2a6fc323b1e837ad.diff LOG: [lldb][DataFormatter][NFC] std::map: minor restructuring in GetChildAtIndex to use early-return Added: Modified: lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp Removed: ################################################################################ diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp index 2a241e3764b19..44fe294ced722 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp @@ -267,6 +267,7 @@ void lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetValueOffset( uint64_t bit_offset; if (node_type.GetIndexOfFieldWithName("__value_", nullptr, &bit_offset) != UINT32_MAX) { + // Old layout (pre 089a7cc5dea) m_skip_size = bit_offset / 8u; } else { auto ast_ctx = node_type.GetTypeSystem().dyn_cast_or_null<TypeSystemClang>(); @@ -328,45 +329,47 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetChildAtIndex( nullptr; // this will stop all future searches until an Update() happens return iterated_sp; } - if (GetDataType()) { - if (!need_to_skip) { - Status error; - iterated_sp = iterated_sp->Dereference(error); - if (!iterated_sp || error.Fail()) { - m_tree = nullptr; - return lldb::ValueObjectSP(); - } - GetValueOffset(iterated_sp); - auto child_sp = iterated_sp->GetChildMemberWithName("__value_"); - if (child_sp) - iterated_sp = child_sp; - else - iterated_sp = iterated_sp->GetSyntheticChildAtOffset( - m_skip_size, m_element_type, true); - if (!iterated_sp) { - m_tree = nullptr; - return lldb::ValueObjectSP(); - } - } else { - // because of the way our debug info is made, we need to read item 0 - // first so that we can cache information used to generate other elements - if (m_skip_size == UINT32_MAX) - GetChildAtIndex(0); - if (m_skip_size == UINT32_MAX) { - m_tree = nullptr; - return lldb::ValueObjectSP(); - } + + if (!GetDataType()) { + m_tree = nullptr; + return lldb::ValueObjectSP(); + } + + if (!need_to_skip) { + Status error; + iterated_sp = iterated_sp->Dereference(error); + if (!iterated_sp || error.Fail()) { + m_tree = nullptr; + return lldb::ValueObjectSP(); + } + GetValueOffset(iterated_sp); + auto child_sp = iterated_sp->GetChildMemberWithName("__value_"); + if (child_sp) + iterated_sp = child_sp; + else iterated_sp = iterated_sp->GetSyntheticChildAtOffset( m_skip_size, m_element_type, true); - if (!iterated_sp) { - m_tree = nullptr; - return lldb::ValueObjectSP(); - } + if (!iterated_sp) { + m_tree = nullptr; + return lldb::ValueObjectSP(); } } else { - m_tree = nullptr; - return lldb::ValueObjectSP(); + // because of the way our debug info is made, we need to read item 0 + // first so that we can cache information used to generate other elements + if (m_skip_size == UINT32_MAX) + GetChildAtIndex(0); + if (m_skip_size == UINT32_MAX) { + m_tree = nullptr; + return lldb::ValueObjectSP(); + } + iterated_sp = iterated_sp->GetSyntheticChildAtOffset(m_skip_size, + m_element_type, true); + if (!iterated_sp) { + m_tree = nullptr; + return lldb::ValueObjectSP(); + } } + // at this point we have a valid // we need to copy current_sp into a new object otherwise we will end up with // all items named __value_ _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits