[cfe-commits] r124376 - in /cfe/trunk: include/clang/StaticAnalyzer/PathSensitive/ObjCMessage.h lib/StaticAnalyzer/Checkers/ExprEngine.cpp test/Analysis/properties.m

Argyrios Kyrtzidis akyrtzi at gmail.com
Thu Jan 27 08:17:11 PST 2011


Author: akirtzidis
Date: Thu Jan 27 10:17:11 2011
New Revision: 124376

URL: http://llvm.org/viewvc/llvm-project?rev=124376&view=rev
Log:
[analyzer] Fix crash when handling dot syntax on 'super'.

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

Modified: cfe/trunk/include/clang/StaticAnalyzer/PathSensitive/ObjCMessage.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/PathSensitive/ObjCMessage.h?rev=124376&r1=124375&r2=124376&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/PathSensitive/ObjCMessage.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/PathSensitive/ObjCMessage.h Thu Jan 27 10:17:11 2011
@@ -78,7 +78,10 @@
     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 {

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp?rev=124376&r1=124375&r2=124376&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp Thu Jan 27 10:17:11 2011
@@ -2073,12 +2073,13 @@
 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 @@
        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)));
   }
   

Modified: cfe/trunk/test/Analysis/properties.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/properties.m?rev=124376&r1=124375&r2=124376&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/properties.m (original)
+++ cfe/trunk/test/Analysis/properties.m Thu Jan 27 10:17:11 2011
@@ -133,3 +133,13 @@
   p.name = [[NSString string] retain]; // expected-warning {{leak}}
   p.name = [[NSString alloc] init]; // expected-warning {{leak}}
 }
+
+ at interface SubPerson : Person
+-(NSString *)foo;
+ at end
+
+ at implementation SubPerson
+-(NSString *)foo {
+  return super.name;
+}
+ at end





More information about the cfe-commits mailing list