зеркало из https://github.com/microsoft/clang-1.git
Convert RecordLayout::NonVirtualSize from bit units to CharUnits.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124646 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
65e7a9e059
Коммит
5c3633fa57
|
@ -52,7 +52,7 @@ class ASTRecordLayout {
|
|||
struct CXXRecordLayoutInfo {
|
||||
/// NonVirtualSize - The non-virtual size (in bits) of an object, which is
|
||||
/// the size of the object without virtual bases.
|
||||
uint64_t NonVirtualSize;
|
||||
CharUnits NonVirtualSize;
|
||||
|
||||
/// NonVirtualAlign - The non-virtual alignment (in bits) of an object,
|
||||
/// which is the alignment of the object without virtual bases.
|
||||
|
@ -91,7 +91,7 @@ class ASTRecordLayout {
|
|||
ASTRecordLayout(const ASTContext &Ctx,
|
||||
uint64_t size, unsigned alignment, uint64_t datasize,
|
||||
const uint64_t *fieldoffsets, unsigned fieldcount,
|
||||
uint64_t nonvirtualsize, unsigned nonvirtualalign,
|
||||
CharUnits nonvirtualsize, unsigned nonvirtualalign,
|
||||
CharUnits SizeOfLargestEmptySubobject,
|
||||
const CXXRecordDecl *PrimaryBase,
|
||||
bool IsPrimaryBaseVirtual,
|
||||
|
@ -128,9 +128,9 @@ public:
|
|||
return DataSize;
|
||||
}
|
||||
|
||||
/// getNonVirtualSize - Get the non-virtual size (in bits) of an object,
|
||||
/// getNonVirtualSize - Get the non-virtual size (in chars) of an object,
|
||||
/// which is the size of the object without virtual bases.
|
||||
uint64_t getNonVirtualSize() const {
|
||||
CharUnits getNonVirtualSize() const {
|
||||
assert(CXXInfo && "Record layout does not have C++ specific info!");
|
||||
|
||||
return CXXInfo->NonVirtualSize;
|
||||
|
|
|
@ -52,7 +52,9 @@ public:
|
|||
return false;
|
||||
|
||||
const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
|
||||
return Layout.getNonVirtualSize() == Context.Target.getPointerWidth(0);
|
||||
CharUnits PointerSize =
|
||||
Context.toCharUnitsFromBits(Context.Target.getPointerWidth(0));
|
||||
return Layout.getNonVirtualSize() == PointerSize;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -44,8 +44,10 @@ public:
|
|||
const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
|
||||
|
||||
// In the Microsoft ABI, classes can have one or two vtable pointers.
|
||||
return Layout.getNonVirtualSize() == Context.Target.getPointerWidth(0) ||
|
||||
Layout.getNonVirtualSize() == Context.Target.getPointerWidth(0) * 2;
|
||||
CharUnits PointerSize =
|
||||
Context.toCharUnitsFromBits(Context.Target.getPointerWidth(0));
|
||||
return Layout.getNonVirtualSize() == PointerSize ||
|
||||
Layout.getNonVirtualSize() == PointerSize * 2;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ ASTRecordLayout::ASTRecordLayout(const ASTContext &Ctx,
|
|||
uint64_t datasize,
|
||||
const uint64_t *fieldoffsets,
|
||||
unsigned fieldcount,
|
||||
uint64_t nonvirtualsize,
|
||||
CharUnits nonvirtualsize,
|
||||
unsigned nonvirtualalign,
|
||||
CharUnits SizeOfLargestEmptySubobject,
|
||||
const CXXRecordDecl *PrimaryBase,
|
||||
|
|
|
@ -1115,7 +1115,8 @@ CharUnits RecordLayoutBuilder::LayoutBase(const BaseSubobjectInfo *Base) {
|
|||
|
||||
if (!Base->Class->isEmpty()) {
|
||||
// Update the data size.
|
||||
DataSize = Offset + Layout.getNonVirtualSize();
|
||||
DataSize = Offset +
|
||||
(Layout.getNonVirtualSize().getQuantity() * Context.getCharWidth());
|
||||
|
||||
Size = std::max(Size, DataSize);
|
||||
} else
|
||||
|
@ -1665,7 +1666,7 @@ ASTContext::getASTRecordLayout(const RecordDecl *D) const {
|
|||
new (*this) ASTRecordLayout(*this, Builder->Size, Builder->Alignment,
|
||||
DataSize, Builder->FieldOffsets.data(),
|
||||
Builder->FieldOffsets.size(),
|
||||
NonVirtualSize,
|
||||
toCharUnitsFromBits(NonVirtualSize),
|
||||
Builder->NonVirtualAlignment,
|
||||
EmptySubobjects.SizeOfLargestEmptySubobject,
|
||||
Builder->PrimaryBase,
|
||||
|
@ -1834,7 +1835,7 @@ static void DumpCXXRecordLayout(llvm::raw_ostream &OS,
|
|||
OS << " sizeof=" << Layout.getSize() / 8;
|
||||
OS << ", dsize=" << Layout.getDataSize() / 8;
|
||||
OS << ", align=" << Layout.getAlignment() / 8 << '\n';
|
||||
OS << " nvsize=" << Layout.getNonVirtualSize() / 8;
|
||||
OS << " nvsize=" << Layout.getNonVirtualSize().getQuantity();
|
||||
OS << ", nvalign=" << Layout.getNonVirtualAlign() / 8 << '\n';
|
||||
OS << '\n';
|
||||
}
|
||||
|
|
|
@ -500,12 +500,12 @@ void CGRecordLayoutBuilder::LayoutBase(const CXXRecordDecl *BaseDecl,
|
|||
const ASTRecordLayout &Layout =
|
||||
Types.getContext().getASTRecordLayout(BaseDecl);
|
||||
|
||||
uint64_t NonVirtualSize = Layout.getNonVirtualSize();
|
||||
CharUnits NonVirtualSize = Layout.getNonVirtualSize();
|
||||
|
||||
AppendPadding(BaseOffset / 8, 1);
|
||||
|
||||
// FIXME: Actually use a better type than [sizeof(BaseDecl) x i8] when we can.
|
||||
AppendBytes(NonVirtualSize / 8);
|
||||
AppendBytes(NonVirtualSize.getQuantity());
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -520,12 +520,12 @@ CGRecordLayoutBuilder::LayoutVirtualBase(const CXXRecordDecl *BaseDecl,
|
|||
const ASTRecordLayout &Layout =
|
||||
Types.getContext().getASTRecordLayout(BaseDecl);
|
||||
|
||||
uint64_t NonVirtualSize = Layout.getNonVirtualSize();
|
||||
CharUnits NonVirtualSize = Layout.getNonVirtualSize();
|
||||
|
||||
AppendPadding(BaseOffset / 8, 1);
|
||||
|
||||
// FIXME: Actually use a better type than [sizeof(BaseDecl) x i8] when we can.
|
||||
AppendBytes(NonVirtualSize / 8);
|
||||
AppendBytes(NonVirtualSize.getQuantity());
|
||||
|
||||
// FIXME: Add the vbase field info.
|
||||
}
|
||||
|
@ -616,8 +616,9 @@ bool
|
|||
CGRecordLayoutBuilder::ComputeNonVirtualBaseType(const CXXRecordDecl *RD) {
|
||||
const ASTRecordLayout &Layout = Types.getContext().getASTRecordLayout(RD);
|
||||
|
||||
|
||||
uint64_t AlignedNonVirtualTypeSize =
|
||||
llvm::RoundUpToAlignment(Layout.getNonVirtualSize(),
|
||||
llvm::RoundUpToAlignment(Layout.getNonVirtualSize().getQuantity() * 8,
|
||||
Layout.getNonVirtualAlign()) / 8;
|
||||
|
||||
|
||||
|
@ -855,7 +856,7 @@ CGRecordLayout *CodeGenTypes::ComputeRecordLayout(const RecordDecl *D) {
|
|||
|
||||
if (BaseTy) {
|
||||
uint64_t AlignedNonVirtualTypeSizeInBits =
|
||||
llvm::RoundUpToAlignment(Layout.getNonVirtualSize(),
|
||||
llvm::RoundUpToAlignment(Layout.getNonVirtualSize().getQuantity() * 8,
|
||||
Layout.getNonVirtualAlign());
|
||||
|
||||
assert(AlignedNonVirtualTypeSizeInBits ==
|
||||
|
|
Загрузка…
Ссылка в новой задаче