[Lldb-commits] [lldb] [WIP] Reland "[lldb][test] TestDataFormatterLibcxxStringSimulator.py: add new padding layout" (PR #111123)
Michael Buch via lldb-commits
lldb-commits at lists.llvm.org
Fri Oct 4 02:33:20 PDT 2024
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/111123
>From 27ff173e19c5391fe175a144f5bb6909a98289f9 Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Fri, 4 Oct 2024 10:16:18 +0100
Subject: [PATCH 1/3] Reland "[lldb][test]
TestDataFormatterLibcxxStringSimulator.py: add new padding layout (#108375)"
This reverts commit ee4dd147baff8f971f3ec5aad5a216ca9837a732.
---
.../TestDataFormatterLibcxxStringSimulator.py | 2 +-
.../libcxx-simulators/string/main.cpp | 34 +++++++++++++++----
2 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py
index afe6374e55a355..fff181440b6d7c 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py
@@ -27,7 +27,7 @@ def _run_test(self, defines):
for v in [None, "ALTERNATE_LAYOUT"]:
- for r in range(5):
+ for r in range(6):
for c in range(3):
name = "test_r%d_c%d" % (r, c)
defines = ["REVISION=%d" % r, "COMPRESSED_PAIR_REV=%d" % c]
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/main.cpp
index f8fc13c10c4372..628d32c8d7a55e 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/main.cpp
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/main.cpp
@@ -20,7 +20,11 @@
// Pre-D128285 layout.
#define PACKED_ANON_STRUCT
#endif
-// REVISION == 4: current layout
+#if REVISION <= 4
+// Pre-2a1ef74 layout.
+#define NON_STANDARD_PADDING
+#endif
+// REVISION == 5: current layout
#ifdef PACKED_ANON_STRUCT
#define BEGIN_PACKED_ANON_STRUCT struct __attribute__((packed)) {
@@ -34,6 +38,7 @@
namespace std {
namespace __lldb {
+#ifdef NON_STANDARD_PADDING
#if defined(ALTERNATE_LAYOUT) && defined(SUBCLASS_PADDING)
template <class _CharT, size_t = sizeof(_CharT)> struct __padding {
unsigned char __xx[sizeof(_CharT) - 1];
@@ -41,6 +46,13 @@ template <class _CharT, size_t = sizeof(_CharT)> struct __padding {
template <class _CharT> struct __padding<_CharT, 1> {};
#endif
+#else // !NON_STANDARD_PADDING
+template <size_t _PaddingSize> struct __padding {
+ char __padding_[_PaddingSize];
+};
+
+template <> struct __padding<0> {};
+#endif
template <class _CharT, class _Traits, class _Allocator> class basic_string {
public:
@@ -77,7 +89,12 @@ template <class _CharT, class _Traits, class _Allocator> class basic_string {
};
#else // !SUBCLASS_PADDING
+#ifdef NON_STANDARD_PADDING
unsigned char __padding[sizeof(value_type) - 1];
+#else
+ [[no_unique_address]] __padding<sizeof(value_type) - 1> __padding_;
+#endif
+
#ifdef BITMASKS
unsigned char __size_;
#else // !BITMASKS
@@ -129,21 +146,26 @@ template <class _CharT, class _Traits, class _Allocator> class basic_string {
union {
#ifdef BITMASKS
unsigned char __size_;
-#else
+#else // !BITMASKS
struct {
unsigned char __is_long_ : 1;
unsigned char __size_ : 7;
};
-#endif
+#endif // BITMASKS
value_type __lx;
};
-#else
+#else // !SHORT_UNION
BEGIN_PACKED_ANON_STRUCT
unsigned char __is_long_ : 1;
unsigned char __size_ : 7;
END_PACKED_ANON_STRUCT
- char __padding_[sizeof(value_type) - 1];
-#endif
+#ifdef NON_STANDARD_PADDING
+ unsigned char __padding[sizeof(value_type) - 1];
+#else // !NON_STANDARD_PADDING
+ [[no_unique_address]] __padding<sizeof(value_type) - 1> __padding_;
+#endif // NON_STANDARD_PADDING
+
+#endif // SHORT_UNION
value_type __data_[__min_cap];
};
>From 81179dc2fb9272d3d4192e9a938a204cb6466e43 Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Fri, 4 Oct 2024 10:24:15 +0100
Subject: [PATCH 2/3] fixup!
---
.../compressed_pair.h | 39 +++++++++++--------
.../libcxx-simulators/string/main.cpp | 4 +-
2 files changed, 25 insertions(+), 18 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 89eafcec0ea962..6dc53a4e88ffdd 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
@@ -7,6 +7,12 @@
namespace std {
namespace __lldb {
+#if __has_cpp_attribute(msvc::no_unique_address)
+#define _LLDB_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
+#elif __has_cpp_attribute(no_unique_address)
+#define _LLDB_NO_UNIQUE_ADDRESS [[__no_unique_address__]]
+#endif
+
#if COMPRESSED_PAIR_REV == 0 // Post-c88580c layout
struct __value_init_tag {};
struct __default_init_tag {};
@@ -55,7 +61,7 @@ class __compressed_pair : private __compressed_pair_elem<_T1, 0>,
#elif COMPRESSED_PAIR_REV == 1
// From libc++ datasizeof.h
template <class _Tp> struct _FirstPaddingByte {
- [[no_unique_address]] _Tp __v_;
+ _LLDB_NO_UNIQUE_ADDRESS _Tp __v_;
char __first_padding_byte_;
};
@@ -75,29 +81,30 @@ template <class _ToPad> class __compressed_pair_padding {
};
#define _LLDB_COMPRESSED_PAIR(T1, Initializer1, T2, Initializer2) \
- [[__gnu__::__aligned__(alignof(T2))]] [[no_unique_address]] T1 Initializer1; \
- [[no_unique_address]] __compressed_pair_padding<T1> __padding1_; \
- [[no_unique_address]] T2 Initializer2; \
- [[no_unique_address]] __compressed_pair_padding<T2> __padding2_;
+ [[__gnu__::__aligned__( \
+ alignof(T2))]] _LLDB_NO_UNIQUE_ADDRESS T1 Initializer1; \
+ _LLDB_NO_UNIQUE_ADDRESS __compressed_pair_padding<T1> __padding1_; \
+ _LLDB_NO_UNIQUE_ADDRESS T2 Initializer2; \
+ _LLDB_NO_UNIQUE_ADDRESS __compressed_pair_padding<T2> __padding2_;
#define _LLDB_COMPRESSED_TRIPLE(T1, Initializer1, T2, Initializer2, T3, \
Initializer3) \
[[using __gnu__: __aligned__(alignof(T2)), \
- __aligned__(alignof(T3))]] [[no_unique_address]] T1 Initializer1; \
- [[no_unique_address]] __compressed_pair_padding<T1> __padding1_; \
- [[no_unique_address]] T2 Initializer2; \
- [[no_unique_address]] __compressed_pair_padding<T2> __padding2_; \
- [[no_unique_address]] T3 Initializer3; \
- [[no_unique_address]] __compressed_pair_padding<T3> __padding3_;
+ __aligned__(alignof(T3))]] _LLDB_NO_UNIQUE_ADDRESS T1 Initializer1; \
+ _LLDB_NO_UNIQUE_ADDRESS __compressed_pair_padding<T1> __padding1_; \
+ _LLDB_NO_UNIQUE_ADDRESS T2 Initializer2; \
+ _LLDB_NO_UNIQUE_ADDRESS __compressed_pair_padding<T2> __padding2_; \
+ _LLDB_NO_UNIQUE_ADDRESS T3 Initializer3; \
+ _LLDB_NO_UNIQUE_ADDRESS __compressed_pair_padding<T3> __padding3_;
#elif COMPRESSED_PAIR_REV == 2
#define _LLDB_COMPRESSED_PAIR(T1, Name1, T2, Name2) \
- [[no_unique_address]] T1 Name1; \
- [[no_unique_address]] T2 Name2
+ _LLDB_NO_UNIQUE_ADDRESS T1 Name1; \
+ _LLDB_NO_UNIQUE_ADDRESS T2 Name2
#define _LLDB_COMPRESSED_TRIPLE(T1, Name1, T2, Name2, T3, Name3) \
- [[no_unique_address]] T1 Name1; \
- [[no_unique_address]] T2 Name2; \
- [[no_unique_address]] T3 Name3
+ _LLDB_NO_UNIQUE_ADDRESS T1 Name1; \
+ _LLDB_NO_UNIQUE_ADDRESS T2 Name2; \
+ _LLDB_NO_UNIQUE_ADDRESS T3 Name3
#endif
} // namespace __lldb
} // namespace std
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/main.cpp
index 628d32c8d7a55e..fdf8d53a341384 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/main.cpp
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/main.cpp
@@ -92,7 +92,7 @@ template <class _CharT, class _Traits, class _Allocator> class basic_string {
#ifdef NON_STANDARD_PADDING
unsigned char __padding[sizeof(value_type) - 1];
#else
- [[no_unique_address]] __padding<sizeof(value_type) - 1> __padding_;
+ _LLDB_NO_UNIQUE_ADDRESS __padding<sizeof(value_type) - 1> __padding_;
#endif
#ifdef BITMASKS
@@ -162,7 +162,7 @@ template <class _CharT, class _Traits, class _Allocator> class basic_string {
#ifdef NON_STANDARD_PADDING
unsigned char __padding[sizeof(value_type) - 1];
#else // !NON_STANDARD_PADDING
- [[no_unique_address]] __padding<sizeof(value_type) - 1> __padding_;
+ _LLDB_NO_UNIQUE_ADDRESS __padding<sizeof(value_type) - 1> __padding_;
#endif // NON_STANDARD_PADDING
#endif // SHORT_UNION
>From c7278ddc820025b7ba9797150fa088d982c02533 Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Fri, 4 Oct 2024 10:33:08 +0100
Subject: [PATCH 3/3] TEST COMMIT
---
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index fe0c53a7e9a3ea..08a25468d43848 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -71,7 +71,6 @@
#include "lldb/Utility/Flags.h"
#include "lldb/Utility/LLDBAssert.h"
#include "lldb/Utility/LLDBLog.h"
-#include "lldb/Utility/RegularExpression.h"
#include "lldb/Utility/Scalar.h"
#include "lldb/Utility/ThreadSafeDenseMap.h"
More information about the lldb-commits
mailing list