]> granicus.if.org Git - clang/commitdiff
Changed GRExprEngine to pass down a reference to itself when checkers are doing posta...
authorTom Care <tcare@apple.com>
Tue, 3 Aug 2010 01:55:07 +0000 (01:55 +0000)
committerTom Care <tcare@apple.com>
Tue, 3 Aug 2010 01:55:07 +0000 (01:55 +0000)
- Exposed the worklist and BlockAborted flag in GRCoreEngine
- Changed postanalysis checkers to use the new infrastructure

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110095 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Checker/PathSensitive/Checker.h
include/clang/Checker/PathSensitive/GRCoreEngine.h
include/clang/Checker/PathSensitive/GRExprEngine.h
lib/Checker/GRExprEngine.cpp
lib/Checker/IdempotentOperationChecker.cpp
lib/Checker/UnreachableCodeChecker.cpp

index b439205edd5606ae9089287b0795b5f2600e29f3..81f151b89d79e226f2bf1998851417bd05e882bb 100644 (file)
@@ -285,7 +285,7 @@ public:
   }
 
   virtual void VisitEndAnalysis(ExplodedGraph &G, BugReporter &B,
-                                bool hasWorkRemaining) {}
+                                GRExprEngine &Eng) {}
 };
 } // end clang namespace
 
index 90f6979b5392a4c566b628f75f5663ec10a94255..dbef75782685b9bd10adedd9b421408ec2e0bbd9 100644 (file)
@@ -158,6 +158,12 @@ public:
   void ExecuteWorkListWithInitialState(const LocationContext *L, unsigned Steps,
                                        const GRState *InitState, 
                                        ExplodedNodeSet &Dst);
+
+  // Functions for external checking of whether we have unfinished work
+  bool wasBlockAborted() const { return BlockAborted; }
+  bool hasWorkRemaining() const { return BlockAborted || WList->hasWork(); }
+
+  GRWorkList *getWorkList() const { return WList; }
 };
 
 class GRStmtNodeBuilder {
index 8f01ab9f7ce07238b795f3f0d6cf43efbba9830a..ffdf9de049f1f938759e163a11b33a66ab35e87b 100644 (file)
@@ -236,6 +236,14 @@ public:
   SymbolManager& getSymbolManager() { return SymMgr; }
   const SymbolManager& getSymbolManager() const { return SymMgr; }
 
+  // Functions for external checking of whether we have unfinished work
+  bool wasBlockAborted() const { return CoreEngine.wasBlockAborted(); }
+  bool hasWorkRemaining() const {
+    return wasBlockAborted() || getWorkList()->hasWork();
+  }
+
+  GRWorkList *getWorkList() const { return CoreEngine.getWorkList(); }
+
 protected:
   const GRState* GetState(ExplodedNode* N) {
     return N == EntryNode ? CleanedState : N->getState();
index 9ee723eb7c5446fc7d3e3875447746b5a70c0e51..328dacfe909329dd45692e989d085549ddfe2b1f 100644 (file)
@@ -518,7 +518,7 @@ const GRState *GRExprEngine::ProcessAssume(const GRState *state, SVal cond,
 void GRExprEngine::ProcessEndWorklist(bool hasWorkRemaining) {
   for (CheckersOrdered::iterator I = Checkers.begin(), E = Checkers.end();
        I != E; ++I) {
-    I->second->VisitEndAnalysis(G, BR, hasWorkRemaining);
+    I->second->VisitEndAnalysis(G, BR, *this);
   }
 }
 
index 267e747928a245d0e1e5233e49d593895c21ad2a..26b018e54b9b9902ea1f5e869b339480058922d7 100644 (file)
@@ -65,8 +65,7 @@ class IdempotentOperationChecker
   public:
     static void *getTag();
     void PreVisitBinaryOperator(CheckerContext &C, const BinaryOperator *B);
-    void VisitEndAnalysis(ExplodedGraph &G, BugReporter &B,
-        bool hasWorkRemaining);
+    void VisitEndAnalysis(ExplodedGraph &G, BugReporter &B, GRExprEngine &Eng);
 
   private:
     // Our assumption about a particular operation.
@@ -293,9 +292,9 @@ void IdempotentOperationChecker::PreVisitBinaryOperator(
 
 void IdempotentOperationChecker::VisitEndAnalysis(ExplodedGraph &G,
                                                   BugReporter &BR,
-                                                  bool hasWorkRemaining) {
+                                                  GRExprEngine &Eng) {
   // If there is any work remaining we cannot be 100% sure about our warnings
-  if (hasWorkRemaining)
+  if (Eng.hasWorkRemaining())
     return;
 
   // Iterate over the hash to see if we have any paths with definite
index e95e6a832d05524ef0bd6317cfd6b14ce0234dcd..e3d758f20a52ab0de4057cdaeab5d5a2a70d935f 100644 (file)
@@ -33,8 +33,9 @@ namespace {
 class UnreachableCodeChecker : public CheckerVisitor<UnreachableCodeChecker> {
 public:
   static void *getTag();
-  void VisitEndAnalysis(ExplodedGraph &G, BugReporter &B,
-      bool hasWorkRemaining);
+  void VisitEndAnalysis(ExplodedGraph &G,
+                        BugReporter &B,
+                        GRExprEngine &Eng);
 private:
   typedef bool (*ExplodedNodeHeuristic)(const ExplodedNode &EN);
 
@@ -60,9 +61,9 @@ void clang::RegisterUnreachableCodeChecker(GRExprEngine &Eng) {
 
 void UnreachableCodeChecker::VisitEndAnalysis(ExplodedGraph &G,
                                               BugReporter &B,
-                                              bool hasWorkRemaining) {
+                                              GRExprEngine &Eng) {
   // Bail out if we didn't cover all paths
-  if (hasWorkRemaining)
+  if (Eng.hasWorkRemaining())
     return;
 
   CFG *C = 0;