diff options
author | Ken Dyck <kd@kendyck.com> | 2011-03-11 02:17:05 +0000 |
---|---|---|
committer | Ken Dyck <kd@kendyck.com> | 2011-03-11 02:17:05 +0000 |
commit | 106ca049e9a5b10ba80df1b60c0708b2491b7e18 (patch) | |
tree | 0af077b8e4bb26ddd9861f8ba6c988e756252f75 /lib/CodeGen/CGExprConstant.cpp | |
parent | 4f3bc8f7aa90b72832b03bee9201c98f4bb6b4d1 (diff) |
Convert the RecordSize parameter of AppendTailPadding() to CharUnits to
avoid converting to bits and back again. No change in functionality
intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127455 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprConstant.cpp')
-rw-r--r-- | lib/CodeGen/CGExprConstant.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index a4e054d06e..99554753c9 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/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!"); |