diff options
author | Michael Buch <michaelbuch12@gmail.com> | 2025-08-25 17:17:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-08-25 09:17:55 -0700 |
commit | 20dd053160f7d933037aacb69067ef4d77996ba1 (patch) | |
tree | b36945b09677700c38491ae8b9b51a42f62f250c /lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp | |
parent | 8ab917a241e5b9e153012eef9d76519c6eab9526 (diff) | |
download | llvm-20dd053160f7d933037aacb69067ef4d77996ba1.zip llvm-20dd053160f7d933037aacb69067ef4d77996ba1.tar.gz llvm-20dd053160f7d933037aacb69067ef4d77996ba1.tar.bz2 |
[lldb][DataFormatters] Support newer _LIBCPP_COMPRESSED_PAIR layout (#155153)
Starting with https://github.com/llvm/llvm-project/pull/154686 the
compressed_pair children are now wrapped in an anonymous structure.
This patch adjusts the LLDB data-formatters to support that.
Outstanding questions:
1. Should GetChildMemberWithName look through anonymous structures? That
will break users most likely. But maybe introducing a new API is worth
it? Then we wouldnt have to do this awkward passing around of
`anon_struct_index`
2. Do we support the layout without the anonymous structure? It's not
too much added complexity. And we did release that version of libc++, so
there is code out there compiled against it. But there is no great way
of testing it (some of our macOS matrix bots do test it i suppose, but
not in a targeted way). We have the layout "simulator" tests for some of
the STL types which I will adjust.
Diffstat (limited to 'lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp')
-rw-r--r-- | lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp index 41441df..8576696 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp @@ -200,7 +200,8 @@ public: llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override; private: - llvm::Expected<uint32_t> CalculateNumChildrenForOldCompressedPairLayout(); + llvm::Expected<uint32_t> + CalculateNumChildrenForOldCompressedPairLayout(ValueObject &pair); /// Returns the ValueObject for the __tree_node type that /// holds the key/value pair of the node at index \ref idx. @@ -254,16 +255,8 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd:: llvm::Expected<uint32_t> lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd:: - CalculateNumChildrenForOldCompressedPairLayout() { - ValueObjectSP node_sp(m_tree->GetChildMemberWithName("__pair3_")); - if (!node_sp) - return 0; - - if (!isOldCompressedPairLayout(*node_sp)) - return llvm::createStringError("Unexpected std::map layout: expected " - "old __compressed_pair layout."); - - node_sp = GetFirstValueOfLibCXXCompressedPair(*node_sp); + CalculateNumChildrenForOldCompressedPairLayout(ValueObject &pair) { + auto node_sp = GetFirstValueOfLibCXXCompressedPair(pair); if (!node_sp) return 0; @@ -281,12 +274,16 @@ llvm::Expected<uint32_t> lldb_private::formatters:: if (m_tree == nullptr) return 0; - if (auto node_sp = m_tree->GetChildMemberWithName("__size_")) { - m_count = node_sp->GetValueAsUnsigned(0); - return m_count; - } + auto [size_sp, is_compressed_pair] = GetValueOrOldCompressedPair( + *m_tree, /*anon_struct_idx=*/2, "__size_", "__pair3_"); + if (!size_sp) + return llvm::createStringError("Unexpected std::map layout"); - return CalculateNumChildrenForOldCompressedPairLayout(); + if (is_compressed_pair) + return CalculateNumChildrenForOldCompressedPairLayout(*size_sp); + + m_count = size_sp->GetValueAsUnsigned(0); + return m_count; } ValueObjectSP |