diff options
-rw-r--r-- | lib/CodeGen/CGObjCMac.cpp | 13 | ||||
-rw-r--r-- | test/CodeGenObjC/bitfield-ivar-offsets.m | 3 |
2 files changed, 11 insertions, 5 deletions
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index e92796b5ba..665e927142 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -4600,13 +4600,16 @@ llvm::Constant *CGObjCNonFragileABIMac::EmitIvarList( 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()); diff --git a/test/CodeGenObjC/bitfield-ivar-offsets.m b/test/CodeGenObjC/bitfield-ivar-offsets.m index 0078a8c76a..23a09a3a15 100644 --- a/test/CodeGenObjC/bitfield-ivar-offsets.m +++ b/test/CodeGenObjC/bitfield-ivar-offsets.m @@ -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 |