[cfe-commits] r127455 - /cfe/trunk/lib/CodeGen/CGExprConstant.cpp
Ken Dyck
kd at kendyck.com
Thu Mar 10 18:17:05 PST 2011
Author: kjdyck
Date: Thu Mar 10 20:17:05 2011
New Revision: 127455
URL: http://llvm.org/viewvc/llvm-project?rev=127455&view=rev
Log:
Convert the RecordSize parameter of AppendTailPadding() to CharUnits to
avoid converting to bits and back again. 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=127455&r1=127454&r2=127455&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Thu Mar 10 20:17:05 2011
@@ -58,7 +58,7 @@
void AppendPadding(uint64_t NumBytes);
- void AppendTailPadding(uint64_t RecordSize);
+ void AppendTailPadding(CharUnits RecordSize);
void ConvertStructToPacked();
@@ -280,13 +280,11 @@
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 @@
}
// Append tail padding if necessary.
- AppendTailPadding(CGM.getContext().toBits(Layout.getSize()));
+ AppendTailPadding(Layout.getSize());
assert(Layout.getSize().getQuantity() == NextFieldOffsetInBytes &&
"Tail padding mismatch!");
More information about the cfe-commits
mailing list