Objective-C ARC. Fixes a crash when checking for 'weak' propery
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 21 Nov 2014 21:12:11 +0000 (21:12 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 21 Nov 2014 21:12:11 +0000 (21:12 +0000)
whose base is not an expression. rdar://19053620

llvm-svn: 222570

clang/lib/Sema/ScopeInfo.cpp
clang/test/SemaObjC/arc-repeated-weak.mm

index 00d9982..63ef3b2 100644 (file)
@@ -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<ObjCPropertyRefExpr>(E)) {
+    if (!RefExpr->isObjectReceiver())
+      return;
     if (isa<OpaqueValueExpr>(RefExpr->getBase()))
      Uses = WeakObjectUses.find(WeakObjectProfileTy(RefExpr));
     else {
index 64df92a..264c598 100644 (file)
@@ -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
+