[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 llvm-svn: 263818
This commit is contained in:
parent
fbd7787d7e
commit
4c62c7c981
|
@ -86,11 +86,15 @@ FunctionScopeInfo::WeakObjectProfileTy::getBaseInfo(const Expr *E) {
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -439,3 +439,15 @@ void doubleLevelAccessIvar(Test *a, Test *b) {
|
|||
}
|
||||
@end
|
||||
|
||||
// This used to crash in WeakObjectProfileTy::getBaseInfo when getBase() was
|
||||
// called on an ObjCPropertyRefExpr object whose receiver was an interface.
|
||||
|
||||
@class NSString;
|
||||
@interface NSBundle
|
||||
+(NSBundle *)foo;
|
||||
@property NSString *prop;
|
||||
@end
|
||||
|
||||
void foo() {
|
||||
NSString * t = NSBundle.foo.prop;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue