From: Argyrios Kyrtzidis Date: Thu, 27 Jan 2011 16:17:11 +0000 (+0000) Subject: [analyzer] Fix crash when handling dot syntax on 'super'. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9319b56154cfd9e3c781e54d2ee1c10c5858efed;p=clang [analyzer] Fix crash when handling dot syntax on 'super'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124376 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/StaticAnalyzer/PathSensitive/ObjCMessage.h b/include/clang/StaticAnalyzer/PathSensitive/ObjCMessage.h index 4e5ce09d7a..1af4e0290c 100644 --- a/include/clang/StaticAnalyzer/PathSensitive/ObjCMessage.h +++ b/include/clang/StaticAnalyzer/PathSensitive/ObjCMessage.h @@ -78,7 +78,10 @@ public: assert(isValid() && "This ObjCMessage is uninitialized!"); if (const ObjCMessageExpr *msgE = dyn_cast(MsgOrPropE)) return msgE->getInstanceReceiver(); - return cast(MsgOrPropE)->getBase(); + const ObjCPropertyRefExpr *propE = cast(MsgOrPropE); + if (propE->isObjectReceiver()) + return propE->getBase(); + return 0; } bool isInstanceMessage() const { diff --git a/lib/StaticAnalyzer/Checkers/ExprEngine.cpp b/lib/StaticAnalyzer/Checkers/ExprEngine.cpp index 8ad094b1d3..79d2a2b2fc 100644 --- a/lib/StaticAnalyzer/Checkers/ExprEngine.cpp +++ b/lib/StaticAnalyzer/Checkers/ExprEngine.cpp @@ -2073,12 +2073,13 @@ void ExprEngine::VisitCall(const CallExpr* CE, ExplodedNode* Pred, void ExprEngine::VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *Ex, ExplodedNode *Pred, ExplodedNodeSet &Dst) { - - // Visit the base expression, which is needed for computing the lvalue - // of the ivar. ExplodedNodeSet dstBase; - const Expr *baseExpr = Ex->getBase(); - Visit(baseExpr, Pred, dstBase); + + // Visit the receiver (if any). + if (Ex->isObjectReceiver()) + Visit(Ex->getBase(), Pred, dstBase); + else + dstBase = Pred; ExplodedNodeSet dstPropRef; @@ -2087,7 +2088,6 @@ void ExprEngine::VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *Ex, I!=E; ++I) { ExplodedNode *nodeBase = *I; const GRState *state = GetState(nodeBase); - SVal baseVal = state->getSVal(baseExpr); MakeNode(dstPropRef, Ex, *I, state->BindExpr(Ex, loc::ObjCPropRef(Ex))); } diff --git a/test/Analysis/properties.m b/test/Analysis/properties.m index b0325a1ce7..ce8faf5273 100644 --- a/test/Analysis/properties.m +++ b/test/Analysis/properties.m @@ -133,3 +133,13 @@ void rdar6611873() { p.name = [[NSString string] retain]; // expected-warning {{leak}} p.name = [[NSString alloc] init]; // expected-warning {{leak}} } + +@interface SubPerson : Person +-(NSString *)foo; +@end + +@implementation SubPerson +-(NSString *)foo { + return super.name; +} +@end