Use CharUnits for argument passed to AppendPadding() from AppendBitField().

No change in functionality intended.

llvm-svn: 127538
This commit is contained in:
Ken Dyck 2011-03-12 12:03:11 +00:00
parent fa453cfdc3
commit a862d95054
1 changed files with 6 additions and 5 deletions

View File

@ -124,17 +124,18 @@ AppendField(const FieldDecl *Field, uint64_t FieldOffset,
void ConstStructBuilder::AppendBitField(const FieldDecl *Field,
uint64_t FieldOffset,
llvm::ConstantInt *CI) {
const ASTContext &Context = CGM.getContext();
if (FieldOffset > NextFieldOffsetInBytes * 8) {
// We need to add padding.
uint64_t NumBytes =
llvm::RoundUpToAlignment(FieldOffset -
NextFieldOffsetInBytes * 8, 8) / 8;
CharUnits PadSize = Context.toCharUnitsFromBits(
llvm::RoundUpToAlignment(FieldOffset - NextFieldOffsetInBytes * 8,
Context.Target.getCharAlign()));
AppendPadding(CharUnits::fromQuantity(NumBytes));
AppendPadding(PadSize);
}
uint64_t FieldSize =
Field->getBitWidth()->EvaluateAsInt(CGM.getContext()).getZExtValue();
Field->getBitWidth()->EvaluateAsInt(Context).getZExtValue();
llvm::APInt FieldValue = CI->getValue();