summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGExprConstant.cpp7
-rw-r--r--clang/lib/CodeGen/CGObjCGNU.cpp5
-rw-r--r--clang/lib/CodeGen/CGObjCMac.cpp5
-rw-r--r--clang/lib/CodeGen/CGRecordLayoutBuilder.cpp15
4 files changed, 19 insertions, 13 deletions
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp
index 4d8a60e1e8f..dc84b367cf0 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -368,7 +368,7 @@ bool ConstStructBuilder::Build(InitListExpr *ILE) {
}
}
- uint64_t LayoutSizeInBytes = Layout.getSize() / 8;
+ uint64_t LayoutSizeInBytes = Layout.getSize().getQuantity();
if (NextFieldOffsetInBytes > LayoutSizeInBytes) {
// If the struct is bigger than the size of the record type,
@@ -394,9 +394,10 @@ bool ConstStructBuilder::Build(InitListExpr *ILE) {
}
// Append tail padding if necessary.
- AppendTailPadding(Layout.getSize());
+ AppendTailPadding(
+ Layout.getSize().getQuantity() * CGM.getContext().getCharWidth());
- assert(Layout.getSize() / 8 == NextFieldOffsetInBytes &&
+ assert(Layout.getSize().getQuantity() == NextFieldOffsetInBytes &&
"Tail padding mismatch!");
return true;
diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp
index 4f65dddfdd9..d481e779267 100644
--- a/clang/lib/CodeGen/CGObjCGNU.cpp
+++ b/clang/lib/CodeGen/CGObjCGNU.cpp
@@ -1437,7 +1437,8 @@ void CGObjCGNU::GenerateClass(const ObjCImplementationDecl *OID) {
}
// Get the size of instances.
- int instanceSize = Context.getASTObjCImplementationLayout(OID).getSize() / 8;
+ int instanceSize =
+ Context.getASTObjCImplementationLayout(OID).getSize().getQuantity();
// Collect information about instance variables.
llvm::SmallVector<llvm::Constant*, 16> IvarNames;
@@ -1447,7 +1448,7 @@ void CGObjCGNU::GenerateClass(const ObjCImplementationDecl *OID) {
std::vector<llvm::Constant*> IvarOffsetValues;
int superInstanceSize = !SuperClassDecl ? 0 :
- Context.getASTObjCInterfaceLayout(SuperClassDecl).getSize() / 8;
+ Context.getASTObjCInterfaceLayout(SuperClassDecl).getSize().getQuantity();
// For non-fragile ivars, set the instance size to 0 - {the size of just this
// class}. The runtime will then set this to the correct value on load.
if (CGM.getContext().getLangOptions().ObjCNonFragileABI) {
diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index be7c79cbb56..3cbb296b0b2 100644
--- a/clang/lib/CodeGen/CGObjCMac.cpp
+++ b/clang/lib/CodeGen/CGObjCMac.cpp
@@ -131,7 +131,8 @@ LValue CGObjCRuntime::EmitValueForIvarAtOffset(CodeGen::CodeGenFunction &CGF,
// a synthesized ivar can never be a bit-field, so this is safe.
const ASTRecordLayout &RL =
CGF.CGM.getContext().getASTObjCInterfaceLayout(OID);
- uint64_t TypeSizeInBits = RL.getSize();
+ uint64_t TypeSizeInBits =
+ RL.getSize().getQuantity() * CGF.CGM.getContext().getCharWidth();
uint64_t FieldBitOffset = LookupFieldBitOffset(CGF.CGM, OID, 0, Ivar);
uint64_t BitOffset = FieldBitOffset % 8;
uint64_t ContainingTypeAlign = 8;
@@ -2214,7 +2215,7 @@ void CGObjCMac::GenerateClass(const ObjCImplementationDecl *ID) {
if (ID->getNumIvarInitializers())
Flags |= eClassFlags_HasCXXStructors;
unsigned Size =
- CGM.getContext().getASTObjCImplementationLayout(ID).getSize() / 8;
+ CGM.getContext().getASTObjCImplementationLayout(ID).getSize().getQuantity();
// FIXME: Set CXX-structors flag.
if (ID->getClassInterface()->getVisibility() == HiddenVisibility)
diff --git a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
index e158eed9878..e16173b6dca 100644
--- a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
+++ b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
@@ -300,7 +300,8 @@ CGBitFieldInfo CGBitFieldInfo::MakeInfo(CodeGenTypes &Types,
uint64_t FieldSize) {
const RecordDecl *RD = FD->getParent();
const ASTRecordLayout &RL = Types.getContext().getASTRecordLayout(RD);
- uint64_t ContainingTypeSizeInBits = RL.getSize();
+ uint64_t ContainingTypeSizeInBits =
+ RL.getSize().getQuantity() * Types.getContext().getCharWidth();
unsigned ContainingTypeAlign = RL.getAlignment();
return MakeInfo(Types, FD, FieldOffset, FieldSize, ContainingTypeSizeInBits,
@@ -489,8 +490,8 @@ void CGRecordLayoutBuilder::LayoutUnion(const RecordDecl *D) {
}
// Append tail padding.
- if (Layout.getSize() / 8 > Size)
- AppendPadding(Layout.getSize() / 8, Align);
+ if (Layout.getSize().getQuantity() > Size)
+ AppendPadding(Layout.getSize().getQuantity(), Align);
}
void CGRecordLayoutBuilder::LayoutBase(const CXXRecordDecl *BaseDecl,
@@ -624,7 +625,7 @@ CGRecordLayoutBuilder::ComputeNonVirtualBaseType(const CXXRecordDecl *RD) {
// First check if we can use the same fields as for the complete class.
- if (AlignedNonVirtualTypeSize == Layout.getSize() / 8) {
+ if (AlignedNonVirtualTypeSize == Layout.getSize().getQuantity()) {
NonVirtualBaseTypeIsSameAsCompleteType = true;
return true;
}
@@ -686,7 +687,8 @@ bool CGRecordLayoutBuilder::LayoutFields(const RecordDecl *D) {
}
// Append tail padding if necessary.
- AppendTailPadding(Layout.getSize());
+ AppendTailPadding(
+ Layout.getSize().getQuantity() * Types.getContext().getCharWidth());
return true;
}
@@ -851,7 +853,8 @@ CGRecordLayout *CodeGenTypes::ComputeRecordLayout(const RecordDecl *D) {
// Verify that the computed LLVM struct size matches the AST layout size.
const ASTRecordLayout &Layout = getContext().getASTRecordLayout(D);
- uint64_t TypeSizeInBits = Layout.getSize();
+ uint64_t TypeSizeInBits =
+ Layout.getSize().getQuantity() * getContext().getCharWidth();
assert(TypeSizeInBits == getTargetData().getTypeAllocSizeInBits(Ty) &&
"Type size mismatch!");
OpenPOWER on IntegriCloud