Skip to content

Commit

Permalink
[lldb][test] TestDataFormatterLibcxxStringSimulator.py: add new paddi…
Browse files Browse the repository at this point in the history
…ng layout

Depends on llvm#108362.

Adds new layout for llvm#105865.
  • Loading branch information
Michael137 committed Sep 12, 2024
1 parent 258b6fd commit 35971a4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -34,13 +38,21 @@
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];
};

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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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];
};

Expand Down

0 comments on commit 35971a4

Please sign in to comment.