[cfe-commits] r117610 - in /cfe/trunk: lib/CodeGen/CGBlocks.cpp test/CodeGen/blocks.c

John McCall rjmccall at apple.com
Thu Oct 28 14:37:57 PDT 2010


Author: rjmccall
Date: Thu Oct 28 16:37:57 2010
New Revision: 117610

URL: http://llvm.org/viewvc/llvm-project?rev=117610&view=rev
Log:
When emitting l-values for bool non-__block decl references, make a pointer
using the memory type;  fixes an assert.

Fixes rdar://problem/8605032


Modified:
    cfe/trunk/lib/CodeGen/CGBlocks.cpp
    cfe/trunk/test/CodeGen/blocks.c

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=117610&r1=117609&r2=117610&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Thu Oct 28 16:37:57 2010
@@ -611,7 +611,7 @@
     if (VD->getType()->isReferenceType())
       V = Builder.CreateLoad(V);
   } else {
-    const llvm::Type *Ty = CGM.getTypes().ConvertType(VD->getType());
+    const llvm::Type *Ty = CGM.getTypes().ConvertTypeForMem(VD->getType());
     Ty = llvm::PointerType::get(Ty, 0);
     V = Builder.CreateBitCast(V, Ty);
     if (VD->getType()->isReferenceType())

Modified: cfe/trunk/test/CodeGen/blocks.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/blocks.c?rev=117610&r1=117609&r2=117610&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/blocks.c (original)
+++ cfe/trunk/test/CodeGen/blocks.c Thu Oct 28 16:37:57 2010
@@ -33,3 +33,10 @@
 ftype ^test2 = ^ftype {
   return 0;
 };
+
+// rdar://problem/8605032
+void f3_helper(void (^)(void));
+void f3() {
+  _Bool b = 0;
+  f3_helper(^{ if (b) {} });
+}





More information about the cfe-commits mailing list