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

Anna Zaks ganna at apple.com
Wed Oct 26 17:59:29 PDT 2011


Author: zaks
Date: Wed Oct 26 19:59:28 2011
New Revision: 143090

URL: http://llvm.org/viewvc/llvm-project?rev=143090&view=rev
Log:
[analyzer] Move enqueueEndOfFunction into CoreEngine.

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

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h?rev=143090&r1=143089&r2=143090&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h Wed Oct 26 19:59:28 2011
@@ -47,7 +47,6 @@
   friend class EndOfFunctionNodeBuilder;
   friend class CallEnterNodeBuilder;
   friend class CallExitNodeBuilder;
-  friend class ExprEngine;
 
 public:
   typedef std::vector<std::pair<BlockEdge, const ExplodedNode*> >
@@ -103,6 +102,8 @@
   void enqueueStmtNode(ExplodedNode *N,
                        const CFGBlock *Block, unsigned Idx);
 
+  ExplodedNode *generateCallExitNode(ExplodedNode *N);
+
 public:
   /// Construct a CoreEngine object to analyze the provided CFG using
   ///  a DFS exploration of the exploded graph.
@@ -167,11 +168,15 @@
   }
 
   /// \brief Enqueue the given set of nodes onto the work list.
-  void enqueue(ExplodedNodeSet &NB);
+  void enqueue(ExplodedNodeSet &Set);
 
   /// \brief Enqueue nodes that were created as a result of processing
   /// a statement onto the work list.
   void enqueue(ExplodedNodeSet &Set, const CFGBlock *Block, unsigned Idx);
+
+  /// \brief enqueue the nodes corresponding to the end of function onto the
+  /// end of path / work list.
+  void enqueueEndOfFunction(ExplodedNodeSet &Set);
 };
 
 // TODO: Turn into a calss.

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp?rev=143090&r1=143089&r2=143090&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp Wed Oct 26 19:59:28 2011
@@ -491,6 +491,22 @@
     WList->enqueue(Succ, Block, Idx+1);
 }
 
+ExplodedNode *CoreEngine::generateCallExitNode(ExplodedNode *N) {
+  // Create a CallExit node and enqueue it.
+  const StackFrameContext *LocCtx
+                         = cast<StackFrameContext>(N->getLocationContext());
+  const Stmt *CE = LocCtx->getCallSite();
+
+  // Use the the callee location context.
+  CallExit Loc(CE, LocCtx);
+
+  bool isNew;
+  ExplodedNode *Node = G->getNode(Loc, N->getState(), &isNew);
+  Node->addPredecessor(N, *G);
+  return isNew ? Node : 0;
+}
+
+
 void CoreEngine::enqueue(ExplodedNodeSet &Set) {
   for (ExplodedNodeSet::iterator I = Set.begin(),
                                  E = Set.end(); I != E; ++I) {
@@ -506,6 +522,19 @@
   }
 }
 
+void CoreEngine::enqueueEndOfFunction(ExplodedNodeSet &Set) {
+  for (ExplodedNodeSet::iterator I = Set.begin(), E = Set.end(); I != E; ++I) {
+    ExplodedNode *N = *I;
+    // If we are in an inlined call, generate CallExit node.
+    if (N->getLocationContext()->getParent()) {
+      N = generateCallExitNode(N);
+      if (N)
+        WList->enqueue(N);
+    } else
+      G->addEndOfPath(N);
+  }
+}
+
 
 ExplodedNode* NodeBuilder::generateNodeImpl(const ProgramPoint &Loc,
                                             const ProgramState *State,

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=143090&r1=143089&r2=143090&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Wed Oct 26 19:59:28 2011
@@ -1100,42 +1100,13 @@
     builder.generateNode(I, state);
 }
 
-// TODO: The next two functions should be moved into CoreEngine.
-void ExprEngine::GenerateCallExitNode(ExplodedNode *N) {
-  // Create a CallExit node and enqueue it.
-  const StackFrameContext *LocCtx
-                         = cast<StackFrameContext>(N->getLocationContext());
-  const Stmt *CE = LocCtx->getCallSite();
-
-  // Use the the callee location context.
-  CallExit Loc(CE, LocCtx);
-
-  bool isNew;
-  ExplodedNode *Node = Engine.G->getNode(Loc, N->getState(), &isNew);
-  Node->addPredecessor(N, *Engine.G);
-
-  if (isNew)
-    Engine.WList->enqueue(Node);
-}
-
-void ExprEngine::enqueueEndOfPath(ExplodedNodeSet &S) {
-  for (ExplodedNodeSet::iterator I = S.begin(), E = S.end(); I != E; ++I) {
-    ExplodedNode *N = *I;
-    // If we are in an inlined call, generate CallExit node.
-    if (N->getLocationContext()->getParent())
-      GenerateCallExitNode(N);
-    else
-      Engine.G->addEndOfPath(N);
-  }
-}
-
 /// ProcessEndPath - Called by CoreEngine.  Used to generate end-of-path
 ///  nodes when the control reaches the end of a function.
 void ExprEngine::processEndOfFunction(NodeBuilderContext& BC) {
   StateMgr.EndPath(BC.Pred->getState());
   ExplodedNodeSet Dst;
   getCheckerManager().runCheckersForEndPath(BC, Dst, *this);
-  enqueueEndOfPath(Dst);
+  Engine.enqueueEndOfFunction(Dst);
 }
 
 /// ProcessSwitch - Called by CoreEngine.  Used to generate successor





More information about the cfe-commits mailing list