aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGExprConstant.cpp
diff options
context:
space:
mode:
authorKen Dyck <kd@kendyck.com>2011-03-18 01:12:13 +0000
committerKen Dyck <kd@kendyck.com>2011-03-18 01:12:13 +0000
commit15c152e4f042eb073ac05e87d588dd8fe3aa9e9e (patch)
treec742441d012df9b3bc0078c199a0c835003f9221 /lib/CodeGen/CGExprConstant.cpp
parent4a5c87ec3b92026523a6459f5b4547c4a9b5ab24 (diff)
Convert getSizeInBytes() to getSizeInChars(), which returns its result in
CharUnits. No change in functionality intended. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127846 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprConstant.cpp')
-rw-r--r--lib/CodeGen/CGExprConstant.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp
index 59480a0323..a9ef0c876f 100644
--- a/lib/CodeGen/CGExprConstant.cpp
+++ b/lib/CodeGen/CGExprConstant.cpp
@@ -70,8 +70,9 @@ private:
return CGM.getTargetData().getABITypeAlignment(C->getType());
}
- uint64_t getSizeInBytes(const llvm::Constant *C) const {
- return CGM.getTargetData().getTypeAllocSize(C->getType());
+ CharUnits getSizeInChars(const llvm::Constant *C) const {
+ return CharUnits::fromQuantity(
+ CGM.getTargetData().getTypeAllocSize(C->getType()));
}
};
@@ -116,7 +117,7 @@ AppendField(const FieldDecl *Field, uint64_t FieldOffset,
// Add the field.
Elements.push_back(InitCst);
NextFieldOffsetInChars = AlignedNextFieldOffsetInChars +
- CharUnits::fromQuantity(getSizeInBytes(InitCst));
+ getSizeInChars(InitCst);
if (Packed)
assert(LLVMStructAlignment == 1 && "Packed struct not byte-aligned!");
@@ -285,7 +286,7 @@ void ConstStructBuilder::AppendPadding(CharUnits PadSize) {
Elements.push_back(C);
assert(getAlignment(C) == 1 && "Padding must have 1 byte alignment!");
- NextFieldOffsetInChars += CharUnits::fromQuantity(getSizeInBytes(C));
+ NextFieldOffsetInChars += getSizeInChars(C);
}
void ConstStructBuilder::AppendTailPadding(CharUnits RecordSize) {
@@ -319,11 +320,11 @@ void ConstStructBuilder::ConvertStructToPacked() {
llvm::Constant *Padding = llvm::UndefValue::get(Ty);
PackedElements.push_back(Padding);
- ElementOffsetInChars += CharUnits::fromQuantity(getSizeInBytes(Padding));
+ ElementOffsetInChars += getSizeInChars(Padding);
}
PackedElements.push_back(C);
- ElementOffsetInChars += CharUnits::fromQuantity(getSizeInBytes(C));
+ ElementOffsetInChars += getSizeInChars(C);
}
assert(ElementOffsetInChars == NextFieldOffsetInChars &&
@@ -420,9 +421,9 @@ llvm::Constant *ConstStructBuilder::
llvm::ConstantStruct::get(CGM.getLLVMContext(),
Builder.Elements, Builder.Packed);
- assert(llvm::RoundUpToAlignment(Builder.NextFieldOffsetInChars.getQuantity(),
- Builder.getAlignment(Result)) ==
- Builder.getSizeInBytes(Result) && "Size mismatch!");
+ assert(Builder.NextFieldOffsetInChars.RoundUpToAlignment(
+ CharUnits::fromQuantity(Builder.getAlignment(Result))) ==
+ Builder.getSizeInChars(Result) && "Size mismatch!");
return Result;
}