[cfe-commits] r127513 - /cfe/trunk/lib/CodeGen/CGExprConstant.cpp
Ken Dyck
kd at kendyck.com
Fri Mar 11 15:42:54 PST 2011
Author: kjdyck
Date: Fri Mar 11 17:42:54 2011
New Revision: 127513
URL: http://llvm.org/viewvc/llvm-project?rev=127513&view=rev
Log:
Change parameter to AppendPadding from bytes to 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=127513&r1=127512&r2=127513&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Fri Mar 11 17:42:54 2011
@@ -56,7 +56,7 @@
void AppendBitField(const FieldDecl *Field, uint64_t FieldOffset,
llvm::ConstantInt *InitExpr);
- void AppendPadding(uint64_t NumBytes);
+ void AppendPadding(CharUnits PadSize);
void AppendTailPadding(CharUnits RecordSize);
@@ -99,7 +99,8 @@
if (AlignedNextFieldOffsetInBytes < FieldOffsetInBytes) {
// We need to append padding.
- AppendPadding(FieldOffsetInBytes - NextFieldOffsetInBytes);
+ AppendPadding(
+ CharUnits::fromQuantity(FieldOffsetInBytes - NextFieldOffsetInBytes));
assert(NextFieldOffsetInBytes == FieldOffsetInBytes &&
"Did not add enough padding!");
@@ -129,7 +130,7 @@
llvm::RoundUpToAlignment(FieldOffset -
NextFieldOffsetInBytes * 8, 8) / 8;
- AppendPadding(NumBytes);
+ AppendPadding(CharUnits::fromQuantity(NumBytes));
}
uint64_t FieldSize =
@@ -212,8 +213,8 @@
Elements.pop_back();
// Add the padding back in two chunks.
- AppendPadding(AT->getNumElements()-1);
- AppendPadding(1);
+ AppendPadding(CharUnits::fromQuantity(AT->getNumElements()-1));
+ AppendPadding(CharUnits::One());
assert(isa<llvm::UndefValue>(Elements.back()) &&
Elements.back()->getType()->isIntegerTy(8) &&
"Padding addition didn't work right");
@@ -265,13 +266,13 @@
NextFieldOffsetInBytes++;
}
-void ConstStructBuilder::AppendPadding(uint64_t NumBytes) {
- if (!NumBytes)
+void ConstStructBuilder::AppendPadding(CharUnits PadSize) {
+ if (PadSize.isZero())
return;
const llvm::Type *Ty = llvm::Type::getInt8Ty(CGM.getLLVMContext());
- if (NumBytes > 1)
- Ty = llvm::ArrayType::get(Ty, NumBytes);
+ if (PadSize > CharUnits::One())
+ Ty = llvm::ArrayType::get(Ty, PadSize.getQuantity());
llvm::Constant *C = llvm::UndefValue::get(Ty);
Elements.push_back(C);
@@ -284,8 +285,7 @@
assert(NextFieldOffsetInBytes <= RecordSize.getQuantity() &&
"Size mismatch!");
- unsigned NumPadBytes = RecordSize.getQuantity() - NextFieldOffsetInBytes;
- AppendPadding(NumPadBytes);
+ AppendPadding(RecordSize - CharUnits::fromQuantity(NextFieldOffsetInBytes));
}
void ConstStructBuilder::ConvertStructToPacked() {
More information about the cfe-commits
mailing list