[cfe-commits] r106689 - in /cfe/trunk: include/clang/Checker/PathSensitive/Checker.h include/clang/Checker/PathSensitive/GRExprEngine.h include/clang/Checker/PathSensitive/GRSubEngine.h lib/Checker/GRCoreEngine.cpp lib/Checker/GRExprEngine.cpp

Ted Kremenek kremenek at apple.com
Wed Jun 23 15:08:00 PDT 2010


Author: kremenek
Date: Wed Jun 23 17:08:00 2010
New Revision: 106689

URL: http://llvm.org/viewvc/llvm-project?rev=106689&view=rev
Log:
Add 'VisitEndAnalysis' callback to Checker class.  This callback is called by GRExprEngine
when the worklist algorithm has terminated.  This allows some checkers to do a post-analysis
phase after all paths have been analyzed.

Modified:
    cfe/trunk/include/clang/Checker/PathSensitive/Checker.h
    cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h
    cfe/trunk/include/clang/Checker/PathSensitive/GRSubEngine.h
    cfe/trunk/lib/Checker/GRCoreEngine.cpp
    cfe/trunk/lib/Checker/GRExprEngine.cpp

Modified: cfe/trunk/include/clang/Checker/PathSensitive/Checker.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/Checker.h?rev=106689&r1=106688&r2=106689&view=diff
==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/Checker.h (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/Checker.h Wed Jun 23 17:08:00 2010
@@ -279,6 +279,9 @@
                                     bool Assumption) {
     return state;
   }
+
+  virtual void VisitEndAnalysis(ExplodedGraph &G, BugReporter &B,
+                                bool hasWorkRemaining) {}
 };
 } // end clang namespace
 

Modified: cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h?rev=106689&r1=106688&r2=106689&view=diff
==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h Wed Jun 23 17:08:00 2010
@@ -178,12 +178,15 @@
   ///  nodes when the control reaches the end of a function.
   void ProcessEndPath(GREndPathNodeBuilder& builder);
 
-  // Generate the entry node of the callee.
+  /// Generate the entry node of the callee.
   void ProcessCallEnter(GRCallEnterNodeBuilder &builder);
 
-  // Generate the first post callsite node.
+  /// Generate the first post callsite node.
   void ProcessCallExit(GRCallExitNodeBuilder &builder);
 
+  /// Called by GRCoreEngine when the analysis worklist has terminated.
+  void ProcessEndWorklist(bool hasWorkRemaining);
+
   /// EvalAssume - Callback function invoked by the ConstraintManager when
   ///  making assumptions about state values.
   const GRState *ProcessAssume(const GRState *state, SVal cond, bool assumption);

Modified: cfe/trunk/include/clang/Checker/PathSensitive/GRSubEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/GRSubEngine.h?rev=106689&r1=106688&r2=106689&view=diff
==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/GRSubEngine.h (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/GRSubEngine.h Wed Jun 23 17:08:00 2010
@@ -41,27 +41,27 @@
 
   virtual GRStateManager& getStateManager() = 0;
 
-  /// ProcessStmt - Called by GRCoreEngine. Used to generate new successor
-  ///  nodes by processing the 'effects' of a block-level statement.
+  /// Called by GRCoreEngine. Used to generate new successor
+  /// nodes by processing the 'effects' of a block-level statement.
   virtual void ProcessStmt(CFGElement E, GRStmtNodeBuilder& builder) = 0;
 
-  /// ProcessBlockEntrance - Called by GRCoreEngine when start processing
-  ///  a CFGBlock.  This method returns true if the analysis should continue
-  ///  exploring the given path, and false otherwise.
+  /// Called by GRCoreEngine when start processing
+  /// a CFGBlock.  This method returns true if the analysis should continue
+  /// exploring the given path, and false otherwise.
   virtual bool ProcessBlockEntrance(CFGBlock* B, const ExplodedNode *Pred,
                                     GRBlockCounter BC) = 0;
 
-  /// ProcessBranch - Called by GRCoreEngine.  Used to generate successor
+  /// Called by GRCoreEngine.  Used to generate successor
   ///  nodes by processing the 'effects' of a branch condition.
   virtual void ProcessBranch(Stmt* Condition, Stmt* Term,
                              GRBranchNodeBuilder& builder) = 0;
 
-  /// ProcessIndirectGoto - Called by GRCoreEngine.  Used to generate successor
-  ///  nodes by processing the 'effects' of a computed goto jump.
+  /// Called by GRCoreEngine.  Used to generate successor
+  /// nodes by processing the 'effects' of a computed goto jump.
   virtual void ProcessIndirectGoto(GRIndirectGotoNodeBuilder& builder) = 0;
 
-  /// ProcessSwitch - Called by GRCoreEngine.  Used to generate successor
-  ///  nodes by processing the 'effects' of a switch statement.
+  /// Called by GRCoreEngine.  Used to generate successor
+  /// nodes by processing the 'effects' of a switch statement.
   virtual void ProcessSwitch(GRSwitchNodeBuilder& builder) = 0;
 
   /// ProcessEndPath - Called by GRCoreEngine.  Used to generate end-of-path
@@ -74,10 +74,14 @@
   // Generate the first post callsite node.
   virtual void ProcessCallExit(GRCallExitNodeBuilder &builder) = 0;
   
-  /// EvalAssume - Called by ConstraintManager. Used to call checker-specific
-  ///  logic for handling assumptions on symbolic values.
+  /// Called by ConstraintManager. Used to call checker-specific
+  /// logic for handling assumptions on symbolic values.
   virtual const GRState* ProcessAssume(const GRState *state,
                                        SVal cond, bool assumption) = 0;
+  
+  /// Called by GRCoreEngine when the analysis worklist is either empty or the
+  //  maximum number of analysis steps have been reached.
+  virtual void ProcessEndWorklist(bool hasWorkRemaining) = 0;
 };
 }
 

Modified: cfe/trunk/lib/Checker/GRCoreEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/GRCoreEngine.cpp?rev=106689&r1=106688&r2=106689&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/GRCoreEngine.cpp (original)
+++ cfe/trunk/lib/Checker/GRCoreEngine.cpp Wed Jun 23 17:08:00 2010
@@ -221,6 +221,7 @@
     }
   }
 
+  SubEngine.ProcessEndWorklist(WList->hasWork());
   return WList->hasWork();
 }
 

Modified: cfe/trunk/lib/Checker/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/GRExprEngine.cpp?rev=106689&r1=106688&r2=106689&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Checker/GRExprEngine.cpp Wed Jun 23 17:08:00 2010
@@ -466,6 +466,13 @@
   return TF->EvalAssume(state, cond, assumption);
 }
 
+void GRExprEngine::ProcessEndWorklist(bool hasWorkRemaining) {
+  for (CheckersOrdered::iterator I = Checkers.begin(), E = Checkers.end();
+       I != E; ++I) {
+    I->second->VisitEndAnalysis(G, BR, hasWorkRemaining);
+  }
+}
+
 void GRExprEngine::ProcessStmt(CFGElement CE, GRStmtNodeBuilder& builder) {
   CurrentStmt = CE.getStmt();
   PrettyStackTraceLoc CrashInfo(getContext().getSourceManager(),





More information about the cfe-commits mailing list