summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-01-27 16:17:11 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-01-27 16:17:11 +0000
commitadd754a02edaa7ab44ce1e0ed731fdf1739133ec (patch)
tree7ce7fa1cfc4dd9c418f299575744700e74436d80
parent9f32cfd35e831aa7c381bdb8727ebc389d8f177f (diff)
downloadbcm5719-llvm-add754a02edaa7ab44ce1e0ed731fdf1739133ec.tar.gz
bcm5719-llvm-add754a02edaa7ab44ce1e0ed731fdf1739133ec.zip
[analyzer] Fix crash when handling dot syntax on 'super'.
llvm-svn: 124376
-rw-r--r--clang/include/clang/StaticAnalyzer/PathSensitive/ObjCMessage.h5
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/ExprEngine.cpp12
-rw-r--r--clang/test/Analysis/properties.m10
3 files changed, 20 insertions, 7 deletions
diff --git a/clang/include/clang/StaticAnalyzer/PathSensitive/ObjCMessage.h b/clang/include/clang/StaticAnalyzer/PathSensitive/ObjCMessage.h
index 4e5ce09d7ae..1af4e0290cf 100644
--- a/clang/include/clang/StaticAnalyzer/PathSensitive/ObjCMessage.h
+++ b/clang/include/clang/StaticAnalyzer/PathSensitive/ObjCMessage.h
@@ -78,7 +78,10 @@ public:
assert(isValid() && "This ObjCMessage is uninitialized!");
if (const ObjCMessageExpr *msgE = dyn_cast<ObjCMessageExpr>(MsgOrPropE))
return msgE->getInstanceReceiver();
- return cast<ObjCPropertyRefExpr>(MsgOrPropE)->getBase();
+ const ObjCPropertyRefExpr *propE = cast<ObjCPropertyRefExpr>(MsgOrPropE);
+ if (propE->isObjectReceiver())
+ return propE->getBase();
+ return 0;
}
bool isInstanceMessage() const {
diff --git a/clang/lib/StaticAnalyzer/Checkers/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Checkers/ExprEngine.cpp
index 8ad094b1d3b..79d2a2b2fc0 100644
--- a/clang/lib/StaticAnalyzer/Checkers/ExprEngine.cpp
+++ b/clang/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/clang/test/Analysis/properties.m b/clang/test/Analysis/properties.m
index b0325a1ce7c..ce8faf52736 100644
--- a/clang/test/Analysis/properties.m
+++ b/clang/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
OpenPOWER on IntegriCloud