[Lldb-commits] [lldb] [lldb][Formatters] Remove broken/redundant lookup into anonymous child when extracting from compressed pairs (PR #175564)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/175564 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Formatters] Remove broken/redundant lookup into anonymous child when extracting from compressed pairs (PR #175564)
https://github.com/adrian-prantl approved this pull request. https://github.com/llvm/llvm-project/pull/175564 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Formatters] Remove broken/redundant lookup into anonymous child when extracting from compressed pairs (PR #175564)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/175564 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Formatters] Remove broken/redundant lookup into anonymous child when extracting from compressed pairs (PR #175564)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/175564 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Formatters] Remove broken/redundant lookup into anonymous child when extracting from compressed pairs (PR #175564)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/175564 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Formatters] Remove broken/redundant lookup into anonymous child when extracting from compressed pairs (PR #175564)
llvmbot wrote:
@llvm/pr-subscribers-lldb
Author: Michael Buch (Michael137)
Changes
(brought to my attention in
https://github.com/llvm/llvm-project/pull/155153#discussion_r2682666325)
The latest `_LIBCPP_COMPRESSED_PAIR` wraps the members in an anonymous
structure. Around the time of the patch, `GetChildMemberWithName` wasn't
capable of "seeing through" anonymous structures when searching for children.
However, around the same time as
https://github.com/llvm/llvm-project/pull/155153 landed, the
`GetChildMemberWithName` behaviour was fixed (in
https://github.com/llvm/llvm-project/pull/138487). So regardless of whether the
the compressed pair is wrapped in an anonymous structure, simply calling
`GetChildMemberWithName` is the righ thing to do.
We weren't even using the result of `GetChildAtIndex`, so we were always
calling `GetChildMemberWithName` with the root ValueObject anyways.
Our `libcxx-simulators` already test both compressed pair layouts, so no extra
coverage is needed here.
---
Full diff: https://github.com/llvm/llvm-project/pull/175564.diff
6 Files Affected:
- (modified) lldb/source/Plugins/Language/CPlusPlus/GenericList.cpp (+4-5)
- (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp (+7-16)
- (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxx.h (+1-2)
- (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp (+2-2)
- (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
(+6-6)
- (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp (+2-2)
``diff
diff --git a/lldb/source/Plugins/Language/CPlusPlus/GenericList.cpp
b/lldb/source/Plugins/Language/CPlusPlus/GenericList.cpp
index 8c5ac31aef3f3..b6ff4477a8901 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/GenericList.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/GenericList.cpp
@@ -354,9 +354,8 @@ lldb::ChildCacheState LibCxxForwardListFrontEnd::Update() {
return lldb::ChildCacheState::eRefetch;
// Anonymous strucutre index is in base class at index 0.
- auto [impl_sp, is_compressed_pair] =
- GetValueOrOldCompressedPair(*list_base_sp, /*anon_struct_idx=*/0,
- "__before_begin_", "__before_begin_");
+ auto [impl_sp, is_compressed_pair] = GetValueOrOldCompressedPair(
+ *list_base_sp, "__before_begin_", "__before_begin_");
if (!impl_sp)
return ChildCacheState::eRefetch;
@@ -383,8 +382,8 @@ llvm::Expected
LibCxxListFrontEnd::CalculateNumChildren() {
if (!m_head || !m_tail || m_node_address == 0)
return 0;
- auto [size_node_sp, is_compressed_pair] = GetValueOrOldCompressedPair(
- m_backend, /*anon_struct_idx=*/1, "__size_", "__size_alloc_");
+ auto [size_node_sp, is_compressed_pair] =
+ GetValueOrOldCompressedPair(m_backend, "__size_", "__size_alloc_");
if (is_compressed_pair)
size_node_sp = GetFirstValueOfLibCXXCompressedPair(*size_node_sp);
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index 141c5c9a2caf9..df599d708cda0 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -104,21 +104,12 @@
lldb_private::formatters::GetSecondValueOfLibCXXCompressedPair(
std::pair
lldb_private::formatters::GetValueOrOldCompressedPair(
-ValueObject &obj, size_t anon_struct_idx, llvm::StringRef child_name,
+ValueObject &obj, llvm::StringRef child_name,
llvm::StringRef compressed_pair_name) {
auto is_old_compressed_pair = [](ValueObject &pair_obj) -> bool {
return isStdTemplate(pair_obj.GetTypeName(), "__compressed_pair");
};
- // Try searching the child member in an anonymous structure first.
- if (auto unwrapped = obj.GetChildAtIndex(anon_struct_idx)) {
-ValueObjectSP node_sp(obj.GetChildMemberWithName(child_name));
-if (node_sp)
- return {node_sp, is_old_compressed_pair(*node_sp)};
- }
-
- // Older versions of libc++ don't wrap the children in anonymous structures.
- // Try that instead.
ValueObjectSP node_sp(obj.GetChildMemberWithName(child_name));
if (node_sp)
return {node_sp, is_old_compressed_pair(*node_sp)};
@@ -240,8 +231,8 @@ bool
lldb_private::formatters::LibcxxUniquePointerSummaryProvider(
if (!valobj_sp)
return false;
- auto [ptr_sp, is_compressed_pair] = GetValueOrOldCompressedPair(
- *valobj_sp, /*anon_struct_idx=*/0, "__ptr_", "__ptr_");
+ auto [ptr_sp, is_compressed_pair] =
+ GetValueOrOldCompressedPair(*valobj_sp, "__ptr_", "__ptr_");
if (!ptr_sp)
return false;
@@ -415,8 +406,8 @@
lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::Update() {
if (!valobj_sp)
return lldb::ChildCacheState::eRefetch;
- auto [ptr_sp, is_compressed_pair] = GetValueOrOldCompressedPair(
- *valobj_sp, /*anon_struct_idx=*/0, "__ptr_", "__ptr_");
+ auto [ptr_sp, is_compressed_pair] =
+ GetValueOrOldCompressedPair(*valobj_sp,
[Lldb-commits] [lldb] [lldb][Formatters] Remove broken/redundant lookup into anonymous child when extracting from compressed pairs (PR #175564)
https://github.com/Michael137 created
https://github.com/llvm/llvm-project/pull/175564
(brought to my attention in
https://github.com/llvm/llvm-project/pull/155153#discussion_r2682666325)
The latest `_LIBCPP_COMPRESSED_PAIR` wraps the members in an anonymous
structure. Around the time of the patch, `GetChildMemberWithName` wasn't
capable of "seeing through" anonymous structures when searching for children.
However, around the same time as
https://github.com/llvm/llvm-project/pull/155153 landed, the
`GetChildMemberWithName` behaviour was fixed (in
https://github.com/llvm/llvm-project/pull/138487). So regardless of whether the
the compressed pair is wrapped in an anonymous structure, simply calling
`GetChildMemberWithName` is the righ thing to do.
We weren't even using the result of `GetChildAtIndex`, so we were always
calling `GetChildMemberWithName` with the root ValueObject anyways.
Our `libcxx-simulators` already test both compressed pair layouts, so no extra
coverage is needed here.
>From aad7e91a857a26d1d0f35a0c7192d380cc9e4c8a Mon Sep 17 00:00:00 2001
From: Michael Buch
Date: Mon, 12 Jan 2026 15:35:23 +
Subject: [PATCH] [lldb][Formatters] Remove broken/redundant lookup into
anonymous child when extracting from compressed pairs
(brought to my attention in
https://github.com/llvm/llvm-project/pull/155153#discussion_r2682666325)
The latest `_LIBCPP_COMPRESSED_PAIR` wraps the members in an anonymous
structure. Around the time of the patch, `GetChildMemberWithName` wasn't
capable of "seeing through" anonymous structures when searching for children.
However, around the same time as
https://github.com/llvm/llvm-project/pull/155153 landed, the
`GetChildMemberWithName` behaviour was fixed (in
https://github.com/llvm/llvm-project/pull/138487). So regardless of whether the
the compressed pair is wrapped in an anonymous structure, simply calling
`GetChildMemberWithName` is the righ thing to do.
We weren't even using the result of `GetChildAtIndex`, so we were always
calling `GetChildMemberWithName` with the root ValueObject anyways.
Our `libcxx-simulators` already test both compressed pair layouts, so no extra
coverage is needed here.
---
.../Language/CPlusPlus/GenericList.cpp| 9
.../Plugins/Language/CPlusPlus/LibCxx.cpp | 23 ++-
.../Plugins/Language/CPlusPlus/LibCxx.h | 3 +--
.../Plugins/Language/CPlusPlus/LibCxxMap.cpp | 4 ++--
.../Language/CPlusPlus/LibCxxUnorderedMap.cpp | 12 +-
.../Language/CPlusPlus/LibCxxVector.cpp | 4 ++--
6 files changed, 22 insertions(+), 33 deletions(-)
diff --git a/lldb/source/Plugins/Language/CPlusPlus/GenericList.cpp
b/lldb/source/Plugins/Language/CPlusPlus/GenericList.cpp
index 8c5ac31aef3f3..b6ff4477a8901 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/GenericList.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/GenericList.cpp
@@ -354,9 +354,8 @@ lldb::ChildCacheState LibCxxForwardListFrontEnd::Update() {
return lldb::ChildCacheState::eRefetch;
// Anonymous strucutre index is in base class at index 0.
- auto [impl_sp, is_compressed_pair] =
- GetValueOrOldCompressedPair(*list_base_sp, /*anon_struct_idx=*/0,
- "__before_begin_", "__before_begin_");
+ auto [impl_sp, is_compressed_pair] = GetValueOrOldCompressedPair(
+ *list_base_sp, "__before_begin_", "__before_begin_");
if (!impl_sp)
return ChildCacheState::eRefetch;
@@ -383,8 +382,8 @@ llvm::Expected
LibCxxListFrontEnd::CalculateNumChildren() {
if (!m_head || !m_tail || m_node_address == 0)
return 0;
- auto [size_node_sp, is_compressed_pair] = GetValueOrOldCompressedPair(
- m_backend, /*anon_struct_idx=*/1, "__size_", "__size_alloc_");
+ auto [size_node_sp, is_compressed_pair] =
+ GetValueOrOldCompressedPair(m_backend, "__size_", "__size_alloc_");
if (is_compressed_pair)
size_node_sp = GetFirstValueOfLibCXXCompressedPair(*size_node_sp);
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index 141c5c9a2caf9..df599d708cda0 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -104,21 +104,12 @@
lldb_private::formatters::GetSecondValueOfLibCXXCompressedPair(
std::pair
lldb_private::formatters::GetValueOrOldCompressedPair(
-ValueObject &obj, size_t anon_struct_idx, llvm::StringRef child_name,
+ValueObject &obj, llvm::StringRef child_name,
llvm::StringRef compressed_pair_name) {
auto is_old_compressed_pair = [](ValueObject &pair_obj) -> bool {
return isStdTemplate(pair_obj.GetTypeName(), "__compressed_pair");
};
- // Try searching the child member in an anonymous structure first.
- if (auto unwrapped = obj.GetChildAtIndex(anon_struct_idx)) {
-ValueObjectSP node_sp(obj.GetChildMemberWithName(child_name));
-if (node_sp)
- return {node_sp, is_old_compress
