[Lldb-commits] [lldb] [lldb][test] TestDataFormatterLibcxxStringSimulator.py: add new padding layout (PR #108375)
Michael Buch via lldb-commits
lldb-commits at lists.llvm.org
Fri Sep 13 03:17:22 PDT 2024
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/108375
>From 7932edadf5726b2c73911d1316112af36ab7f044 Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Thu, 12 Sep 2024 12:55:17 +0100
Subject: [PATCH 1/2] [lldb][test] TestDataFormatterLibcxxStringSimulator.py:
add new padding layout
Depends on https://github.com/llvm/llvm-project/pull/108362.
Adds new layout for https://github.com/llvm/llvm-project/pull/105865.
---
.../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 98d2c7320003e4..dd9f5de22c9057 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):
name = "test_r%d" % r
defines = ["REVISION=%d" % r]
if v:
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 b010dc25f8f804..5cf3a85007fb64 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-TODO layout.
+#define UB_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 UB_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 // !UB_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 UB_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 UB_PADDING
+ unsigned char __padding[sizeof(value_type) - 1];
+#else // !UB_PADDING
+ [[no_unique_address]] __padding<sizeof(value_type) - 1> __padding_;
+#endif // UB_PADDING
+
+#endif // SHORT_UNION
value_type __data_[__min_cap];
};
>From d3d78e4a2582fe8f572969b694675f90184894fa Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Fri, 13 Sep 2024 11:16:52 +0100
Subject: [PATCH 2/2] fixup! rename ifdef
---
.../libcxx-simulators/string/main.cpp | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
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 5cf3a85007fb64..944d90ab187ba4 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
@@ -22,7 +22,7 @@
#endif
#if REVISION <= 4
// Pre-TODO layout.
-#define UB_PADDING
+#define NON_STANDARD_PADDING
#endif
// REVISION == 5: current layout
@@ -38,7 +38,7 @@
namespace std {
namespace __lldb {
-#ifdef UB_PADDING
+#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];
@@ -46,7 +46,7 @@ template <class _CharT, size_t = sizeof(_CharT)> struct __padding {
template <class _CharT> struct __padding<_CharT, 1> {};
#endif
-#else // !UB_PADDING
+#else // !NON_STANDARD_PADDING
template <size_t _PaddingSize> struct __padding {
char __padding_[_PaddingSize];
};
@@ -89,7 +89,7 @@ template <class _CharT, class _Traits, class _Allocator> class basic_string {
};
#else // !SUBCLASS_PADDING
-#ifdef UB_PADDING
+#ifdef NON_STANDARD_PADDING
unsigned char __padding[sizeof(value_type) - 1];
#else
[[no_unique_address]] __padding<sizeof(value_type) - 1> __padding_;
@@ -159,11 +159,11 @@ template <class _CharT, class _Traits, class _Allocator> class basic_string {
unsigned char __is_long_ : 1;
unsigned char __size_ : 7;
END_PACKED_ANON_STRUCT
-#ifdef UB_PADDING
+#ifdef NON_STANDARD_PADDING
unsigned char __padding[sizeof(value_type) - 1];
-#else // !UB_PADDING
+#else // !NON_STANDARD_PADDING
[[no_unique_address]] __padding<sizeof(value_type) - 1> __padding_;
-#endif // UB_PADDING
+#endif // NON_STANDARD_PADDING
#endif // SHORT_UNION
value_type __data_[__min_cap];
More information about the lldb-commits
mailing list