>From 995e53b6daec3a4d8b409677e416a5ff6c4a6dbf Mon Sep 17 00:00:00 2001
From: Erik Verbruggen <erik.verbruggen@me.com>
Date: Mon, 5 Mar 2012 10:02:01 +0100
Subject: [PATCH] Removes more recursive visitations in ExprEngine that are no
 longer needed as the CFG is fully linearized.

---
 .../StaticAnalyzer/Core/PathSensitive/ExprEngine.h |   10 --
 lib/StaticAnalyzer/Core/ExprEngineCXX.cpp          |   96 ++------------------
 2 files changed, 10 insertions(+), 96 deletions(-)

diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h b/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
index 6016ee1..27e2893 100644
--- a/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
+++ b/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
@@ -373,17 +373,7 @@ public:
 
   const CXXThisRegion *getCXXThisRegion(const CXXMethodDecl *decl,
                                         const StackFrameContext *frameCtx);
-
-  /// Evaluate arguments with a work list algorithm.
-  void evalArguments(ConstExprIterator AI, ConstExprIterator AE,
-                     const FunctionProtoType *FnType, 
-                     ExplodedNode *Pred, ExplodedNodeSet &Dst,
-                     bool FstArgAsLValue = false);
   
-  /// Evaluate callee expression (for a function call).
-  void evalCallee(const CallExpr *callExpr, const ExplodedNodeSet &src,
-                  ExplodedNodeSet &dest);
-
   /// evalEagerlyAssume - Given the nodes in 'Src', eagerly assume symbolic
   ///  expressions of the form 'x != 0' and generate new nodes (stored in Dst)
   ///  with those assumptions.
diff --git a/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp b/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
index fa02451..b713585 100644
--- a/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ b/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -20,77 +20,6 @@
 using namespace clang;
 using namespace ento;
 
-namespace {
-class CallExprWLItem {
-public:
-  CallExpr::const_arg_iterator I;
-  ExplodedNode *N;
-
-  CallExprWLItem(const CallExpr::const_arg_iterator &i, ExplodedNode *n)
-    : I(i), N(n) {}
-};
-}
-
-void ExprEngine::evalArguments(ConstExprIterator AI, ConstExprIterator AE,
-                                 const FunctionProtoType *FnType, 
-                                 ExplodedNode *Pred, ExplodedNodeSet &Dst,
-                                 bool FstArgAsLValue) {
-
-
-  SmallVector<CallExprWLItem, 20> WorkList;
-  WorkList.reserve(AE - AI);
-  WorkList.push_back(CallExprWLItem(AI, Pred));
-
-  while (!WorkList.empty()) {
-    CallExprWLItem Item = WorkList.back();
-    WorkList.pop_back();
-
-    if (Item.I == AE) {
-      Dst.insert(Item.N);
-      continue;
-    }
-
-    // Evaluate the argument.
-    ExplodedNodeSet Tmp;
-    if (FstArgAsLValue) {
-      FstArgAsLValue = false;
-    }
-
-    Visit(*Item.I, Item.N, Tmp);
-    ++(Item.I);
-    for (ExplodedNodeSet::iterator NI=Tmp.begin(), NE=Tmp.end(); NI != NE; ++NI)
-      WorkList.push_back(CallExprWLItem(Item.I, *NI));
-  }
-}
-
-void ExprEngine::evalCallee(const CallExpr *callExpr,
-                            const ExplodedNodeSet &src,
-                            ExplodedNodeSet &dest) {
-  
-  const Expr *callee = 0;
-  
-  switch (callExpr->getStmtClass()) {
-    case Stmt::CXXMemberCallExprClass: {
-      // Evaluate the implicit object argument that is the recipient of the
-      // call.
-      callee = cast<CXXMemberCallExpr>(callExpr)->getImplicitObjectArgument();
-      
-      // FIXME: handle member pointers.
-      if (!callee)
-        return;
-
-      break;      
-    }
-    default: {
-      callee = callExpr->getCallee()->IgnoreParens();
-      break;
-    }
-  }
-
-  for (ExplodedNodeSet::iterator i = src.begin(), e = src.end(); i != e; ++i)
-    Visit(callee, *i, dest);
-}
-
 const CXXThisRegion *ExprEngine::getCXXThisRegion(const CXXRecordDecl *D,
                                                  const StackFrameContext *SFC) {
   const Type *T = D->getTypeForDecl();
@@ -143,11 +72,6 @@ void ExprEngine::VisitCXXConstructExpr(const CXXConstructExpr *E,
     return;
 #endif
   
-  // Evaluate other arguments.
-  ExplodedNodeSet argsEvaluated;
-  const FunctionProtoType *FnType = CD->getType()->getAs<FunctionProtoType>();
-  evalArguments(E->arg_begin(), E->arg_end(), FnType, Pred, argsEvaluated);
-
 #if 0
   // Is the constructor elidable?
   if (E->isElidable()) {
@@ -160,9 +84,10 @@ void ExprEngine::VisitCXXConstructExpr(const CXXConstructExpr *E,
 #endif
   
   // Perform the previsit of the constructor.
-  ExplodedNodeSet destPreVisit;
-  getCheckerManager().runCheckersForPreStmt(destPreVisit, argsEvaluated, E, 
-                                            *this);
+  ExplodedNodeSet SrcNodes;
+  SrcNodes.Add(Pred);
+  ExplodedNodeSet TmpNodes;
+  getCheckerManager().runCheckersForPreStmt(TmpNodes, SrcNodes, E, *this);
   
   // Evaluate the constructor.  Currently we don't now allow checker-specific
   // implementations of specific constructors (as we do with ordinary
@@ -190,9 +115,9 @@ void ExprEngine::VisitCXXConstructExpr(const CXXConstructExpr *E,
 
     CallEnter Loc(E, SFC, Pred->getLocationContext());
 
-    StmtNodeBuilder Bldr(argsEvaluated, destNodes, *currentBuilderContext);
-    for (ExplodedNodeSet::iterator NI = argsEvaluated.begin(),
-                                  NE = argsEvaluated.end(); NI != NE; ++NI) {
+    StmtNodeBuilder Bldr(SrcNodes, TmpNodes, *currentBuilderContext);
+    for (ExplodedNodeSet::iterator NI = SrcNodes.begin(),
+                                   NE = SrcNodes.end(); NI != NE; ++NI) {
       ProgramStateRef state = (*NI)->getState();
       // Setup 'this' region, so that the ctor is evaluated on the object pointed
       // by 'Dest'.
@@ -205,10 +130,9 @@ void ExprEngine::VisitCXXConstructExpr(const CXXConstructExpr *E,
   // Default semantics: invalidate all regions passed as arguments.
   ExplodedNodeSet destCall;
   {
-    StmtNodeBuilder Bldr(destPreVisit, destCall, *currentBuilderContext);
-    for (ExplodedNodeSet::iterator
-        i = destPreVisit.begin(), e = destPreVisit.end();
-        i != e; ++i)
+    StmtNodeBuilder Bldr(TmpNodes, destCall, *currentBuilderContext);
+    for (ExplodedNodeSet::iterator i = TmpNodes.begin(), e = TmpNodes.end();
+         i != e; ++i)
     {
       ExplodedNode *Pred = *i;
       const LocationContext *LC = Pred->getLocationContext();
-- 
1.7.7.5 (Apple Git-26)

