]> granicus.if.org Git - clang/commitdiff
[analyzer] Fix crash when handling dot syntax on 'super'.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 27 Jan 2011 16:17:11 +0000 (16:17 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 27 Jan 2011 16:17:11 +0000 (16:17 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124376 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/StaticAnalyzer/PathSensitive/ObjCMessage.h
lib/StaticAnalyzer/Checkers/ExprEngine.cpp
test/Analysis/properties.m

index 4e5ce09d7ae153f2f8f6c2f4a5d34fbeef62da7a..1af4e0290cf7e852bf83a3e7566060ab0445e5ed 100644 (file)
@@ -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 {
index 8ad094b1d3b897c0bddaaad953ffc417bad17aa2..79d2a2b2fc078d0a1eae19fdedfa97b4311cb228 100644 (file)
@@ -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)));
   }
   
index b0325a1ce7cb57290554a03461531aa0dfdec54c..ce8faf52736a620a552df252b3b1edc2bdd8e1ae 100644 (file)
@@ -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