[cfe-commits] r70585 - in /cfe/trunk: include/clang/Analysis/PathSensitive/GRCoreEngine.h include/clang/Analysis/PathSensitive/GRWorkList.h lib/Analysis/GRCoreEngine.cpp

Ted Kremenek kremenek at apple.com
Fri May 1 15:18:46 PDT 2009


Author: kremenek
Date: Fri May  1 17:18:46 2009
New Revision: 70585

URL: http://llvm.org/viewvc/llvm-project?rev=70585&view=rev
Log:
Add a new BFS GRWorkList and make it the default worklist model for
GRCoreEngine. This tends to result in shorter paths for pathological cases.

Modified:
    cfe/trunk/include/clang/Analysis/PathSensitive/GRCoreEngine.h
    cfe/trunk/include/clang/Analysis/PathSensitive/GRWorkList.h
    cfe/trunk/lib/Analysis/GRCoreEngine.cpp

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRCoreEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRCoreEngine.h?rev=70585&r1=70584&r2=70585&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRCoreEngine.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRCoreEngine.h Fri May  1 17:18:46 2009
@@ -631,7 +631,7 @@
   ///  a DFS exploration of the exploded graph.
   GRCoreEngine(CFG& cfg, Decl& cd, ASTContext& ctx, SubEngineTy& subengine)
     : GRCoreEngineImpl(new GraphTy(cfg, cd, ctx),
-                       GRWorkList::MakeBFSBlockDFSContents()),
+                       GRWorkList::MakeBFS()),
       SubEngine(subengine) {}
   
   /// Construct a GRCoreEngine object to analyze the provided CFG and to

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRWorkList.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRWorkList.h?rev=70585&r1=70584&r2=70585&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRWorkList.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRWorkList.h Fri May  1 17:18:46 2009
@@ -68,8 +68,9 @@
   void setBlockCounter(GRBlockCounter C) { CurrentCounter = C; }
   GRBlockCounter getBlockCounter() const { return CurrentCounter; }
   
-  static GRWorkList* MakeDFS(); 
-  static GRWorkList* MakeBFSBlockDFSContents();
+  static GRWorkList *MakeDFS();
+  static GRWorkList *MakeBFS();
+  static GRWorkList *MakeBFSBlockDFSContents();
 };
 } // end clang namespace  
 #endif

Modified: cfe/trunk/lib/Analysis/GRCoreEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRCoreEngine.cpp?rev=70585&r1=70584&r2=70585&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/GRCoreEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRCoreEngine.cpp Fri May  1 17:18:46 2009
@@ -47,13 +47,35 @@
     return U;
   }
 };
+  
+class VISIBILITY_HIDDEN BFS : public GRWorkList {
+  std::queue<GRWorkListUnit> Queue;
+public:
+  virtual bool hasWork() const {
+    return !Queue.empty();
+  }
+  
+  virtual void Enqueue(const GRWorkListUnit& U) {
+    Queue.push(U);
+  }
+  
+  virtual GRWorkListUnit Dequeue() {
+    // Don't use const reference.  The subsequent pop_back() might make it
+    // unsafe.
+    GRWorkListUnit U = Queue.front(); 
+    Queue.pop();
+    return U;
+  }
+};
+  
 } // end anonymous namespace
 
 // Place the dstor for GRWorkList here because it contains virtual member
 // functions, and we the code for the dstor generated in one compilation unit.
 GRWorkList::~GRWorkList() {}
 
-GRWorkList* GRWorkList::MakeDFS() { return new DFS(); }
+GRWorkList *GRWorkList::MakeDFS() { return new DFS(); }
+GRWorkList *GRWorkList::MakeBFS() { return new BFS(); }
 
 namespace {
   class VISIBILITY_HIDDEN BFSBlockDFSContents : public GRWorkList {





More information about the cfe-commits mailing list