From 327b77a4421d66541dec5f11629962f78af6ec06 Mon Sep 17 00:00:00 2001 From: Ken Dyck Date: Fri, 11 Mar 2011 02:17:05 +0000 Subject: [PATCH] Convert the RecordSize parameter of AppendTailPadding() to CharUnits to avoid converting to bits and back again. No change in functionality intended. llvm-svn: 127455 --- clang/lib/CodeGen/CGExprConstant.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp index a4e054d06e4c..99554753c98a 100644 --- a/clang/lib/CodeGen/CGExprConstant.cpp +++ b/clang/lib/CodeGen/CGExprConstant.cpp @@ -58,7 +58,7 @@ private: void AppendPadding(uint64_t NumBytes); - void AppendTailPadding(uint64_t RecordSize); + void AppendTailPadding(CharUnits RecordSize); void ConvertStructToPacked(); @@ -280,13 +280,11 @@ void ConstStructBuilder::AppendPadding(uint64_t NumBytes) { NextFieldOffsetInBytes += getSizeInBytes(C); } -void ConstStructBuilder::AppendTailPadding(uint64_t RecordSize) { - assert(RecordSize % 8 == 0 && "Invalid record size!"); +void ConstStructBuilder::AppendTailPadding(CharUnits RecordSize) { + assert(NextFieldOffsetInBytes <= RecordSize.getQuantity() && + "Size mismatch!"); - uint64_t RecordSizeInBytes = RecordSize / 8; - assert(NextFieldOffsetInBytes <= RecordSizeInBytes && "Size mismatch!"); - - unsigned NumPadBytes = RecordSizeInBytes - NextFieldOffsetInBytes; + unsigned NumPadBytes = RecordSize.getQuantity() - NextFieldOffsetInBytes; AppendPadding(NumPadBytes); } @@ -394,7 +392,7 @@ bool ConstStructBuilder::Build(InitListExpr *ILE) { } // Append tail padding if necessary. - AppendTailPadding(CGM.getContext().toBits(Layout.getSize())); + AppendTailPadding(Layout.getSize()); assert(Layout.getSize().getQuantity() == NextFieldOffsetInBytes && "Tail padding mismatch!");