CodeGenFunction::CurFuncDecl can be NULL; fix crash introduced in r175386.
authorDouglas Gregor <dgregor@apple.com>
Mon, 18 Feb 2013 15:59:24 +0000 (15:59 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 18 Feb 2013 15:59:24 +0000 (15:59 +0000)
llvm-svn: 175448

clang/lib/CodeGen/CGObjCMac.cpp
clang/test/CodeGenObjC/ivar-invariant.m

index bf02439..b6617a0 100644 (file)
@@ -1445,9 +1445,9 @@ private:
     // base of the ivar access is a parameter to an Objective C method.
     // However, because the parameters are not available in the current
     // interface, we cannot perform this check.
-      if (dyn_cast<ObjCMethodDecl>(CGF.CurFuncDecl))
-        if (IV->getContainingInterface()->isSuperClassOf(ID))
-          return true;
+    if (CGF.CurFuncDecl && isa<ObjCMethodDecl>(CGF.CurFuncDecl))
+      if (IV->getContainingInterface()->isSuperClassOf(ID))
+        return true;
     return false;
   }
 
index 7552e7a..7cafee7 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fblocks -emit-llvm -o - %s | FileCheck %s
 
 @interface NSObject
 + (id) new;
@@ -54,3 +54,15 @@ void * variant_load_1(int i) {
 // CHECK: define internal i8* @"\01-[Container invariant_load_1]"
 // CHECK: [[IVAR:%.*]] = load i64* @"OBJC_IVAR_$_Derived.member", !invariant.load
 
+@interface ForBlock
+{ 
+@public
+  id foo; 
+}
+@end
+
+// CHECK: define internal i8* @block_block_invoke
+// CHECK: load i64* @"OBJC_IVAR_$_ForBlock.foo"
+id (^block)(ForBlock*) = ^(ForBlock* a) {
+  return a->foo;
+};