@@ -622,9 +622,10 @@ class ItaniumRecordLayoutBuilder {
622
622
// / an adjacent bitfield if necessary. The unit in question is usually
623
623
// / a byte, but larger units are used if IsMsStruct.
624
624
unsigned char UnfilledBitsInLastUnit;
625
- // / LastBitfieldTypeSize - If IsMsStruct, represents the size of the type
626
- // / of the previous field if it was a bitfield.
627
- unsigned char LastBitfieldTypeSize;
625
+
626
+ // / LastBitfieldStorageUnitSize - If IsMsStruct, represents the size of the
627
+ // / storage unit of the previous field if it was a bitfield.
628
+ unsigned char LastBitfieldStorageUnitSize;
628
629
629
630
// / MaxFieldAlignment - The maximum allowed field alignment. This is set by
630
631
// / #pragma pack.
@@ -693,7 +694,7 @@ class ItaniumRecordLayoutBuilder {
693
694
UnadjustedAlignment(CharUnits::One()), UseExternalLayout(false ),
694
695
InferAlignment(false ), Packed(false ), IsUnion(false ),
695
696
IsMac68kAlign(false ), IsMsStruct(false ), UnfilledBitsInLastUnit(0 ),
696
- LastBitfieldTypeSize (0 ), MaxFieldAlignment(CharUnits::Zero()),
697
+ LastBitfieldStorageUnitSize (0 ), MaxFieldAlignment(CharUnits::Zero()),
697
698
DataSize(0 ), NonVirtualSize(CharUnits::Zero()),
698
699
NonVirtualAlignment(CharUnits::One()),
699
700
PreferredNVAlignment(CharUnits::One()),
@@ -708,7 +709,7 @@ class ItaniumRecordLayoutBuilder {
708
709
709
710
void LayoutFields (const RecordDecl *D);
710
711
void LayoutField (const FieldDecl *D, bool InsertExtraPadding);
711
- void LayoutWideBitField (uint64_t FieldSize, uint64_t TypeSize ,
712
+ void LayoutWideBitField (uint64_t FieldSize, uint64_t StorageUnitSize ,
712
713
bool FieldPacked, const FieldDecl *D);
713
714
void LayoutBitField (const FieldDecl *D);
714
715
@@ -1451,7 +1452,7 @@ roundUpSizeToCharAlignment(uint64_t Size,
1451
1452
}
1452
1453
1453
1454
void ItaniumRecordLayoutBuilder::LayoutWideBitField (uint64_t FieldSize,
1454
- uint64_t TypeSize ,
1455
+ uint64_t StorageUnitSize ,
1455
1456
bool FieldPacked,
1456
1457
const FieldDecl *D) {
1457
1458
assert (Context.getLangOpts ().CPlusPlus &&
@@ -1481,7 +1482,7 @@ void ItaniumRecordLayoutBuilder::LayoutWideBitField(uint64_t FieldSize,
1481
1482
1482
1483
// We're not going to use any of the unfilled bits in the last byte.
1483
1484
UnfilledBitsInLastUnit = 0 ;
1484
- LastBitfieldTypeSize = 0 ;
1485
+ LastBitfieldStorageUnitSize = 0 ;
1485
1486
1486
1487
uint64_t FieldOffset;
1487
1488
uint64_t UnpaddedFieldOffset = getDataSizeInBits () - UnfilledBitsInLastUnit;
@@ -1520,7 +1521,7 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const FieldDecl *D) {
1520
1521
bool FieldPacked = Packed || D->hasAttr <PackedAttr>();
1521
1522
uint64_t FieldSize = D->getBitWidthValue (Context);
1522
1523
TypeInfo FieldInfo = Context.getTypeInfo (D->getType ());
1523
- uint64_t TypeSize = FieldInfo.Width ;
1524
+ uint64_t StorageUnitSize = FieldInfo.Width ;
1524
1525
unsigned FieldAlign = FieldInfo.Align ;
1525
1526
1526
1527
// UnfilledBitsInLastUnit is the difference between the end of the
@@ -1529,7 +1530,7 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const FieldDecl *D) {
1529
1530
// first bit offset available for non-bitfields). The current data
1530
1531
// size in bits is always a multiple of the char size; additionally,
1531
1532
// for ms_struct records it's also a multiple of the
1532
- // LastBitfieldTypeSize (if set).
1533
+ // LastBitfieldStorageUnitSize (if set).
1533
1534
1534
1535
// The struct-layout algorithm is dictated by the platform ABI,
1535
1536
// which in principle could use almost any rules it likes. In
@@ -1583,26 +1584,26 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const FieldDecl *D) {
1583
1584
// First, some simple bookkeeping to perform for ms_struct structs.
1584
1585
if (IsMsStruct) {
1585
1586
// The field alignment for integer types is always the size.
1586
- FieldAlign = TypeSize ;
1587
+ FieldAlign = StorageUnitSize ;
1587
1588
1588
1589
// If the previous field was not a bitfield, or was a bitfield
1589
1590
// with a different storage unit size, or if this field doesn't fit into
1590
1591
// the current storage unit, we're done with that storage unit.
1591
- if (LastBitfieldTypeSize != TypeSize ||
1592
+ if (LastBitfieldStorageUnitSize != StorageUnitSize ||
1592
1593
UnfilledBitsInLastUnit < FieldSize) {
1593
1594
// Also, ignore zero-length bitfields after non-bitfields.
1594
- if (!LastBitfieldTypeSize && !FieldSize)
1595
+ if (!LastBitfieldStorageUnitSize && !FieldSize)
1595
1596
FieldAlign = 1 ;
1596
1597
1597
1598
UnfilledBitsInLastUnit = 0 ;
1598
- LastBitfieldTypeSize = 0 ;
1599
+ LastBitfieldStorageUnitSize = 0 ;
1599
1600
}
1600
1601
}
1601
1602
1602
1603
// If the field is wider than its declared type, it follows
1603
1604
// different rules in all cases.
1604
- if (FieldSize > TypeSize ) {
1605
- LayoutWideBitField (FieldSize, TypeSize , FieldPacked, D);
1605
+ if (FieldSize > StorageUnitSize ) {
1606
+ LayoutWideBitField (FieldSize, StorageUnitSize , FieldPacked, D);
1606
1607
return ;
1607
1608
}
1608
1609
@@ -1686,7 +1687,7 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const FieldDecl *D) {
1686
1687
// Compute the real offset.
1687
1688
if (FieldSize == 0 ||
1688
1689
(AllowPadding &&
1689
- (FieldOffset & (FieldAlign- 1 )) + FieldSize > TypeSize )) {
1690
+ (FieldOffset & (FieldAlign - 1 )) + FieldSize > StorageUnitSize )) {
1690
1691
FieldOffset = llvm::alignTo (FieldOffset, FieldAlign);
1691
1692
} else if (ExplicitFieldAlign &&
1692
1693
(MaxFieldAlignmentInBits == 0 ||
@@ -1700,7 +1701,8 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const FieldDecl *D) {
1700
1701
// Repeat the computation for diagnostic purposes.
1701
1702
if (FieldSize == 0 ||
1702
1703
(AllowPadding &&
1703
- (UnpackedFieldOffset & (UnpackedFieldAlign-1 )) + FieldSize > TypeSize))
1704
+ (UnpackedFieldOffset & (UnpackedFieldAlign - 1 )) + FieldSize >
1705
+ StorageUnitSize))
1704
1706
UnpackedFieldOffset =
1705
1707
llvm::alignTo (UnpackedFieldOffset, UnpackedFieldAlign);
1706
1708
else if (ExplicitFieldAlign &&
@@ -1741,11 +1743,11 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const FieldDecl *D) {
1741
1743
// is a zero-width bitfield, in which case just use a size of 1.
1742
1744
uint64_t RoundedFieldSize;
1743
1745
if (IsMsStruct) {
1744
- RoundedFieldSize =
1745
- (FieldSize ? TypeSize : Context.getTargetInfo ().getCharWidth ());
1746
+ RoundedFieldSize = (FieldSize ? StorageUnitSize
1747
+ : Context.getTargetInfo ().getCharWidth ());
1746
1748
1747
- // Otherwise, allocate just the number of bytes required to store
1748
- // the bitfield.
1749
+ // Otherwise, allocate just the number of bytes required to store
1750
+ // the bitfield.
1749
1751
} else {
1750
1752
RoundedFieldSize = roundUpSizeToCharAlignment (FieldSize, Context);
1751
1753
}
@@ -1757,15 +1759,15 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const FieldDecl *D) {
1757
1759
// We should have cleared UnfilledBitsInLastUnit in every case
1758
1760
// where we changed storage units.
1759
1761
if (!UnfilledBitsInLastUnit) {
1760
- setDataSize (FieldOffset + TypeSize );
1761
- UnfilledBitsInLastUnit = TypeSize ;
1762
+ setDataSize (FieldOffset + StorageUnitSize );
1763
+ UnfilledBitsInLastUnit = StorageUnitSize ;
1762
1764
}
1763
1765
UnfilledBitsInLastUnit -= FieldSize;
1764
- LastBitfieldTypeSize = TypeSize ;
1766
+ LastBitfieldStorageUnitSize = StorageUnitSize ;
1765
1767
1766
- // Otherwise, bump the data size up to include the bitfield,
1767
- // including padding up to char alignment, and then remember how
1768
- // bits we didn't use.
1768
+ // Otherwise, bump the data size up to include the bitfield,
1769
+ // including padding up to char alignment, and then remember how
1770
+ // bits we didn't use.
1769
1771
} else {
1770
1772
uint64_t NewSizeInBits = FieldOffset + FieldSize;
1771
1773
uint64_t CharAlignment = Context.getTargetInfo ().getCharAlign ();
@@ -1775,7 +1777,7 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const FieldDecl *D) {
1775
1777
// The only time we can get here for an ms_struct is if this is a
1776
1778
// zero-width bitfield, which doesn't count as anything for the
1777
1779
// purposes of unfilled bits.
1778
- LastBitfieldTypeSize = 0 ;
1780
+ LastBitfieldStorageUnitSize = 0 ;
1779
1781
}
1780
1782
1781
1783
// Update the size.
@@ -1825,7 +1827,7 @@ void ItaniumRecordLayoutBuilder::LayoutField(const FieldDecl *D,
1825
1827
uint64_t UnpaddedFieldOffset = getDataSizeInBits () - UnfilledBitsInLastUnit;
1826
1828
// Reset the unfilled bits.
1827
1829
UnfilledBitsInLastUnit = 0 ;
1828
- LastBitfieldTypeSize = 0 ;
1830
+ LastBitfieldStorageUnitSize = 0 ;
1829
1831
1830
1832
bool FieldPacked = Packed || D->hasAttr <PackedAttr>();
1831
1833
0 commit comments