[cfe-commits] r69361 - in /cfe/trunk: lib/CodeGen/CGObjCMac.cpp test/CodeGenObjC/ivars.m

Chris Lattner sabre at nondot.org
Fri Apr 17 10:46:19 PDT 2009


Author: lattner
Date: Fri Apr 17 12:46:19 2009
New Revision: 69361

URL: http://llvm.org/viewvc/llvm-project?rev=69361&view=rev
Log:
Fix rdar://6800926 - crash compiling non-fragile _Bool bitfield ivar,
the functional change here is changing ConvertType -> ConvertTypeForMem
so that we handle i1 fields properly as memory.


Added:
    cfe/trunk/test/CodeGenObjC/ivars.m
Modified:
    cfe/trunk/lib/CodeGen/CGObjCMac.cpp

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=69361&r1=69360&r2=69361&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Fri Apr 17 12:46:19 2009
@@ -4868,23 +4868,23 @@
     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, 

Added: cfe/trunk/test/CodeGenObjC/ivars.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/ivars.m?rev=69361&view=auto

==============================================================================
--- cfe/trunk/test/CodeGenObjC/ivars.m (added)
+++ cfe/trunk/test/CodeGenObjC/ivars.m Fri Apr 17 12:46:19 2009
@@ -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
+ at interface ITF {
+ at public
+  unsigned field :1 ;
+  _Bool boolfield :1 ;
+}
+ at end
+
+void foo(ITF *P) {
+  P->boolfield = 1;
+}





More information about the cfe-commits mailing list