r263818 - [Objective-c] Fix a crash in WeakObjectProfileTy::getBaseInfo.
Akira Hatanaka via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 18 12:03:50 PDT 2016
Author: ahatanak
Date: Fri Mar 18 14:03:50 2016
New Revision: 263818
URL: http://llvm.org/viewvc/llvm-project?rev=263818&view=rev
Log:
[Objective-c] Fix a crash in WeakObjectProfileTy::getBaseInfo.
The crash occurs in WeakObjectProfileTy::getBaseInfo when getBase() is
called on an ObjCPropertyRefExpr object whose receiver is an interface.
This commit fixes the crash by checking the type of the receiver and
setting IsExact to true if it is an interface.
rdar://problem/25208167
Differential Revision: http://reviews.llvm.org/D18268
Modified:
cfe/trunk/lib/Sema/ScopeInfo.cpp
cfe/trunk/test/SemaObjC/arc-repeated-weak.mm
Modified: cfe/trunk/lib/Sema/ScopeInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/ScopeInfo.cpp?rev=263818&r1=263817&r2=263818&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/ScopeInfo.cpp (original)
+++ cfe/trunk/lib/Sema/ScopeInfo.cpp Fri Mar 18 14:03:50 2016
@@ -86,11 +86,15 @@ FunctionScopeInfo::WeakObjectProfileTy::
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;
}
Modified: cfe/trunk/test/SemaObjC/arc-repeated-weak.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc-repeated-weak.mm?rev=263818&r1=263817&r2=263818&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/arc-repeated-weak.mm (original)
+++ cfe/trunk/test/SemaObjC/arc-repeated-weak.mm Fri Mar 18 14:03:50 2016
@@ -439,3 +439,15 @@ void doubleLevelAccessIvar(Test *a, Test
}
@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;
+}
More information about the cfe-commits
mailing list