]> granicus.if.org Git - clang/commitdiff
Have GRCoreEngine record the blocks where analysis was aborted because we visited...
authorTed Kremenek <kremenek@apple.com>
Wed, 11 Aug 2010 00:03:02 +0000 (00:03 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 11 Aug 2010 00:03:02 +0000 (00:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110755 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Checker/PathSensitive/GRCoreEngine.h
lib/Checker/GRCoreEngine.cpp

index dbef75782685b9bd10adedd9b421408ec2e0bbd9..0426194c5e0e6c8ddb3423ee5965da1645e6250c 100644 (file)
@@ -58,9 +58,13 @@ class GRCoreEngine {
   ///   number of times different CFGBlocks have been visited along a path.
   GRBlockCounter::Factory BCounterFactory;
   
-  /// A flag that indicates whether paths were halted because 
-  ///  ProcessBlockEntrace returned false. 
-  bool BlockAborted;
+  
+  typedef std::vector<std::pair<BlockEdge, const ExplodedNode*> >
+          BlocksAborted;
+
+  /// The locations where we stopped doing work because we visited a location
+  ///  too many times.
+  BlocksAborted blocksAborted;
 
   void GenerateNode(const ProgramPoint& Loc, const GRState* State,
                     ExplodedNode* Pred);
@@ -129,16 +133,14 @@ public:
   GRCoreEngine(GRSubEngine& subengine)
     : SubEngine(subengine), G(new ExplodedGraph()),
       WList(GRWorkList::MakeBFS()),
-      BCounterFactory(G->getAllocator()),
-      BlockAborted(false) {}
+      BCounterFactory(G->getAllocator()) {}
 
   /// Construct a GRCoreEngine object to analyze the provided CFG and to
   ///  use the provided worklist object to execute the worklist algorithm.
   ///  The GRCoreEngine object assumes ownership of 'wlist'.
   GRCoreEngine(GRWorkList* wlist, GRSubEngine& subengine)
     : SubEngine(subengine), G(new ExplodedGraph()), WList(wlist),
-      BCounterFactory(G->getAllocator()),
-      BlockAborted(false) {}
+      BCounterFactory(G->getAllocator()) {}
 
   ~GRCoreEngine() {
     delete WList;
@@ -160,10 +162,17 @@ public:
                                        ExplodedNodeSet &Dst);
 
   // Functions for external checking of whether we have unfinished work
-  bool wasBlockAborted() const { return BlockAborted; }
-  bool hasWorkRemaining() const { return BlockAborted || WList->hasWork(); }
+  bool wasBlockAborted() const { return !blocksAborted.empty(); }
+  bool hasWorkRemaining() const { return wasBlockAborted() || WList->hasWork(); }
 
   GRWorkList *getWorkList() const { return WList; }
+
+  BlocksAborted::const_iterator blocks_aborted_begin() const {
+    return blocksAborted.begin();
+  }
+  BlocksAborted::const_iterator blocks_aborted_end() const {
+    return blocksAborted.end();
+  }
 };
 
 class GRStmtNodeBuilder {
index c2a33225370b545512a19b077797f1990a2b3f5e..e0524d9ef4cca09c2dcf15227057c99abe6cc293 100644 (file)
@@ -200,7 +200,7 @@ bool GRCoreEngine::ExecuteWorkList(const LocationContext *L, unsigned Steps,
     }
   }
 
-  SubEngine.ProcessEndWorklist(WList->hasWork() || BlockAborted);
+  SubEngine.ProcessEndWorklist(hasWorkRemaining());
   return WList->hasWork();
 }
 
@@ -250,8 +250,9 @@ void GRCoreEngine::HandleBlockEdge(const BlockEdge& L, ExplodedNode* Pred) {
   if (ProcessBlockEntrance(Blk, Pred, WList->getBlockCounter()))
     GenerateNode(BlockEntrance(Blk, Pred->getLocationContext()),
                  Pred->State, Pred);
-  else
-    BlockAborted = true;
+  else {
+    blocksAborted.push_back(std::make_pair(L, Pred));
+  }
 }
 
 void GRCoreEngine::HandleBlockEntrance(const BlockEntrance& L,