[cfe-commits] r137279 - in /cfe/trunk: include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h lib/StaticAnalyzer/Core/CXXExprEngine.cpp lib/StaticAnalyzer/Core/ExprEngine.cpp

Anna Zaks ganna at apple.com
Wed Aug 10 16:34:53 PDT 2011


Author: zaks
Date: Wed Aug 10 18:34:53 2011
New Revision: 137279

URL: http://llvm.org/viewvc/llvm-project?rev=137279&view=rev
Log:
Cleanup: remove GetState() wrapper from ExprEngine, not needed as of r137273.

Modified:
    cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
    cfe/trunk/lib/StaticAnalyzer/Core/CXXExprEngine.cpp
    cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h?rev=137279&r1=137278&r2=137279&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h Wed Aug 10 18:34:53 2011
@@ -222,11 +222,6 @@
 
   const CoreEngine &getCoreEngine() const { return Engine; }
 
-protected:
-  const GRState* GetState(ExplodedNode* N) {
-    return N == EntryNode ? CleanedState : N->getState();
-  }
-
 public:
   ExplodedNode* MakeNode(ExplodedNodeSet& Dst, const Stmt* S, 
                          ExplodedNode* Pred, const GRState* St,

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CXXExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CXXExprEngine.cpp?rev=137279&r1=137278&r2=137279&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/CXXExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CXXExprEngine.cpp Wed Aug 10 18:34:53 2011
@@ -109,7 +109,7 @@
   ExplodedNodeSet Tmp;
   Visit(ME->GetTemporaryExpr(), Pred, Tmp);
   for (ExplodedNodeSet::iterator I = Tmp.begin(), E = Tmp.end(); I != E; ++I) {
-    const GRState *state = GetState(*I);
+    const GRState *state = (*I)->getState();
 
     // Bind the temporary object to the value of the expression. Then bind
     // the expression to the location of the object.
@@ -187,7 +187,7 @@
 
     for (ExplodedNodeSet::iterator NI = argsEvaluated.begin(),
                                   NE = argsEvaluated.end(); NI != NE; ++NI) {
-      const GRState *state = GetState(*NI);
+      const GRState *state = (*NI)->getState();
       // Setup 'this' region, so that the ctor is evaluated on the object pointed
       // by 'Dest'.
       state = state->bindLoc(loc::MemRegionVal(ThisR), loc::MemRegionVal(Dest));
@@ -216,7 +216,7 @@
        i != e; ++i)
   {
     ExplodedNode *Pred = *i;
-    const GRState *state = GetState(Pred);
+    const GRState *state = Pred->getState();
 
     // Accumulate list of regions that are invalidated.
     for (CXXConstructExpr::const_arg_iterator
@@ -280,7 +280,7 @@
   if (CNE->isArray()) {
     // FIXME: allocating an array requires simulating the constructors.
     // For now, just return a symbolicated region.
-    const GRState *state = GetState(Pred);
+    const GRState *state = Pred->getState();
     state = state->BindExpr(CNE, loc::MemRegionVal(EleReg));
     MakeNode(Dst, CNE, Pred, state);
     return;
@@ -299,7 +299,7 @@
   for (ExplodedNodeSet::iterator I = argsEvaluated.begin(), 
                                  E = argsEvaluated.end(); I != E; ++I) {
 
-    const GRState *state = GetState(*I);
+    const GRState *state = (*I)->getState();
     
     // Accumulate list of regions that are invalidated.
     // FIXME: Eventually we should unify the logic for constructor
@@ -352,7 +352,7 @@
   Visit(CDE->getArgument(), Pred, Argevaluated);
   for (ExplodedNodeSet::iterator I = Argevaluated.begin(), 
                                  E = Argevaluated.end(); I != E; ++I) {
-    const GRState *state = GetState(*I);
+    const GRState *state = (*I)->getState();
     MakeNode(Dst, CDE, *I, state);
   }
 }
@@ -365,7 +365,7 @@
                                   getContext().getCanonicalType(TE->getType()),
                                                Pred->getLocationContext());
 
-  const GRState *state = GetState(Pred);
+  const GRState *state = Pred->getState();
   SVal V = state->getSVal(loc::MemRegionVal(R));
   MakeNode(Dst, TE, Pred, state->BindExpr(TE, V));
 }

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=137279&r1=137278&r2=137279&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Wed Aug 10 18:34:53 2011
@@ -496,7 +496,7 @@
     {
       SaveAndRestore<bool> OldSink(Builder->BuildSinks);
       Builder->BuildSinks = true;
-      const ExplodedNode *node = MakeNode(Dst, S, Pred, GetState(Pred));
+      const ExplodedNode *node = MakeNode(Dst, S, Pred, Pred->getState());
       Engine.addAbortedBlock(node, Builder->getBlock());
       break;
     }
@@ -535,7 +535,7 @@
 
     case Stmt::GNUNullExprClass: {
       // GNU __null is a pointer-width integer, not an actual pointer.
-      const GRState *state = GetState(Pred);
+      const GRState *state = Pred->getState();
       state = state->BindExpr(S, svalBuilder.makeIntValWithPtrWidth(0, false));
       MakeNode(Dst, S, Pred, state);
       break;
@@ -550,7 +550,7 @@
       break;
 
     case Stmt::ImplicitValueInitExprClass: {
-      const GRState *state = GetState(Pred);
+      const GRState *state = Pred->getState();
       QualType ty = cast<ImplicitValueInitExpr>(S)->getType();
       SVal val = svalBuilder.makeZeroVal(ty);
       MakeNode(Dst, S, Pred, state->BindExpr(S, val));
@@ -621,7 +621,7 @@
         break;
       }
       else if (B->getOpcode() == BO_Comma) {
-        const GRState* state = GetState(Pred);
+        const GRState* state = Pred->getState();
         MakeNode(Dst, B, Pred, state->BindExpr(B, state->getSVal(B->getRHS())));
         break;
       }
@@ -762,7 +762,7 @@
       // an abort.
       SaveAndRestore<bool> OldSink(Builder->BuildSinks);
       Builder->BuildSinks = true;
-      MakeNode(Dst, S, Pred, GetState(Pred));
+      MakeNode(Dst, S, Pred, Pred->getState());
       break;
     }
 
@@ -791,7 +791,7 @@
       }
 
       if (Expr* LastExpr = dyn_cast<Expr>(*SE->getSubStmt()->body_rbegin())) {
-        const GRState* state = GetState(Pred);
+        const GRState* state = Pred->getState();
         MakeNode(Dst, SE, Pred, state->BindExpr(SE, state->getSVal(LastExpr)));
       }
       else
@@ -801,7 +801,7 @@
     }
 
     case Stmt::StringLiteralClass: {
-      const GRState* state = GetState(Pred);
+      const GRState* state = Pred->getState();
       SVal V = state->getLValue(cast<StringLiteral>(S));
       MakeNode(Dst, S, Pred, state->BindExpr(S, V));
       return;
@@ -1072,7 +1072,7 @@
   assert(Ex == currentStmt &&
          Pred->getLocationContext()->getCFG()->isBlkExpr(Ex));
 
-  const GRState* state = GetState(Pred);
+  const GRState* state = Pred->getState();
   SVal X = state->getSVal(Ex);
 
   assert (X.isUndef());
@@ -1254,7 +1254,7 @@
 
   assert(B==currentStmt && Pred->getLocationContext()->getCFG()->isBlkExpr(B));
 
-  const GRState* state = GetState(Pred);
+  const GRState* state = Pred->getState();
   SVal X = state->getSVal(B);
   assert(X.isUndef());
 
@@ -1309,7 +1309,7 @@
   SVal V = svalBuilder.getBlockPointer(BE->getBlockDecl(), T,
                                   Pred->getLocationContext());
 
-  MakeNode(Tmp, BE, Pred, GetState(Pred)->BindExpr(BE, V),
+  MakeNode(Tmp, BE, Pred, Pred->getState()->BindExpr(BE, V),
            ProgramPoint::PostLValueKind);
 
   // Post-visit the BlockExpr.
@@ -1319,7 +1319,7 @@
 void ExprEngine::VisitCommonDeclRefExpr(const Expr *Ex, const NamedDecl *D,
                                         ExplodedNode *Pred,
                                         ExplodedNodeSet &Dst) {
-  const GRState *state = GetState(Pred);
+  const GRState *state = Pred->getState();
 
   if (const VarDecl* VD = dyn_cast<VarDecl>(D)) {
     assert(Ex->isLValue());
@@ -1368,7 +1368,7 @@
 
   for (ExplodedNodeSet::iterator it = checkerPreStmt.begin(),
                                  ei = checkerPreStmt.end(); it != ei; ++it) {
-    const GRState* state = GetState(*it);
+    const GRState* state = (*it)->getState();
     SVal V = state->getLValue(A->getType(), state->getSVal(Idx),
                               state->getSVal(Base));
     assert(A->isLValue());
@@ -1385,7 +1385,7 @@
     return;
 
   Expr *baseExpr = M->getBase()->IgnoreParens();
-  const GRState* state = GetState(Pred);
+  const GRState* state = Pred->getState();
   SVal baseExprVal = state->getSVal(baseExpr);
   if (isa<nonloc::LazyCompoundVal>(baseExprVal) ||
       isa<nonloc::CompoundVal>(baseExprVal) ||
@@ -1426,7 +1426,7 @@
        I!=E; ++I) {
 
     if (Pred != *I)
-      state = GetState(*I);
+      state = (*I)->getState();
 
     const GRState* newState = 0;
 
@@ -1504,7 +1504,7 @@
                                                    ProgramPoint::PostStoreKind);
 
   for (ExplodedNodeSet::iterator NI=Tmp.begin(), NE=Tmp.end(); NI!=NE; ++NI)
-    evalBind(Dst, StoreE, *NI, GetState(*NI), location, Val);
+    evalBind(Dst, StoreE, *NI, (*NI)->getState(), location, Val);
 }
 
 void ExprEngine::evalLoad(ExplodedNodeSet& Dst, const Expr *Ex,
@@ -1534,7 +1534,7 @@
 
       // Perform the load from the referenced value.
       for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end() ; I!=E; ++I) {
-        state = GetState(*I);
+        state = (*I)->getState();
         location = state->getSVal(Ex);
         evalLoadCommon(Dst, Ex, *I, state, location, tag, LoadTy);
       }
@@ -1564,7 +1564,7 @@
 
   // Proceed with the load.
   for (ExplodedNodeSet::iterator NI=Tmp.begin(), NE=Tmp.end(); NI!=NE; ++NI) {
-    state = GetState(*NI);
+    state = (*NI)->getState();
 
     if (location.isUnknown()) {
       // This is important.  We must nuke the old binding.
@@ -1621,7 +1621,7 @@
   // cases as well.
   
 #if 0
-  const GRState *state = GetState(Pred);
+  const GRState *state = Pred->getState();
   const Expr *Callee = CE->getCallee();
   SVal L = state->getSVal(Callee);
   
@@ -1716,7 +1716,7 @@
 
       // Dispatch to transfer function logic to handle the call itself.
       const Expr* Callee = CE->getCallee()->IgnoreParens();
-      const GRState* state = Eng.GetState(Pred);
+      const GRState* state = Pred->getState();
       SVal L = state->getSVal(Callee);
       Eng.getTF().evalCall(Dst, Eng, Builder, CE, L, Pred);
 
@@ -1749,7 +1749,7 @@
 void ExprEngine::VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *Ex,
                                           ExplodedNode *Pred,
                                           ExplodedNodeSet &Dst) {
-  MakeNode(Dst, Ex, Pred, GetState(Pred)->BindExpr(Ex, loc::ObjCPropRef(Ex)));
+  MakeNode(Dst, Ex, Pred, Pred->getState()->BindExpr(Ex, loc::ObjCPropRef(Ex)));
 }
 
 //===----------------------------------------------------------------------===//
@@ -1773,7 +1773,7 @@
       continue;
     }
 
-    const GRState* state = GetState(Pred);
+    const GRState* state = Pred->getState();
     SVal V = state->getSVal(Ex);
     if (nonloc::SymExprVal *SEV = dyn_cast<nonloc::SymExprVal>(&V)) {
       // First assume that the condition is true.
@@ -1817,7 +1817,7 @@
                                           ExplodedNode* Pred,
                                           ExplodedNodeSet& Dst) {
 
-  const GRState *state = GetState(Pred);
+  const GRState *state = Pred->getState();
   SVal baseVal = state->getSVal(Ex->getBase());
   SVal location = state->getLValue(Ex->getDecl(), baseVal);
 
@@ -1862,7 +1862,7 @@
   //    result in state splitting.
 
   const Stmt* elem = S->getElement();
-  const GRState *state = GetState(Pred);
+  const GRState *state = Pred->getState();
   SVal elementV;
 
   if (const DeclStmt* DS = dyn_cast<DeclStmt>(elem)) {
@@ -1883,7 +1883,7 @@
   for (ExplodedNodeSet::iterator NI = dstLocation.begin(),
                                  NE = dstLocation.end(); NI!=NE; ++NI) {
     Pred = *NI;
-    const GRState *state = GetState(Pred);
+    const GRState *state = Pred->getState();
     
     // Handle the case where the container still has elements.
     SVal TrueV = svalBuilder.makeTruthVal(1);
@@ -1941,7 +1941,7 @@
     SaveOr OldHasGen(Builder->hasGeneratedNode);
 
     if (const Expr *Receiver = msg.getInstanceReceiver()) {
-      const GRState *state = GetState(Pred);
+      const GRState *state = Pred->getState();
       SVal recVal = state->getSVal(Receiver);
       if (!recVal.isUndef()) {
         // Bifurcate the state into nil and non-nil ones.
@@ -2024,7 +2024,7 @@
     // contains the updated state if we aren't generating sinks.
     if (!Builder->BuildSinks && dstEval.size() == oldSize &&
         !Builder->hasGeneratedNode)
-      MakeNode(dstEval, msg.getOriginExpr(), Pred, GetState(Pred));
+      MakeNode(dstEval, msg.getOriginExpr(), Pred, Pred->getState());
   }
 
   // Finally, perform the post-condition check of the ObjCMessageExpr and store
@@ -2047,7 +2047,7 @@
     for (ExplodedNodeSet::iterator I = dstPreStmt.begin(), E = dstPreStmt.end();
          I!=E; ++I) {
       ExplodedNode *subExprNode = *I;
-      const GRState *state = GetState(subExprNode);
+      const GRState *state = subExprNode->getState();
       evalLoad(Dst, CastE, subExprNode, state, state->getSVal(Ex));
     }
     return;
@@ -2082,7 +2082,7 @@
       case CK_NoOp:
       case CK_FunctionToPointerDecay: {
         // Copy the SVal of Ex to CastE.
-        const GRState *state = GetState(Pred);
+        const GRState *state = Pred->getState();
         SVal V = state->getSVal(Ex);
         state = state->BindExpr(CastE, V);
         MakeNode(Dst, CastE, Pred, state);
@@ -2116,7 +2116,7 @@
       case CK_AnyPointerToBlockPointerCast:  
       case CK_ObjCObjectLValueCast: {
         // Delegate to SValBuilder to process.
-        const GRState* state = GetState(Pred);
+        const GRState* state = Pred->getState();
         SVal V = state->getSVal(Ex);
         V = svalBuilder.evalCast(V, T, ExTy);
         state = state->BindExpr(CastE, V);
@@ -2126,7 +2126,7 @@
       case CK_DerivedToBase:
       case CK_UncheckedDerivedToBase: {
         // For DerivedToBase cast, delegate to the store manager.
-        const GRState *state = GetState(Pred);
+        const GRState *state = Pred->getState();
         SVal val = state->getSVal(Ex);
         val = getStoreManager().evalDerivedToBase(val, T);
         state = state->BindExpr(CastE, val);
@@ -2153,7 +2153,7 @@
           svalBuilder.getConjuredSymbolVal(NULL, CastE, resultType,
                                            Builder->getCurrentBlockCount());
 
-        const GRState *state = GetState(Pred)->BindExpr(CastE, result);
+        const GRState *state = Pred->getState()->BindExpr(CastE, result);
         MakeNode(Dst, CastE, Pred, state);
         continue;
       }
@@ -2167,7 +2167,7 @@
   const InitListExpr* ILE 
     = cast<InitListExpr>(CL->getInitializer()->IgnoreParens());
   
-  const GRState* state = GetState(Pred);
+  const GRState* state = Pred->getState();
   SVal ILV = state->getSVal(ILE);
 
   const LocationContext *LC = Pred->getLocationContext();
@@ -2203,7 +2203,7 @@
        I!=E; ++I)
   {
     ExplodedNode *N = *I;
-    const GRState *state = GetState(N);
+    const GRState *state = N->getState();
 
     // Decls without InitExpr are not initialized explicitly.
     const LocationContext *LC = N->getLocationContext();
@@ -2240,7 +2240,7 @@
 void ExprEngine::VisitInitListExpr(const InitListExpr *IE, ExplodedNode *Pred,
                                     ExplodedNodeSet& Dst) {
 
-  const GRState* state = GetState(Pred);
+  const GRState* state = Pred->getState();
   QualType T = getContext().getCanonicalType(IE->getType());
   unsigned NumInitElements = IE->getNumInits();
 
@@ -2296,7 +2296,7 @@
       // Get the size by getting the extent of the sub-expression.
       // First, visit the sub-expression to find its region.
       const Expr *Arg = Ex->getArgumentExpr();
-      const GRState *state = GetState(Pred);
+      const GRState *state = Pred->getState();
       const MemRegion *MR = state->getSVal(Arg).getAsRegion();
 
       // If the subexpression can't be resolved to a region, we don't know
@@ -2326,7 +2326,7 @@
   CharUnits amt = CharUnits::fromQuantity(Result.Val.getInt().getZExtValue());
 
   MakeNode(Dst, Ex, Pred,
-           GetState(Pred)->BindExpr(Ex,
+           Pred->getState()->BindExpr(Ex,
               svalBuilder.makeIntVal(amt.getQuantity(), Ex->getType())));
 }
 
@@ -2339,7 +2339,7 @@
     assert(OOE->getType()->isIntegerType());
     assert(IV.isSigned() == OOE->getType()->isSignedIntegerOrEnumerationType());
     SVal X = svalBuilder.makeIntVal(IV);
-    MakeNode(Dst, OOE, Pred, GetState(Pred)->BindExpr(OOE, X));
+    MakeNode(Dst, OOE, Pred, Pred->getState()->BindExpr(OOE, X));
     return;
   }
   // FIXME: Handle the case where __builtin_offsetof is not a constant.
@@ -2371,7 +2371,7 @@
 
         // For all other types, UO_Real is an identity operation.
         assert (U->getType() == Ex->getType());
-        const GRState* state = GetState(*I);
+        const GRState* state = (*I)->getState();
         MakeNode(Dst, U, *I, state->BindExpr(U, state->getSVal(Ex)));
       }
 
@@ -2393,7 +2393,7 @@
         }
 
         // For all other types, UO_Imag returns 0.
-        const GRState* state = GetState(*I);
+        const GRState* state = (*I)->getState();
         SVal X = svalBuilder.makeZeroVal(Ex->getType());
         MakeNode(Dst, U, *I, state->BindExpr(U, X));
       }
@@ -2418,7 +2418,7 @@
       Visit(Ex, Pred, Tmp);
 
       for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
-        const GRState* state = GetState(*I);
+        const GRState* state = (*I)->getState();
         MakeNode(Dst, U, *I, state->BindExpr(U, state->getSVal(Ex)));
       }
 
@@ -2434,7 +2434,7 @@
       Visit(Ex, Pred, Tmp);
 
       for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
-        const GRState* state = GetState(*I);
+        const GRState* state = (*I)->getState();
 
         // Get the value of the subexpression.
         SVal V = state->getSVal(Ex);
@@ -2509,7 +2509,7 @@
 
   for (ExplodedNodeSet::iterator I = Tmp.begin(), E = Tmp.end(); I!=E; ++I) {
 
-    const GRState* state = GetState(*I);
+    const GRState* state = (*I)->getState();
     SVal loc = state->getSVal(Ex);
 
     // Perform a load.
@@ -2518,7 +2518,7 @@
 
     for (ExplodedNodeSet::iterator I2=Tmp2.begin(), E2=Tmp2.end();I2!=E2;++I2) {
 
-      state = GetState(*I2);
+      state = (*I2)->getState();
       SVal V2_untested = state->getSVal(Ex);
 
       // Propagate unknown and undefined values.
@@ -2620,7 +2620,7 @@
     // which interprets the inline asm and stores proper results in the
     // outputs.
 
-    const GRState* state = GetState(Pred);
+    const GRState* state = Pred->getState();
 
     for (AsmStmt::const_outputs_iterator OI = A->begin_outputs(),
                                    OE = A->end_outputs(); OI != OE; ++OI) {
@@ -2653,7 +2653,7 @@
     // processCallExit to bind the return value to the call expr.
     {
       static int tag = 0;
-      const GRState *state = GetState(Pred);
+      const GRState *state = Pred->getState();
       state = state->set<ReturnExpr>(RetE);
       Pred = Builder->generateNode(RetE, state, Pred, &tag);
     }
@@ -2684,7 +2684,7 @@
     // Handle the case where no nodes where generated.
     if (!Builder->BuildSinks && Dst.size() == size &&
         !Builder->hasGeneratedNode)
-      MakeNode(Dst, RS, Pred, GetState(Pred));
+      MakeNode(Dst, RS, Pred, Pred->getState());
   }
 }
 
@@ -2703,7 +2703,7 @@
   ExplodedNodeSet Tmp3;
 
   for (ExplodedNodeSet::iterator I1=Tmp1.begin(), E1=Tmp1.end(); I1!=E1; ++I1) {
-    SVal LeftV = GetState(*I1)->getSVal(LHS);
+    SVal LeftV = (*I1)->getState()->getSVal(LHS);
     ExplodedNodeSet Tmp2;
     Visit(RHS, *I1, Tmp2);
 
@@ -2715,7 +2715,7 @@
     for (ExplodedNodeSet::iterator I2=CheckedSet.begin(), E2=CheckedSet.end();
          I2 != E2; ++I2) {
 
-      const GRState *state = GetState(*I2);
+      const GRState *state = (*I2)->getState();
       SVal RightV = state->getSVal(RHS);
 
       BinaryOperator::Opcode Op = B->getOpcode();
@@ -2778,7 +2778,7 @@
 
       for (ExplodedNodeSet::iterator I4=Tmp4.begin(), E4=Tmp4.end(); I4!=E4;
            ++I4) {
-        state = GetState(*I4);
+        state = (*I4)->getState();
         SVal V = state->getSVal(LHS);
 
         // Get the computation type.





More information about the cfe-commits mailing list