/// an adjacent bitfield if necessary. The unit in question is usually
/// a byte, but larger units are used if IsMsStruct.
unsigned char UnfilledBitsInLastUnit;
- /// LastBitfieldTypeSize - If IsMsStruct, represents the size of the type
- /// of the previous field if it was a bitfield.
- unsigned char LastBitfieldTypeSize;
+
+ /// LastBitfieldStorageUnitSize - If IsMsStruct, represents the size of the
+ /// storage unit of the previous field if it was a bitfield.
+ unsigned char LastBitfieldStorageUnitSize;
/// MaxFieldAlignment - The maximum allowed field alignment. This is set by
/// #pragma pack.
UnadjustedAlignment(CharUnits::One()), UseExternalLayout(false),
InferAlignment(false), Packed(false), IsUnion(false),
IsMac68kAlign(false), IsMsStruct(false), UnfilledBitsInLastUnit(0),
- LastBitfieldTypeSize(0), MaxFieldAlignment(CharUnits::Zero()),
+ LastBitfieldStorageUnitSize(0), MaxFieldAlignment(CharUnits::Zero()),
DataSize(0), NonVirtualSize(CharUnits::Zero()),
NonVirtualAlignment(CharUnits::One()),
PreferredNVAlignment(CharUnits::One()),
void LayoutFields(const RecordDecl *D);
void LayoutField(const FieldDecl *D, bool InsertExtraPadding);
- void LayoutWideBitField(uint64_t FieldSize, uint64_t TypeSize,
+ void LayoutWideBitField(uint64_t FieldSize, uint64_t StorageUnitSize,
bool FieldPacked, const FieldDecl *D);
void LayoutBitField(const FieldDecl *D);
}
void ItaniumRecordLayoutBuilder::LayoutWideBitField(uint64_t FieldSize,
- uint64_t TypeSize,
+ uint64_t StorageUnitSize,
bool FieldPacked,
const FieldDecl *D) {
assert(Context.getLangOpts().CPlusPlus &&
// We're not going to use any of the unfilled bits in the last byte.
UnfilledBitsInLastUnit = 0;
- LastBitfieldTypeSize = 0;
+ LastBitfieldStorageUnitSize = 0;
uint64_t FieldOffset;
uint64_t UnpaddedFieldOffset = getDataSizeInBits() - UnfilledBitsInLastUnit;
bool FieldPacked = Packed || D->hasAttr<PackedAttr>();
uint64_t FieldSize = D->getBitWidthValue(Context);
TypeInfo FieldInfo = Context.getTypeInfo(D->getType());
- uint64_t TypeSize = FieldInfo.Width;
+ uint64_t StorageUnitSize = FieldInfo.Width;
unsigned FieldAlign = FieldInfo.Align;
// UnfilledBitsInLastUnit is the difference between the end of the
// first bit offset available for non-bitfields). The current data
// size in bits is always a multiple of the char size; additionally,
// for ms_struct records it's also a multiple of the
- // LastBitfieldTypeSize (if set).
+ // LastBitfieldStorageUnitSize (if set).
// The struct-layout algorithm is dictated by the platform ABI,
// which in principle could use almost any rules it likes. In
// First, some simple bookkeeping to perform for ms_struct structs.
if (IsMsStruct) {
// The field alignment for integer types is always the size.
- FieldAlign = TypeSize;
+ FieldAlign = StorageUnitSize;
// If the previous field was not a bitfield, or was a bitfield
// with a different storage unit size, or if this field doesn't fit into
// the current storage unit, we're done with that storage unit.
- if (LastBitfieldTypeSize != TypeSize ||
+ if (LastBitfieldStorageUnitSize != StorageUnitSize ||
UnfilledBitsInLastUnit < FieldSize) {
// Also, ignore zero-length bitfields after non-bitfields.
- if (!LastBitfieldTypeSize && !FieldSize)
+ if (!LastBitfieldStorageUnitSize && !FieldSize)
FieldAlign = 1;
UnfilledBitsInLastUnit = 0;
- LastBitfieldTypeSize = 0;
+ LastBitfieldStorageUnitSize = 0;
}
}
// If the field is wider than its declared type, it follows
// different rules in all cases.
- if (FieldSize > TypeSize) {
- LayoutWideBitField(FieldSize, TypeSize, FieldPacked, D);
+ if (FieldSize > StorageUnitSize) {
+ LayoutWideBitField(FieldSize, StorageUnitSize, FieldPacked, D);
return;
}
// Compute the real offset.
if (FieldSize == 0 ||
(AllowPadding &&
- (FieldOffset & (FieldAlign-1)) + FieldSize > TypeSize)) {
+ (FieldOffset & (FieldAlign - 1)) + FieldSize > StorageUnitSize)) {
FieldOffset = llvm::alignTo(FieldOffset, FieldAlign);
} else if (ExplicitFieldAlign &&
(MaxFieldAlignmentInBits == 0 ||
// Repeat the computation for diagnostic purposes.
if (FieldSize == 0 ||
(AllowPadding &&
- (UnpackedFieldOffset & (UnpackedFieldAlign-1)) + FieldSize > TypeSize))
+ (UnpackedFieldOffset & (UnpackedFieldAlign - 1)) + FieldSize >
+ StorageUnitSize))
UnpackedFieldOffset =
llvm::alignTo(UnpackedFieldOffset, UnpackedFieldAlign);
else if (ExplicitFieldAlign &&
// is a zero-width bitfield, in which case just use a size of 1.
uint64_t RoundedFieldSize;
if (IsMsStruct) {
- RoundedFieldSize =
- (FieldSize ? TypeSize : Context.getTargetInfo().getCharWidth());
+ RoundedFieldSize = (FieldSize ? StorageUnitSize
+ : Context.getTargetInfo().getCharWidth());
- // Otherwise, allocate just the number of bytes required to store
- // the bitfield.
+ // Otherwise, allocate just the number of bytes required to store
+ // the bitfield.
} else {
RoundedFieldSize = roundUpSizeToCharAlignment(FieldSize, Context);
}
// We should have cleared UnfilledBitsInLastUnit in every case
// where we changed storage units.
if (!UnfilledBitsInLastUnit) {
- setDataSize(FieldOffset + TypeSize);
- UnfilledBitsInLastUnit = TypeSize;
+ setDataSize(FieldOffset + StorageUnitSize);
+ UnfilledBitsInLastUnit = StorageUnitSize;
}
UnfilledBitsInLastUnit -= FieldSize;
- LastBitfieldTypeSize = TypeSize;
+ LastBitfieldStorageUnitSize = StorageUnitSize;
- // Otherwise, bump the data size up to include the bitfield,
- // including padding up to char alignment, and then remember how
- // bits we didn't use.
+ // Otherwise, bump the data size up to include the bitfield,
+ // including padding up to char alignment, and then remember how
+ // bits we didn't use.
} else {
uint64_t NewSizeInBits = FieldOffset + FieldSize;
uint64_t CharAlignment = Context.getTargetInfo().getCharAlign();
// The only time we can get here for an ms_struct is if this is a
// zero-width bitfield, which doesn't count as anything for the
// purposes of unfilled bits.
- LastBitfieldTypeSize = 0;
+ LastBitfieldStorageUnitSize = 0;
}
// Update the size.
uint64_t UnpaddedFieldOffset = getDataSizeInBits() - UnfilledBitsInLastUnit;
// Reset the unfilled bits.
UnfilledBitsInLastUnit = 0;
- LastBitfieldTypeSize = 0;
+ LastBitfieldStorageUnitSize = 0;
bool FieldPacked = Packed || D->hasAttr<PackedAttr>();