Skip to content

[lldb][test] Synchronize __compressed_pair_padding with libc++ #142516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

frederick-vs-ja
Copy link
Contributor

@llvmbot
Copy link
Member

llvmbot commented Jun 3, 2025

@llvm/pr-subscribers-lldb

Author: A. Jiang (frederick-vs-ja)

Changes

This PR mirrors changes of __compressed_pair_padding in libc++ into lldb test suite.

Related PR for libc++:

  • #108956
  • #109028
  • #142125

Full diff: https://github.com/llvm/llvm-project/pull/142516.diff

1 Files Affected:

  • (modified) lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h (+16-6)
diff --git a/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h b/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h
index 6dc53a4e88ffd..3f305bdcb4d54 100644
--- a/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h
+++ b/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h
@@ -72,14 +72,24 @@ inline const size_t __datasizeof_v =
 template <class _Tp>
 struct __lldb_is_final : public integral_constant<bool, __is_final(_Tp)> {};
 
-template <class _ToPad> class __compressed_pair_padding {
-  char __padding_[((is_empty<_ToPad>::value &&
-                    !__lldb_is_final<_ToPad>::value) ||
-                   is_reference<_ToPad>::value)
-                      ? 0
-                      : sizeof(_ToPad) - __datasizeof_v<_ToPad>];
+template <class _ToPad>
+inline const bool __is_reference_or_unpadded_object =
+    (std::is_empty<_ToPad>::value && !__lldb_is_final<_ToPad>::value) ||
+    sizeof(_ToPad) == __datasizeof_v<_ToPad>;
+
+template <class _Tp>
+inline const bool __is_reference_or_unpadded_object<_Tp &> = true;
+
+template <class _Tp>
+inline const bool __is_reference_or_unpadded_object<_Tp &&> = true;
+
+template <class _ToPad, bool _Empty = __is_reference_or_unpadded_object<_ToPad>>
+class __compressed_pair_padding {
+  char __padding_[sizeof(_ToPad) - __datasizeof_v<_ToPad>] = {};
 };
 
+template <class _ToPad> class __compressed_pair_padding<_ToPad, true> {};
+
 #define _LLDB_COMPRESSED_PAIR(T1, Initializer1, T2, Initializer2)              \
   [[__gnu__::__aligned__(                                                      \
       alignof(T2))]] _LLDB_NO_UNIQUE_ADDRESS T1 Initializer1;                  \

};

template <class _ToPad> class __compressed_pair_padding<_ToPad, true> {};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for keeping this in sync! What we would usually do with these simulators is to add the new implementation behind a ifdef COMPRESSED_PAIR_REV == <new version>. To make sure we don't regress users still on the older layout. Do you mind doing that? If it's too finicky I'm happy to give it a shot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants