[cfe-commits] r127538 - /cfe/trunk/lib/CodeGen/CGExprConstant.cpp

Ken Dyck kd at kendyck.com
Sat Mar 12 04:03:11 PST 2011


Author: kjdyck
Date: Sat Mar 12 06:03:11 2011
New Revision: 127538

URL: http://llvm.org/viewvc/llvm-project?rev=127538&view=rev
Log:
Use CharUnits for argument passed to AppendPadding() from AppendBitField().
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=127538&r1=127537&r2=127538&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Sat Mar 12 06:03:11 2011
@@ -124,17 +124,18 @@
 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();
 





More information about the cfe-commits mailing list