|
20 | 20 | // Pre-D128285 layout.
|
21 | 21 | #define PACKED_ANON_STRUCT
|
22 | 22 | #endif
|
23 |
| -// REVISION == 4: current layout |
| 23 | +#if REVISION <= 4 |
| 24 | +// Pre-2a1ef74 layout. |
| 25 | +#define NON_STANDARD_PADDING |
| 26 | +#endif |
| 27 | +// REVISION == 5: current layout |
24 | 28 |
|
25 | 29 | #ifdef PACKED_ANON_STRUCT
|
26 | 30 | #define BEGIN_PACKED_ANON_STRUCT struct __attribute__((packed)) {
|
|
34 | 38 | namespace std {
|
35 | 39 | namespace __lldb {
|
36 | 40 |
|
| 41 | +#ifdef NON_STANDARD_PADDING |
37 | 42 | #if defined(ALTERNATE_LAYOUT) && defined(SUBCLASS_PADDING)
|
38 | 43 | template <class _CharT, size_t = sizeof(_CharT)> struct __padding {
|
39 | 44 | unsigned char __xx[sizeof(_CharT) - 1];
|
40 | 45 | };
|
41 | 46 |
|
42 | 47 | template <class _CharT> struct __padding<_CharT, 1> {};
|
43 | 48 | #endif
|
| 49 | +#else // !NON_STANDARD_PADDING |
| 50 | +template <size_t _PaddingSize> struct __padding { |
| 51 | + char __padding_[_PaddingSize]; |
| 52 | +}; |
| 53 | + |
| 54 | +template <> struct __padding<0> {}; |
| 55 | +#endif |
44 | 56 |
|
45 | 57 | template <class _CharT, class _Traits, class _Allocator> class basic_string {
|
46 | 58 | public:
|
@@ -77,7 +89,12 @@ template <class _CharT, class _Traits, class _Allocator> class basic_string {
|
77 | 89 | };
|
78 | 90 | #else // !SUBCLASS_PADDING
|
79 | 91 |
|
| 92 | +#ifdef NON_STANDARD_PADDING |
80 | 93 | unsigned char __padding[sizeof(value_type) - 1];
|
| 94 | +#else |
| 95 | + [[no_unique_address]] __padding<sizeof(value_type) - 1> __padding_; |
| 96 | +#endif |
| 97 | + |
81 | 98 | #ifdef BITMASKS
|
82 | 99 | unsigned char __size_;
|
83 | 100 | #else // !BITMASKS
|
@@ -129,21 +146,26 @@ template <class _CharT, class _Traits, class _Allocator> class basic_string {
|
129 | 146 | union {
|
130 | 147 | #ifdef BITMASKS
|
131 | 148 | unsigned char __size_;
|
132 |
| -#else |
| 149 | +#else // !BITMASKS |
133 | 150 | struct {
|
134 | 151 | unsigned char __is_long_ : 1;
|
135 | 152 | unsigned char __size_ : 7;
|
136 | 153 | };
|
137 |
| -#endif |
| 154 | +#endif // BITMASKS |
138 | 155 | value_type __lx;
|
139 | 156 | };
|
140 |
| -#else |
| 157 | +#else // !SHORT_UNION |
141 | 158 | BEGIN_PACKED_ANON_STRUCT
|
142 | 159 | unsigned char __is_long_ : 1;
|
143 | 160 | unsigned char __size_ : 7;
|
144 | 161 | END_PACKED_ANON_STRUCT
|
145 |
| - char __padding_[sizeof(value_type) - 1]; |
146 |
| -#endif |
| 162 | +#ifdef NON_STANDARD_PADDING |
| 163 | + unsigned char __padding[sizeof(value_type) - 1]; |
| 164 | +#else // !NON_STANDARD_PADDING |
| 165 | + [[no_unique_address]] __padding<sizeof(value_type) - 1> __padding_; |
| 166 | +#endif // NON_STANDARD_PADDING |
| 167 | + |
| 168 | +#endif // SHORT_UNION |
147 | 169 | value_type __data_[__min_cap];
|
148 | 170 | };
|
149 | 171 |
|
|
0 commit comments