[cfe-commits] r125641 - /cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
Ken Dyck
kd at kendyck.com
Tue Feb 15 18:05:22 PST 2011
Author: kjdyck
Date: Tue Feb 15 20:05:21 2011
New Revision: 125641
URL: http://llvm.org/viewvc/llvm-project?rev=125641&view=rev
Log:
Convert Alignment member to CharUnits from bits. No change in functionality
intended.
Modified:
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=125641&r1=125640&r2=125641&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Tue Feb 15 20:05:21 2011
@@ -551,7 +551,7 @@
uint64_t Size;
/// Alignment - The current alignment of the record layout.
- unsigned Alignment;
+ CharUnits Alignment;
/// \brief The alignment if attribute packed is not used.
unsigned UnpackedAlignment;
@@ -610,12 +610,12 @@
RecordLayoutBuilder(const ASTContext &Context, EmptySubobjectMap
*EmptySubobjects)
- : Context(Context), EmptySubobjects(EmptySubobjects), Size(0), Alignment(8),
- UnpackedAlignment(Alignment), Packed(false), IsUnion(false),
- IsMac68kAlign(false), UnfilledBitsInLastByte(0), MaxFieldAlignment(0),
- DataSize(0), NonVirtualSize(CharUnits::Zero()),
- NonVirtualAlignment(CharUnits::One()), PrimaryBase(0),
- PrimaryBaseIsVirtual(false), FirstNearlyEmptyVBase(0) { }
+ : Context(Context), EmptySubobjects(EmptySubobjects), Size(0),
+ Alignment(CharUnits::One()), UnpackedAlignment(Context.toBits(Alignment)),
+ Packed(false), IsUnion(false), IsMac68kAlign(false),
+ UnfilledBitsInLastByte(0), MaxFieldAlignment(0), DataSize(0),
+ NonVirtualSize(CharUnits::Zero()), NonVirtualAlignment(CharUnits::One()),
+ PrimaryBase(0), PrimaryBaseIsVirtual(false), FirstNearlyEmptyVBase(0) { }
void Layout(const RecordDecl *D);
void Layout(const CXXRecordDecl *D);
@@ -1137,7 +1137,7 @@
if (D->hasAttr<AlignMac68kAttr>()) {
IsMac68kAlign = true;
MaxFieldAlignment = 2 * 8;
- Alignment = 2 * 8;
+ Alignment = CharUnits::fromQuantity(2);
} else {
if (const MaxFieldAlignmentAttr *MFAA = D->getAttr<MaxFieldAlignmentAttr>())
MaxFieldAlignment = MFAA->getAlignment();
@@ -1165,7 +1165,7 @@
LayoutFields(RD);
NonVirtualSize = Context.toCharUnitsFromBits(Size);
- NonVirtualAlignment = Context.toCharUnitsFromBits(Alignment);
+ NonVirtualAlignment = Alignment;
// Lay out the virtual bases and add the primary virtual base offsets.
LayoutVirtualBases(RD, RD);
@@ -1480,7 +1480,7 @@
// record itself.
uint64_t UnpaddedSize = Size - UnfilledBitsInLastByte;
uint64_t UnpackedSize = llvm::RoundUpToAlignment(Size, UnpackedAlignment);
- Size = llvm::RoundUpToAlignment(Size, Alignment);
+ Size = llvm::RoundUpToAlignment(Size, Context.toBits(Alignment));
unsigned CharBitNum = Context.Target.getCharWidth();
if (const RecordDecl *RD = dyn_cast<RecordDecl>(D)) {
@@ -1512,9 +1512,10 @@
if (IsMac68kAlign)
return;
- if (NewAlignment > Alignment) {
+ CharUnits NewAlignmentInChars = Context.toCharUnitsFromBits(NewAlignment);
+ if (NewAlignmentInChars > Alignment) {
assert(llvm::isPowerOf2_32(NewAlignment && "Alignment not a power of 2"));
- Alignment = NewAlignment;
+ Alignment = NewAlignmentInChars;
}
if (UnpackedNewAlignment > UnpackedAlignment) {
@@ -1685,7 +1686,7 @@
CharUnits RecordSize = toCharUnitsFromBits(Builder->Size);
NewEntry =
new (*this) ASTRecordLayout(*this, RecordSize,
- toCharUnitsFromBits(Builder->Alignment),
+ Builder->Alignment,
toCharUnitsFromBits(DataSize),
Builder->FieldOffsets.data(),
Builder->FieldOffsets.size(),
@@ -1703,7 +1704,7 @@
NewEntry =
new (*this) ASTRecordLayout(*this, RecordSize,
- toCharUnitsFromBits(Builder.Alignment),
+ Builder.Alignment,
toCharUnitsFromBits(Builder.Size),
Builder.FieldOffsets.data(),
Builder.FieldOffsets.size());
@@ -1764,7 +1765,7 @@
const ASTRecordLayout *NewEntry =
new (*this) ASTRecordLayout(*this, RecordSize,
- toCharUnitsFromBits(Builder.Alignment),
+ Builder.Alignment,
toCharUnitsFromBits(Builder.DataSize),
Builder.FieldOffsets.data(),
Builder.FieldOffsets.size());
More information about the cfe-commits
mailing list