[cfe-commits] r127846 - /cfe/trunk/lib/CodeGen/CGExprConstant.cpp
Ken Dyck
kd at kendyck.com
Thu Mar 17 18:12:13 PDT 2011
Author: kjdyck
Date: Thu Mar 17 20:12:13 2011
New Revision: 127846
URL: http://llvm.org/viewvc/llvm-project?rev=127846&view=rev
Log:
Convert getSizeInBytes() to getSizeInChars(), which returns its result in
CharUnits. No change in functionality intended.
Modified:
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=127846&r1=127845&r2=127846&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Thu Mar 17 20:12:13 2011
@@ -70,8 +70,9 @@
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 @@
// 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 @@
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 @@
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::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;
}
More information about the cfe-commits
mailing list