@@ -70,6 +70,11 @@ class ASTRecordLayout {
70
70
// Alignment - Alignment of record in characters.
71
71
CharUnits Alignment;
72
72
73
+ // PreferredAlignment - Preferred alignment of record in characters. This
74
+ // can be different than Alignment in cases where it is beneficial for
75
+ // performance or backwards compatibility preserving (e.g. AIX-ABI).
76
+ CharUnits PreferredAlignment;
77
+
73
78
// UnadjustedAlignment - Maximum of the alignments of the record members in
74
79
// characters.
75
80
CharUnits UnadjustedAlignment;
@@ -91,6 +96,11 @@ class ASTRecordLayout {
91
96
// / which is the alignment of the object without virtual bases.
92
97
CharUnits NonVirtualAlignment;
93
98
99
+ // / PreferredNVAlignment - The preferred non-virtual alignment (in chars) of
100
+ // / an object, which is the preferred alignment of the object without
101
+ // / virtual bases.
102
+ CharUnits PreferredNVAlignment;
103
+
94
104
// / SizeOfLargestEmptySubobject - The size of the largest empty subobject
95
105
// / (either a base or a member). Will be zero if the class doesn't contain
96
106
// / any empty subobjects.
@@ -139,30 +149,26 @@ class ASTRecordLayout {
139
149
CXXRecordLayoutInfo *CXXInfo = nullptr ;
140
150
141
151
ASTRecordLayout (const ASTContext &Ctx, CharUnits size, CharUnits alignment,
142
- CharUnits unadjustedAlignment,
152
+ CharUnits preferredAlignment, CharUnits unadjustedAlignment,
143
153
CharUnits requiredAlignment, CharUnits datasize,
144
154
ArrayRef<uint64_t > fieldoffsets);
145
155
146
156
using BaseOffsetsMapTy = CXXRecordLayoutInfo::BaseOffsetsMapTy;
147
157
148
158
// Constructor for C++ records.
149
- ASTRecordLayout (const ASTContext &Ctx,
150
- CharUnits size, CharUnits alignment,
151
- CharUnits unadjustedAlignment,
152
- CharUnits requiredAlignment,
153
- bool hasOwnVFPtr, bool hasExtendableVFPtr,
154
- CharUnits vbptroffset,
155
- CharUnits datasize,
156
- ArrayRef<uint64_t > fieldoffsets,
159
+ ASTRecordLayout (const ASTContext &Ctx, CharUnits size, CharUnits alignment,
160
+ CharUnits preferredAlignment, CharUnits unadjustedAlignment,
161
+ CharUnits requiredAlignment, bool hasOwnVFPtr,
162
+ bool hasExtendableVFPtr, CharUnits vbptroffset,
163
+ CharUnits datasize, ArrayRef<uint64_t > fieldoffsets,
157
164
CharUnits nonvirtualsize, CharUnits nonvirtualalignment,
165
+ CharUnits preferrednvalignment,
158
166
CharUnits SizeOfLargestEmptySubobject,
159
- const CXXRecordDecl *PrimaryBase,
160
- bool IsPrimaryBaseVirtual,
167
+ const CXXRecordDecl *PrimaryBase, bool IsPrimaryBaseVirtual,
161
168
const CXXRecordDecl *BaseSharingVBPtr,
162
- bool EndsWithZeroSizedObject,
163
- bool LeadsWithZeroSizedBase,
164
- const BaseOffsetsMapTy& BaseOffsets,
165
- const VBaseOffsetsMapTy& VBaseOffsets);
169
+ bool EndsWithZeroSizedObject, bool LeadsWithZeroSizedBase,
170
+ const BaseOffsetsMapTy &BaseOffsets,
171
+ const VBaseOffsetsMapTy &VBaseOffsets);
166
172
167
173
~ASTRecordLayout () = default ;
168
174
@@ -175,6 +181,10 @@ class ASTRecordLayout {
175
181
// / getAlignment - Get the record alignment in characters.
176
182
CharUnits getAlignment () const { return Alignment; }
177
183
184
+ // / getPreferredFieldAlignment - Get the record preferred alignment in
185
+ // / characters.
186
+ CharUnits getPreferredAlignment () const { return PreferredAlignment; }
187
+
178
188
// / getUnadjustedAlignment - Get the record alignment in characters, before
179
189
// / alignment adjustement.
180
190
CharUnits getUnadjustedAlignment () const { return UnadjustedAlignment; }
@@ -193,9 +203,7 @@ class ASTRecordLayout {
193
203
194
204
// / getDataSize() - Get the record data size, which is the record size
195
205
// / without tail padding, in characters.
196
- CharUnits getDataSize () const {
197
- return DataSize;
198
- }
206
+ CharUnits getDataSize () const { return DataSize; }
199
207
200
208
// / getNonVirtualSize - Get the non-virtual size (in chars) of an object,
201
209
// / which is the size of the object without virtual bases.
@@ -205,14 +213,23 @@ class ASTRecordLayout {
205
213
return CXXInfo->NonVirtualSize ;
206
214
}
207
215
208
- // / getNonVirtualSize - Get the non-virtual alignment (in chars) of an object,
209
- // / which is the alignment of the object without virtual bases.
216
+ // / getNonVirtualAlignment - Get the non-virtual alignment (in chars) of an
217
+ // / object, which is the alignment of the object without virtual bases.
210
218
CharUnits getNonVirtualAlignment () const {
211
219
assert (CXXInfo && " Record layout does not have C++ specific info!" );
212
220
213
221
return CXXInfo->NonVirtualAlignment ;
214
222
}
215
223
224
+ // / getPreferredNVAlignment - Get the preferred non-virtual alignment (in
225
+ // / chars) of an object, which is the preferred alignment of the object
226
+ // / without virtual bases.
227
+ CharUnits getPreferredNVAlignment () const {
228
+ assert (CXXInfo && " Record layout does not have C++ specific info!" );
229
+
230
+ return CXXInfo->PreferredNVAlignment ;
231
+ }
232
+
216
233
// / getPrimaryBase - Get the primary base for this record.
217
234
const CXXRecordDecl *getPrimaryBase () const {
218
235
assert (CXXInfo && " Record layout does not have C++ specific info!" );
@@ -287,9 +304,7 @@ class ASTRecordLayout {
287
304
return !CXXInfo->VBPtrOffset .isNegative ();
288
305
}
289
306
290
- CharUnits getRequiredAlignment () const {
291
- return RequiredAlignment;
292
- }
307
+ CharUnits getRequiredAlignment () const { return RequiredAlignment; }
293
308
294
309
bool endsWithZeroSizedObject () const {
295
310
return CXXInfo && CXXInfo->EndsWithZeroSizedObject ;
0 commit comments