[cfe-commits] r69572 - in /cfe/trunk: lib/CodeGen/CGObjCMac.cpp test/CodeGenObjC/bitfield-ivar-offsets.m
Daniel Dunbar
daniel at zuster.org
Sun Apr 19 22:53:41 PDT 2009
Author: ddunbar
Date: Mon Apr 20 00:53:40 2009
New Revision: 69572
URL: http://llvm.org/viewvc/llvm-project?rev=69572&view=rev
Log:
Don't emit ivar offsets for unnamed bit fields.
Also, added assertion that the field matches what would be looked up.
Modified:
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/test/CodeGenObjC/bitfield-ivar-offsets.m
Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=69572&r1=69571&r2=69572&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Mon Apr 20 00:53:40 2009
@@ -4600,13 +4600,16 @@
unsigned iv = 0;
for (RecordDecl::field_iterator e = RD->field_end(CGM.getContext());
i != e; ++i) {
+ ObjCIvarDecl *IVD = OIvars[iv++];
+ // Don't emit entries for unnamed bit fields.
+ if (!IVD->getDeclName())
+ continue;
+
FieldDecl *Field = *i;
- Ivar[0] = EmitIvarOffsetVar(ID->getClassInterface(), OIvars[iv++],
+ assert(Field == OID->lookupFieldDeclForIvar(CGM.getContext(), IVD));
+ Ivar[0] = EmitIvarOffsetVar(ID->getClassInterface(), IVD,
GetIvarBaseOffset(Layout, Field));
- if (Field->getIdentifier())
- Ivar[1] = GetMethodVarName(Field->getIdentifier());
- else
- Ivar[1] = llvm::Constant::getNullValue(ObjCTypes.Int8PtrTy);
+ Ivar[1] = GetMethodVarName(Field->getIdentifier());
Ivar[2] = GetMethodVarType(Field);
const llvm::Type *FieldTy =
CGM.getTypes().ConvertTypeForMem(Field->getType());
Modified: cfe/trunk/test/CodeGenObjC/bitfield-ivar-offsets.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/bitfield-ivar-offsets.m?rev=69572&r1=69571&r2=69572&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/bitfield-ivar-offsets.m (original)
+++ cfe/trunk/test/CodeGenObjC/bitfield-ivar-offsets.m Mon Apr 20 00:53:40 2009
@@ -1,3 +1,4 @@
+// RUNX: llvm-gcc -m64 -emit-llvm -S -o %t %s &&
// RUN: clang-cc -triple x86_64-apple-darwin10 -emit-llvm -o %t %s &&
// RUN: grep -F '@"OBJC_IVAR_$_I0._b0" = global i64 0, section "__DATA, __objc_const", align 8' %t &&
// RUN: grep -F '@"OBJC_IVAR_$_I0._b1" = global i64 0, section "__DATA, __objc_const", align 8' %t &&
@@ -6,6 +7,7 @@
// RUN: grep -F '@"OBJC_IVAR_$_I0._b3" = global i64 4, section "__DATA, __objc_const", align 8' %t &&
// RUN: grep -F '@"OBJC_IVAR_$_I0._y" = global i64 6, section "__DATA, __objc_const", align 8' %t &&
// RUN: grep -F '@"OBJC_IVAR_$_I0._b4" = global i64 7, section "__DATA, __objc_const", align 8' %t &&
+// RUN: grep -F '@"OBJC_IVAR_$_I0." = global' %t | count 0 &&
// RUN: true
@interface I0 {
@@ -16,6 +18,7 @@
unsigned _b3:9;
char _y;
char _b4:3;
+ char : 0;
}
@end
More information about the cfe-commits
mailing list