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 (llvm#108375)

Depends on llvm#108362 and
llvm#108343.

Adds new layout for llvm#105865.
  • Loading branch information
Michael137 authored and xgupta committed Oct 4, 2024
1 parent 4b5c87f commit b5bde9a
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):
for c in range(3):
name = "test_r%d_c%d" % (r, c)
defines = ["REVISION=%d" % r, "COMPRESSED_PAIR_REV=%d" % c]
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-2a1ef74 layout.
#define NON_STANDARD_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 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];
};

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

Expand Down

0 comments on commit b5bde9a

Please sign in to comment.