@@ -70,6 +70,11 @@ class ASTRecordLayout {
7070 // Alignment - Alignment of record in characters.
7171 CharUnits Alignment;
7272
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+
7378 // UnadjustedAlignment - Maximum of the alignments of the record members in
7479 // characters.
7580 CharUnits UnadjustedAlignment;
@@ -91,6 +96,11 @@ class ASTRecordLayout {
9196 // / which is the alignment of the object without virtual bases.
9297 CharUnits NonVirtualAlignment;
9398
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+
94104 // / SizeOfLargestEmptySubobject - The size of the largest empty subobject
95105 // / (either a base or a member). Will be zero if the class doesn't contain
96106 // / any empty subobjects.
@@ -139,30 +149,26 @@ class ASTRecordLayout {
139149 CXXRecordLayoutInfo *CXXInfo = nullptr ;
140150
141151 ASTRecordLayout (const ASTContext &Ctx, CharUnits size, CharUnits alignment,
142- CharUnits unadjustedAlignment,
152+ CharUnits preferredAlignment, CharUnits unadjustedAlignment,
143153 CharUnits requiredAlignment, CharUnits datasize,
144154 ArrayRef<uint64_t > fieldoffsets);
145155
146156 using BaseOffsetsMapTy = CXXRecordLayoutInfo::BaseOffsetsMapTy;
147157
148158 // 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,
157164 CharUnits nonvirtualsize, CharUnits nonvirtualalignment,
165+ CharUnits preferrednvalignment,
158166 CharUnits SizeOfLargestEmptySubobject,
159- const CXXRecordDecl *PrimaryBase,
160- bool IsPrimaryBaseVirtual,
167+ const CXXRecordDecl *PrimaryBase, bool IsPrimaryBaseVirtual,
161168 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);
166172
167173 ~ASTRecordLayout () = default ;
168174
@@ -175,6 +181,10 @@ class ASTRecordLayout {
175181 // / getAlignment - Get the record alignment in characters.
176182 CharUnits getAlignment () const { return Alignment; }
177183
184+ // / getPreferredFieldAlignment - Get the record preferred alignment in
185+ // / characters.
186+ CharUnits getPreferredAlignment () const { return PreferredAlignment; }
187+
178188 // / getUnadjustedAlignment - Get the record alignment in characters, before
179189 // / alignment adjustement.
180190 CharUnits getUnadjustedAlignment () const { return UnadjustedAlignment; }
@@ -193,9 +203,7 @@ class ASTRecordLayout {
193203
194204 // / getDataSize() - Get the record data size, which is the record size
195205 // / without tail padding, in characters.
196- CharUnits getDataSize () const {
197- return DataSize;
198- }
206+ CharUnits getDataSize () const { return DataSize; }
199207
200208 // / getNonVirtualSize - Get the non-virtual size (in chars) of an object,
201209 // / which is the size of the object without virtual bases.
@@ -205,14 +213,23 @@ class ASTRecordLayout {
205213 return CXXInfo->NonVirtualSize ;
206214 }
207215
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.
210218 CharUnits getNonVirtualAlignment () const {
211219 assert (CXXInfo && " Record layout does not have C++ specific info!" );
212220
213221 return CXXInfo->NonVirtualAlignment ;
214222 }
215223
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+
216233 // / getPrimaryBase - Get the primary base for this record.
217234 const CXXRecordDecl *getPrimaryBase () const {
218235 assert (CXXInfo && " Record layout does not have C++ specific info!" );
@@ -287,9 +304,7 @@ class ASTRecordLayout {
287304 return !CXXInfo->VBPtrOffset .isNegative ();
288305 }
289306
290- CharUnits getRequiredAlignment () const {
291- return RequiredAlignment;
292- }
307+ CharUnits getRequiredAlignment () const { return RequiredAlignment; }
293308
294309 bool endsWithZeroSizedObject () const {
295310 return CXXInfo && CXXInfo->EndsWithZeroSizedObject ;
0 commit comments