From: Fariborz Jahanian Date: Fri, 21 Nov 2014 21:12:11 +0000 (+0000) Subject: Objective-C ARC. Fixes a crash when checking for 'weak' propery X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=84f615d8a0defb3b893f5ca930f6f0a98f404078;p=clang Objective-C ARC. Fixes a crash when checking for 'weak' propery whose base is not an expression. rdar://19053620 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222570 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/ScopeInfo.cpp b/lib/Sema/ScopeInfo.cpp index 00d9982ac0..63ef3b2355 100644 --- a/lib/Sema/ScopeInfo.cpp +++ b/lib/Sema/ScopeInfo.cpp @@ -176,6 +176,8 @@ void FunctionScopeInfo::markSafeWeakUse(const Expr *E) { // Has this weak object been seen before? FunctionScopeInfo::WeakObjectUseMap::iterator Uses; if (const ObjCPropertyRefExpr *RefExpr = dyn_cast(E)) { + if (!RefExpr->isObjectReceiver()) + return; if (isa(RefExpr->getBase())) Uses = WeakObjectUses.find(WeakObjectProfileTy(RefExpr)); else { diff --git a/test/SemaObjC/arc-repeated-weak.mm b/test/SemaObjC/arc-repeated-weak.mm index 64df92a9af..264c598942 100644 --- a/test/SemaObjC/arc-repeated-weak.mm +++ b/test/SemaObjC/arc-repeated-weak.mm @@ -425,3 +425,17 @@ void doubleLevelAccessIvar(Test *a, Test *b) { } @end +// rdar://19053620 +@interface NSNull ++ (NSNull *)null; +@end + +@interface INTF @end + +@implementation INTF +- (void) Meth : (id) data +{ + data = data ?: NSNull.null; +} +@end +