]> granicus.if.org Git - clang/commitdiff
Fix rdar://6800926 - crash compiling non-fragile _Bool bitfield ivar,
authorChris Lattner <sabre@nondot.org>
Fri, 17 Apr 2009 17:46:19 +0000 (17:46 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 17 Apr 2009 17:46:19 +0000 (17:46 +0000)
the functional change here is changing ConvertType -> ConvertTypeForMem
so that we handle i1 fields properly as memory.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69361 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGObjCMac.cpp
test/CodeGenObjC/ivars.m [new file with mode: 0644]

index 67fc63c65aa2eedc22b738755c2233e8b444d223..4acc61810368dd8f0f7c59ee3d3e61a3972ef3fd 100644 (file)
@@ -4868,23 +4868,23 @@ LValue CGObjCNonFragileABIMac::EmitObjCValueForIvar(
     ObjCIvarOffsetVariable(ExternalName, ID, Ivar);
   
   // (char *) BaseValue
-  llvm::Value *V =  CGF.Builder.CreateBitCast(BaseValue,
-                                              ObjCTypes.Int8PtrTy);
+  llvm::Value *V = CGF.Builder.CreateBitCast(BaseValue, ObjCTypes.Int8PtrTy);
   llvm::Value *Offset = CGF.Builder.CreateLoad(IvarOffsetGV);
   // (char*)BaseValue + Offset_symbol
   V = CGF.Builder.CreateGEP(V, Offset, "add.ptr");
   // (type *)((char*)BaseValue + Offset_symbol)
   const llvm::Type *IvarTy = 
-    CGM.getTypes().ConvertType(Ivar->getType());
+    CGM.getTypes().ConvertTypeForMem(Ivar->getType());
   llvm::Type *ptrIvarTy = llvm::PointerType::getUnqual(IvarTy);
   V = CGF.Builder.CreateBitCast(V, ptrIvarTy);
   
   if (Ivar->isBitField()) {
+    QualType FieldTy = Field->getType();
     CodeGenTypes::BitFieldInfo bitFieldInfo =
                                  CGM.getTypes().getBitFieldInfo(Field);
     return LValue::MakeBitfield(V, bitFieldInfo.Begin, bitFieldInfo.Size,
-                                Field->getType()->isSignedIntegerType(),
-                                Field->getType().getCVRQualifiers()|CVRQualifiers);
+                                FieldTy->isSignedIntegerType(),
+                                FieldTy.getCVRQualifiers()|CVRQualifiers);
   }
 
   LValue LV = LValue::MakeAddr(V, 
diff --git a/test/CodeGenObjC/ivars.m b/test/CodeGenObjC/ivars.m
new file mode 100644 (file)
index 0000000..327b628
--- /dev/null
@@ -0,0 +1,14 @@
+// RUN: clang-cc -triple x86_64-apple-darwin9 -emit-llvm -o - %s &&
+// RUN: clang-cc -triple i386-apple-darwin9 -emit-llvm -o - %s
+
+// rdar://6800926
+@interface ITF {
+@public
+  unsigned field :1 ;
+  _Bool boolfield :1 ;
+}
+@end
+
+void foo(ITF *P) {
+  P->boolfield = 1;
+}