When emitting l-values for bool non-__block decl references, make a pointer
using the memory type;  fixes an assert.

Fixes rdar://problem/8605032



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117610 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp
index ca78781..44e0833 100644
--- a/lib/CodeGen/CGBlocks.cpp
+++ b/lib/CodeGen/CGBlocks.cpp
@@ -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())
diff --git a/test/CodeGen/blocks.c b/test/CodeGen/blocks.c
index 6888356..b7b6a2d 100644
--- a/test/CodeGen/blocks.c
+++ b/test/CodeGen/blocks.c
@@ -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) {} });
+}