diff options
author | Michael Buch <michaelbuch12@gmail.com> | 2025-08-24 13:25:58 +0100 |
---|---|---|
committer | Michael Buch <michaelbuch12@gmail.com> | 2025-08-24 13:32:21 +0100 |
commit | 7b22660d2aa0a9906e85d2c25e8a6577c39b31e0 (patch) | |
tree | 4bd11202b16f0875ba75ec5b2b5342880fecd34f /lldb/packages/Python/lldbsuite/test | |
parent | c9106c8298df82ecaf91ae1e9d0cbccb5919c51a (diff) | |
download | llvm-7b22660d2aa0a9906e85d2c25e8a6577c39b31e0.zip llvm-7b22660d2aa0a9906e85d2c25e8a6577c39b31e0.tar.gz llvm-7b22660d2aa0a9906e85d2c25e8a6577c39b31e0.tar.bz2 |
[lldb][test][NFC] Re-arrange ifdefs in compressed_pair.h
In an upcoming patch we'll start supporting a new compressed_pair
layout. This refactor will make it easier to add tests for that new
layout.
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h | 96 |
1 files changed, 51 insertions, 45 deletions
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 35649b1..491acb5 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 @@ -4,6 +4,12 @@ #include <type_traits> #include <utility> // for std::forward +// COMPRESSED_PAIR_REV versions: +// 0 -> Post-c88580c layout +// 1 -> Post-27c83382d83dc layout +// 2 -> Post-769c42f4a552a layout +// 3 -> padding-less no_unique_address-based layout (introduced in 27c83382d83dc) + namespace std { namespace __lldb { @@ -13,7 +19,50 @@ namespace __lldb { #define _LLDB_NO_UNIQUE_ADDRESS [[__no_unique_address__]] #endif -#if COMPRESSED_PAIR_REV == 0 // Post-c88580c layout +// From libc++ datasizeof.h +template <class _Tp> struct _FirstPaddingByte { + _LLDB_NO_UNIQUE_ADDRESS _Tp __v_; + char __first_padding_byte_; +}; + +template <class _Tp> +inline const size_t __datasizeof_v = + __builtin_offsetof(_FirstPaddingByte<_Tp>, __first_padding_byte_); + +template <class _Tp> +struct __lldb_is_final : public integral_constant<bool, __is_final(_Tp)> {}; + +// The legacy layout has been patched, see +// https://github.com/llvm/llvm-project/pull/142516. +#if COMPRESSED_PAIR_REV == 1 +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>]; +}; +#elif COMPRESSED_PAIR_REV > 1 && COMPRESSED_PAIR_REV < 3 +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> {}; +#endif // COMPRESSED_PAIR_REV == 1 + +#if COMPRESSED_PAIR_REV == 0 struct __value_init_tag {}; struct __default_init_tag {}; @@ -59,49 +108,6 @@ public: _T1 &first() { return static_cast<_Base1 &>(*this).__get(); } }; #elif COMPRESSED_PAIR_REV == 1 || COMPRESSED_PAIR_REV == 2 -// From libc++ datasizeof.h -template <class _Tp> struct _FirstPaddingByte { - _LLDB_NO_UNIQUE_ADDRESS _Tp __v_; - char __first_padding_byte_; -}; - -template <class _Tp> -inline const size_t __datasizeof_v = - __builtin_offsetof(_FirstPaddingByte<_Tp>, __first_padding_byte_); - -template <class _Tp> -struct __lldb_is_final : public integral_constant<bool, __is_final(_Tp)> {}; - -// The legacy layout has been patched, see -// https://github.com/llvm/llvm-project/pull/142516. -#if COMPRESSED_PAIR_REV == 1 -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>]; -}; -#else -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> {}; -#endif - #define _LLDB_COMPRESSED_PAIR(T1, Initializer1, T2, Initializer2) \ [[__gnu__::__aligned__( \ alignof(T2))]] _LLDB_NO_UNIQUE_ADDRESS T1 Initializer1; \ @@ -127,7 +133,7 @@ template <class _ToPad> class __compressed_pair_padding<_ToPad, true> {}; _LLDB_NO_UNIQUE_ADDRESS T1 Name1; \ _LLDB_NO_UNIQUE_ADDRESS T2 Name2; \ _LLDB_NO_UNIQUE_ADDRESS T3 Name3 -#endif +#endif // COMPRESSED_PAIR_REV == 3 } // namespace __lldb } // namespace std |