]> granicus.if.org Git - clang/commitdiff
Simplify AppendTailPadding() by converting its parameter to CharUnits. No
authorKen Dyck <kd@kendyck.com>
Sun, 24 Apr 2011 16:53:44 +0000 (16:53 +0000)
committerKen Dyck <kd@kendyck.com>
Sun, 24 Apr 2011 16:53:44 +0000 (16:53 +0000)
change in functionality intended.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130108 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGRecordLayoutBuilder.cpp

index 67a2ef3db9e52e386d803839d62e6ca3c63c7018..24caf68d76b71e2e01813d19d4de9e26d46cd7a7 100644 (file)
@@ -168,7 +168,7 @@ private:
 
   /// AppendTailPadding - Append enough tail padding so that the type will have
   /// the passed size.
-  void AppendTailPadding(uint64_t RecordSize);
+  void AppendTailPadding(CharUnits RecordSize);
 
   CharUnits getTypeAlignment(const llvm::Type *Ty) const;
 
@@ -765,29 +765,25 @@ bool CGRecordLayoutBuilder::LayoutFields(const RecordDecl *D) {
   }
   
   // Append tail padding if necessary.
-  AppendTailPadding(Types.getContext().toBits(Layout.getSize()));
+  AppendTailPadding(Layout.getSize());
 
   return true;
 }
 
-void CGRecordLayoutBuilder::AppendTailPadding(uint64_t RecordSize) {
-  assert(RecordSize % 8 == 0 && "Invalid record size!");
+void CGRecordLayoutBuilder::AppendTailPadding(CharUnits RecordSize) {
+  ResizeLastBaseFieldIfNecessary(RecordSize);
 
-  CharUnits RecordSizeInBytes =
-    Types.getContext().toCharUnitsFromBits(RecordSize);
-  ResizeLastBaseFieldIfNecessary(RecordSizeInBytes);
-
-  assert(NextFieldOffset <= RecordSizeInBytes && "Size mismatch!");
+  assert(NextFieldOffset <= RecordSize && "Size mismatch!");
 
   CharUnits AlignedNextFieldOffset =
     NextFieldOffset.RoundUpToAlignment(getAlignmentAsLLVMStruct());
 
-  if (AlignedNextFieldOffset == RecordSizeInBytes) {
+  if (AlignedNextFieldOffset == RecordSize) {
     // We don't need any padding.
     return;
   }
 
-  CharUnits NumPadBytes = RecordSizeInBytes - NextFieldOffset;
+  CharUnits NumPadBytes = RecordSize - NextFieldOffset;
   AppendBytes(NumPadBytes);
 }