[cfe-commits] r125069 - in /cfe/trunk: include/clang/AST/RecordLayout.h lib/AST/RecordLayout.cpp lib/AST/RecordLayoutBuilder.cpp lib/CodeGen/CGRecordLayoutBuilder.cpp
Ken Dyck
kd at kendyck.com
Mon Feb 7 18:02:47 PST 2011
Author: kjdyck
Date: Mon Feb 7 20:02:47 2011
New Revision: 125069
URL: http://llvm.org/viewvc/llvm-project?rev=125069&view=rev
Log:
Convert RecordLayout::NonVirtualAlign to CharUnits. No change in
functionality intended.
Modified:
cfe/trunk/include/clang/AST/RecordLayout.h
cfe/trunk/lib/AST/RecordLayout.cpp
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
Modified: cfe/trunk/include/clang/AST/RecordLayout.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecordLayout.h?rev=125069&r1=125068&r2=125069&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/RecordLayout.h (original)
+++ cfe/trunk/include/clang/AST/RecordLayout.h Mon Feb 7 20:02:47 2011
@@ -54,9 +54,9 @@
/// the size of the object without virtual bases.
CharUnits NonVirtualSize;
- /// NonVirtualAlign - The non-virtual alignment (in bits) of an object,
+ /// NonVirtualAlign - The non-virtual alignment (in chars) of an object,
/// which is the alignment of the object without virtual bases.
- uint64_t NonVirtualAlign;
+ CharUnits NonVirtualAlign;
/// SizeOfLargestEmptySubobject - The size of the largest empty subobject
/// (either a base or a member). Will be zero if the class doesn't contain
@@ -91,7 +91,7 @@
ASTRecordLayout(const ASTContext &Ctx,
uint64_t size, unsigned alignment, uint64_t datasize,
const uint64_t *fieldoffsets, unsigned fieldcount,
- CharUnits nonvirtualsize, unsigned nonvirtualalign,
+ CharUnits nonvirtualsize, CharUnits nonvirtualalign,
CharUnits SizeOfLargestEmptySubobject,
const CXXRecordDecl *PrimaryBase,
bool IsPrimaryBaseVirtual,
@@ -136,9 +136,9 @@
return CXXInfo->NonVirtualSize;
}
- /// getNonVirtualSize - Get the non-virtual alignment (in bits) of an object,
+ /// getNonVirtualSize - Get the non-virtual alignment (in chars) of an object,
/// which is the alignment of the object without virtual bases.
- unsigned getNonVirtualAlign() const {
+ CharUnits getNonVirtualAlign() const {
assert(CXXInfo && "Record layout does not have C++ specific info!");
return CXXInfo->NonVirtualAlign;
Modified: cfe/trunk/lib/AST/RecordLayout.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayout.cpp?rev=125069&r1=125068&r2=125069&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayout.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayout.cpp Mon Feb 7 20:02:47 2011
@@ -46,7 +46,7 @@
const uint64_t *fieldoffsets,
unsigned fieldcount,
CharUnits nonvirtualsize,
- unsigned nonvirtualalign,
+ CharUnits nonvirtualalign,
CharUnits SizeOfLargestEmptySubobject,
const CXXRecordDecl *PrimaryBase,
bool IsPrimaryBaseVirtual,
Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=125069&r1=125068&r2=125069&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Mon Feb 7 20:02:47 2011
@@ -1096,7 +1096,8 @@
return CharUnits::Zero();
}
- unsigned UnpackedBaseAlign = Layout.getNonVirtualAlign();
+ unsigned UnpackedBaseAlign =
+ Layout.getNonVirtualAlign().getQuantity() * Context.getCharWidth();
unsigned BaseAlign = (Packed) ? 8 : UnpackedBaseAlign;
// The maximum field alignment overrides base align.
@@ -1684,13 +1685,14 @@
IsPODForThePurposeOfLayout ? Builder->Size : Builder->DataSize;
uint64_t NonVirtualSize =
IsPODForThePurposeOfLayout ? DataSize : Builder->NonVirtualSize;
+ uint64_t NonVirtualAlign = Builder->NonVirtualAlignment;
NewEntry =
new (*this) ASTRecordLayout(*this, Builder->Size, Builder->Alignment,
DataSize, Builder->FieldOffsets.data(),
Builder->FieldOffsets.size(),
toCharUnitsFromBits(NonVirtualSize),
- Builder->NonVirtualAlignment,
+ toCharUnitsFromBits(NonVirtualAlign),
EmptySubobjects.SizeOfLargestEmptySubobject,
Builder->PrimaryBase,
Builder->PrimaryBaseIsVirtual,
@@ -1859,7 +1861,7 @@
OS << ", dsize=" << Layout.getDataSize() / 8;
OS << ", align=" << Layout.getAlignment() / 8 << '\n';
OS << " nvsize=" << Layout.getNonVirtualSize().getQuantity();
- OS << ", nvalign=" << Layout.getNonVirtualAlign() / 8 << '\n';
+ OS << ", nvalign=" << Layout.getNonVirtualAlign().getQuantity() << '\n';
OS << '\n';
}
Modified: cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp?rev=125069&r1=125068&r2=125069&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp Mon Feb 7 20:02:47 2011
@@ -617,9 +617,10 @@
const ASTRecordLayout &Layout = Types.getContext().getASTRecordLayout(RD);
+ CharUnits NonVirtualSize = Layout.getNonVirtualSize();
+ CharUnits NonVirtualAlign = Layout.getNonVirtualAlign();
uint64_t AlignedNonVirtualTypeSize =
- llvm::RoundUpToAlignment(Layout.getNonVirtualSize().getQuantity() * 8,
- Layout.getNonVirtualAlign()) / 8;
+ NonVirtualSize.RoundUpToAlignment(NonVirtualAlign).getQuantity();
// First check if we can use the same fields as for the complete class.
@@ -855,9 +856,13 @@
"Type size mismatch!");
if (BaseTy) {
- uint64_t AlignedNonVirtualTypeSizeInBits =
- llvm::RoundUpToAlignment(Layout.getNonVirtualSize().getQuantity() * 8,
- Layout.getNonVirtualAlign());
+ CharUnits NonVirtualSize = Layout.getNonVirtualSize();
+ CharUnits NonVirtualAlign = Layout.getNonVirtualAlign();
+ CharUnits AlignedNonVirtualTypeSize =
+ NonVirtualSize.RoundUpToAlignment(NonVirtualAlign);
+
+ uint64_t AlignedNonVirtualTypeSizeInBits =
+ AlignedNonVirtualTypeSize.getQuantity() * getContext().getCharWidth();
assert(AlignedNonVirtualTypeSizeInBits ==
getTargetData().getTypeAllocSizeInBits(BaseTy) &&
More information about the cfe-commits
mailing list