[PATCH] D18268: [Objective-c] Fix a crash in WeakObjectProfileTy::getBaseInfo

Akira Hatanaka via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 18 12:09:13 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL263818: [Objective-c] Fix a crash in WeakObjectProfileTy::getBaseInfo. (authored by ahatanak).

Changed prior to commit:
  http://reviews.llvm.org/D18268?vs=51025&id=51056#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18268

Files:
  cfe/trunk/lib/Sema/ScopeInfo.cpp
  cfe/trunk/test/SemaObjC/arc-repeated-weak.mm

Index: cfe/trunk/test/SemaObjC/arc-repeated-weak.mm
===================================================================
--- cfe/trunk/test/SemaObjC/arc-repeated-weak.mm
+++ cfe/trunk/test/SemaObjC/arc-repeated-weak.mm
@@ -439,3 +439,15 @@
 }
 @end
 
+// This used to crash in WeakObjectProfileTy::getBaseInfo when getBase() was
+// called on an ObjCPropertyRefExpr object whose receiver was an interface.
+
+ at class NSString;
+ at interface NSBundle
++(NSBundle *)foo;
+ at property NSString *prop;
+ at end
+
+void foo() {
+  NSString * t = NSBundle.foo.prop;
+}
Index: cfe/trunk/lib/Sema/ScopeInfo.cpp
===================================================================
--- cfe/trunk/lib/Sema/ScopeInfo.cpp
+++ cfe/trunk/lib/Sema/ScopeInfo.cpp
@@ -86,11 +86,15 @@
     if (BaseProp) {
       D = getBestPropertyDecl(BaseProp);
 
-      const Expr *DoubleBase = BaseProp->getBase();
-      if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(DoubleBase))
-        DoubleBase = OVE->getSourceExpr();
+      if (BaseProp->isClassReceiver())
+        IsExact = true;
+      else {
+        const Expr *DoubleBase = BaseProp->getBase();
+        if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(DoubleBase))
+          DoubleBase = OVE->getSourceExpr();
 
-      IsExact = DoubleBase->isObjCSelfExpr();
+        IsExact = DoubleBase->isObjCSelfExpr();
+      }
     }
     break;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18268.51056.patch
Type: text/x-patch
Size: 1389 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160318/acc50e4e/attachment.bin>


More information about the cfe-commits mailing list