[cfe-commits] r76847 - /cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
Anders Carlsson
andersca at mac.com
Wed Jul 22 21:01:13 PDT 2009
Author: andersca
Date: Wed Jul 22 23:00:39 2009
New Revision: 76847
URL: http://llvm.org/viewvc/llvm-project?rev=76847&view=rev
Log:
Handle zero width bit fields in unions correctly (by ignoring them).
Modified:
cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
Modified: cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp?rev=76847&r1=76846&r2=76847&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp Wed Jul 22 23:00:39 2009
@@ -160,6 +160,15 @@
FieldEnd = D->field_end(); Field != FieldEnd; ++Field, ++FieldNo) {
assert(Layout.getFieldOffset(FieldNo) == 0 &&
"Union field offset did not start at the beginning of record!");
+
+ if (Field->isBitField()) {
+ uint64_t FieldSize =
+ Field->getBitWidth()->EvaluateAsInt(Types.getContext()).getZExtValue();
+
+ // Ignore zero sized bit fields.
+ if (FieldSize == 0)
+ continue;
+ }
const llvm::Type *FieldTy =
Types.ConvertTypeForMemRecursive(Field->getType());
More information about the cfe-commits
mailing list