diff options
author | Douglas Gregor <dgregor@apple.com> | 2013-02-18 15:59:24 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2013-02-18 15:59:24 +0000 |
commit | 3b1a40fedc489e8ad90476d9966ce39e93b86b44 (patch) | |
tree | 7e00aca099c1b6cfc08c9dc6f2e043799c279f61 | |
parent | aa945900d5438984bdcaac85c4f54868292231f4 (diff) |
CodeGenFunction::CurFuncDecl can be NULL; fix crash introduced in r175386.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175448 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/CGObjCMac.cpp | 6 | ||||
-rw-r--r-- | test/CodeGenObjC/ivar-invariant.m | 14 |
2 files changed, 16 insertions, 4 deletions
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index bf02439ec6..b6617a0557 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -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; } diff --git a/test/CodeGenObjC/ivar-invariant.m b/test/CodeGenObjC/ivar-invariant.m index 7552e7a8a3..7cafee7007 100644 --- a/test/CodeGenObjC/ivar-invariant.m +++ b/test/CodeGenObjC/ivar-invariant.m @@ -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; +}; |