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
diff --git a/include/clang/AST/RecordLayout.h b/include/clang/AST/RecordLayout.h
index 4440ec8..940979f 100644
--- a/include/clang/AST/RecordLayout.h
+++ b/include/clang/AST/RecordLayout.h
@@ -52,7 +52,7 @@
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 @@
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 @@
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;
diff --git a/lib/AST/ItaniumCXXABI.cpp b/lib/AST/ItaniumCXXABI.cpp
index ca1fffa..bed02b4 100644
--- a/lib/AST/ItaniumCXXABI.cpp
+++ b/lib/AST/ItaniumCXXABI.cpp
@@ -52,7 +52,9 @@
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;
}
};
diff --git a/lib/AST/MicrosoftCXXABI.cpp b/lib/AST/MicrosoftCXXABI.cpp
index c4259f4..4de93bb 100644
--- a/lib/AST/MicrosoftCXXABI.cpp
+++ b/lib/AST/MicrosoftCXXABI.cpp
@@ -44,8 +44,10 @@
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;
}
};
}
diff --git a/lib/AST/RecordLayout.cpp b/lib/AST/RecordLayout.cpp
index e027c1a..cdecff6 100644
--- a/lib/AST/RecordLayout.cpp
+++ b/lib/AST/RecordLayout.cpp
@@ -45,7 +45,7 @@
uint64_t datasize,
const uint64_t *fieldoffsets,
unsigned fieldcount,
- uint64_t nonvirtualsize,
+ CharUnits nonvirtualsize,
unsigned nonvirtualalign,
CharUnits SizeOfLargestEmptySubobject,
const CXXRecordDecl *PrimaryBase,
diff --git a/lib/AST/RecordLayoutBuilder.cpp b/lib/AST/RecordLayoutBuilder.cpp
index 8c62ffd..7e15dcc 100644
--- a/lib/AST/RecordLayoutBuilder.cpp
+++ b/lib/AST/RecordLayoutBuilder.cpp
@@ -1115,7 +1115,8 @@
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 @@
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 @@
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';
}
diff --git a/lib/CodeGen/CGRecordLayoutBuilder.cpp b/lib/CodeGen/CGRecordLayoutBuilder.cpp
index 5571e43..b9b8c9d 100644
--- a/lib/CodeGen/CGRecordLayoutBuilder.cpp
+++ b/lib/CodeGen/CGRecordLayoutBuilder.cpp
@@ -500,12 +500,12 @@
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 @@
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 @@
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 @@
if (BaseTy) {
uint64_t AlignedNonVirtualTypeSizeInBits =
- llvm::RoundUpToAlignment(Layout.getNonVirtualSize(),
+ llvm::RoundUpToAlignment(Layout.getNonVirtualSize().getQuantity() * 8,
Layout.getNonVirtualAlign());
assert(AlignedNonVirtualTypeSizeInBits ==