r175448 - CodeGenFunction::CurFuncDecl can be NULL; fix crash introduced in r175386.

Douglas Gregor dgregor at apple.com
Mon Feb 18 07:59:24 PST 2013


Author: dgregor
Date: Mon Feb 18 09:59:24 2013
New Revision: 175448

URL: http://llvm.org/viewvc/llvm-project?rev=175448&view=rev
Log:
CodeGenFunction::CurFuncDecl can be NULL; fix crash introduced in r175386.

Modified:
    cfe/trunk/lib/CodeGen/CGObjCMac.cpp
    cfe/trunk/test/CodeGenObjC/ivar-invariant.m

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=175448&r1=175447&r2=175448&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Mon Feb 18 09:59:24 2013
@@ -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;
   }
 

Modified: cfe/trunk/test/CodeGenObjC/ivar-invariant.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/ivar-invariant.m?rev=175448&r1=175447&r2=175448&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/ivar-invariant.m (original)
+++ cfe/trunk/test/CodeGenObjC/ivar-invariant.m Mon Feb 18 09:59:24 2013
@@ -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
 
+ at interface ForBlock
+{ 
+ at public
+  id foo; 
+}
+ at end
+
+// CHECK: define internal i8* @block_block_invoke
+// CHECK: load i64* @"OBJC_IVAR_$_ForBlock.foo"
+id (^block)(ForBlock*) = ^(ForBlock* a) {
+  return a->foo;
+};





More information about the cfe-commits mailing list