[cfe-commits] r79973 - in /cfe/trunk: include/clang/Analysis/PathSensitive/ExplodedGraph.h include/clang/Analysis/PathSensitive/GRCoreEngine.h include/clang/Analysis/PathSensitive/GRExprEngine.h lib/Analysis/BugReporter.cpp lib/Analysis/CFRefCount.cpp lib/Analysis/GRCoreEngine.cpp lib/Analysis/GRExprEngine.cpp

Zhongxing Xu xuzhongxing at gmail.com
Mon Aug 24 20:33:42 PDT 2009


Author: zhongxingxu
Date: Mon Aug 24 22:33:41 2009
New Revision: 79973

URL: http://llvm.org/viewvc/llvm-project?rev=79973&view=rev
Log:
Remove Decl and CFG from ExplodedGraph. This leads to a series small changes.

Modified:
    cfe/trunk/include/clang/Analysis/PathSensitive/ExplodedGraph.h
    cfe/trunk/include/clang/Analysis/PathSensitive/GRCoreEngine.h
    cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h
    cfe/trunk/lib/Analysis/BugReporter.cpp
    cfe/trunk/lib/Analysis/CFRefCount.cpp
    cfe/trunk/lib/Analysis/GRCoreEngine.cpp
    cfe/trunk/lib/Analysis/GRExprEngine.cpp

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

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/ExplodedGraph.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/ExplodedGraph.h Mon Aug 24 22:33:41 2009
@@ -223,14 +223,6 @@
   /// Allocator - BumpPtrAllocator to create nodes.
   llvm::BumpPtrAllocator Allocator;
   
-  /// cfg - The CFG associated with this analysis graph.
-  CFG& cfg;
-  
-  // FIXME: Remove.
-  /// CodeDecl - The declaration containing the code being analyzed.  This
-  ///  can be a FunctionDecl or and ObjCMethodDecl.
-  const Decl& CodeDecl;
-  
   /// Ctx - The ASTContext used to "interpret" CodeDecl.
   ASTContext& Ctx;
   
@@ -247,7 +239,7 @@
                         bool* IsNew = 0);
   
   ExplodedGraph* MakeEmptyGraph() const {
-    return new ExplodedGraph(cfg, CodeDecl, Ctx);
+    return new ExplodedGraph(Ctx);
   }
 
   /// addRoot - Add an untyped node to the set of roots.
@@ -262,8 +254,7 @@
     return V;
   }
 
-  ExplodedGraph(CFG& c, const Decl &cd, ASTContext& ctx)
-    : cfg(c), CodeDecl(cd), Ctx(ctx), NumNodes(0) {}
+  ExplodedGraph(ASTContext& ctx) : Ctx(ctx), NumNodes(0) {}
 
   virtual ~ExplodedGraph() {}
 
@@ -308,16 +299,9 @@
   const_eop_iterator eop_end() const { return EndNodes.end(); }
 
   llvm::BumpPtrAllocator& getAllocator() { return Allocator; }
-  CFG& getCFG() { return cfg; }
-  ASTContext& getContext() { return Ctx; }
 
-  // FIXME: Remove.
-  const Decl& getCodeDecl() const { return CodeDecl; }
+  ASTContext& getContext() { return Ctx; }
 
-  const FunctionDecl* getFunctionDecl() const {
-    return llvm::dyn_cast<FunctionDecl>(&CodeDecl);
-  }
-  
   typedef llvm::DenseMap<const ExplodedNode*, ExplodedNode*> NodeMap;
 
   std::pair<ExplodedGraph*, InterExplodedGraphMap*>

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=79973&r1=79972&r2=79973&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRCoreEngine.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRCoreEngine.h Mon Aug 24 22:33:41 2009
@@ -98,18 +98,16 @@
 public:
   /// Construct a GRCoreEngine object to analyze the provided CFG using
   ///  a DFS exploration of the exploded graph.
-  GRCoreEngine(CFG& cfg, const Decl &cd, ASTContext& ctx,
-               GRSubEngine& subengine)
-    : SubEngine(subengine), G(new ExplodedGraph(cfg, cd, ctx)), 
+  GRCoreEngine(ASTContext& ctx, GRSubEngine& subengine)
+    : SubEngine(subengine), G(new ExplodedGraph(ctx)), 
       WList(GRWorkList::MakeBFS()),
       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(CFG& cfg, const Decl &cd, ASTContext& ctx, GRWorkList* wlist,
-               GRSubEngine& subengine)
-    : SubEngine(subengine), G(new ExplodedGraph(cfg, cd, ctx)), WList(wlist),
+  GRCoreEngine(ASTContext& ctx, GRWorkList* wlist, GRSubEngine& subengine)
+    : SubEngine(subengine), G(new ExplodedGraph(ctx)), WList(wlist),
       BCounterFactory(G->getAllocator()) {}
 
   ~GRCoreEngine() {
@@ -126,8 +124,6 @@
   /// ExecuteWorkList - Run the worklist algorithm for a maximum number of
   ///  steps.  Returns true if there is still simulation state on the worklist.
   bool ExecuteWorkList(const LocationContext *L, unsigned Steps);
-  
-  CFG& getCFG() { return G->getCFG(); }
 };
   
 class GRStmtNodeBuilder {

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

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h Mon Aug 24 22:33:41 2009
@@ -217,9 +217,6 @@
   /// getContext - Return the ASTContext associated with this analysis.
   ASTContext& getContext() const { return G.getContext(); }
   
-  /// getCFG - Returns the CFG associated with this analysis.
-  CFG& getCFG() { return G.getCFG(); }
-  
   SValuator &getSValuator() { return SVator; }
   
   GRTransferFuncs& getTF() { return *StateMgr.TF; }

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

==============================================================================
--- cfe/trunk/lib/Analysis/BugReporter.cpp (original)
+++ cfe/trunk/lib/Analysis/BugReporter.cpp Mon Aug 24 22:33:41 2009
@@ -1373,8 +1373,7 @@
 
   // Create a new (third!) graph with a single path.  This is the graph
   // that will be returned to the caller.
-  ExplodedGraph *GNew = new ExplodedGraph(GTrim->getCFG(), GTrim->getCodeDecl(),
-                                          GTrim->getContext());
+  ExplodedGraph *GNew = new ExplodedGraph(GTrim->getContext());
   
   // Sometimes the trimmed graph can contain a cycle.  Perform a reverse BFS
   // to the root node, and then construct a new graph that contains only

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

==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Mon Aug 24 22:33:41 2009
@@ -3025,7 +3025,7 @@
 
     // Special-case: are we sending a mesage to "self"?
     //  This is a hack.  When we have full-IP this should be removed.
-    if (isa<ObjCMethodDecl>(&Eng.getGraph().getCodeDecl())) {      
+    if (isa<ObjCMethodDecl>(Pred->getLocationContext()->getDecl())) {      
       if (Expr* Receiver = ME->getReceiver()) {
         SVal X = St->getSValAsScalarOrLoc(Receiver);
         if (loc::MemRegionVal* L = dyn_cast<loc::MemRegionVal>(&X)) {          

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

==============================================================================
--- cfe/trunk/lib/Analysis/GRCoreEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRCoreEngine.cpp Mon Aug 24 22:33:41 2009
@@ -151,7 +151,7 @@
   if (G->num_roots() == 0) { // Initialize the analysis by constructing
     // the root if none exists.
     
-    CFGBlock* Entry = &getCFG().getEntry();
+    CFGBlock* Entry = &(L->getCFG()->getEntry());
     
     assert (Entry->empty() && 
             "Entry block must be empty.");
@@ -214,9 +214,9 @@
   CFGBlock* Blk = L.getDst();
   
   // Check if we are entering the EXIT block. 
-  if (Blk == &getCFG().getExit()) {
+  if (Blk == &(Pred->getLocationContext()->getCFG()->getExit())) {
     
-    assert (getCFG().getExit().size() == 0 
+    assert (Pred->getLocationContext()->getCFG()->getExit().size() == 0 
             && "EXIT block cannot contain Stmts.");
 
     // Process the final state transition.

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

==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Mon Aug 24 22:33:41 2009
@@ -153,7 +153,7 @@
                            StoreManagerCreator SMC,
                            ConstraintManagerCreator CMC)
   : AMgr(mgr),
-    CoreEngine(cfg, CD, Ctx, *this), 
+    CoreEngine(Ctx, *this), 
     G(CoreEngine.getGraph()),
     Liveness(L),
     Builder(NULL),
@@ -316,7 +316,7 @@
   //  this check when we KNOW that there is no block-level subexpression.
   //  The motivation is that this check requires a hashtable lookup.
   
-  if (S != CurrentStmt && getCFG().isBlkExpr(S)) {
+  if (S != CurrentStmt && Pred->getLocationContext()->getCFG()->isBlkExpr(S)) {
     Dst.Add(Pred);
     return;
   }
@@ -494,7 +494,7 @@
   
   Ex = Ex->IgnoreParens();
   
-  if (Ex != CurrentStmt && getCFG().isBlkExpr(Ex)) {
+  if (Ex != CurrentStmt && Pred->getLocationContext()->getCFG()->isBlkExpr(Ex)) {
     Dst.Add(Pred);
     return;
   }
@@ -807,7 +807,7 @@
 void GRExprEngine::VisitGuardedExpr(Expr* Ex, Expr* L, Expr* R,
                                     ExplodedNode* Pred, ExplodedNodeSet& Dst) {
   
-  assert (Ex == CurrentStmt && getCFG().isBlkExpr(Ex));
+  assert (Ex == CurrentStmt && Pred->getLocationContext()->getCFG()->isBlkExpr(Ex));
   
   const GRState* state = GetState(Pred);
   SVal X = state->getBlkExprSVal(Ex);
@@ -917,7 +917,7 @@
   assert(B->getOpcode() == BinaryOperator::LAnd ||
          B->getOpcode() == BinaryOperator::LOr);
   
-  assert(B == CurrentStmt && getCFG().isBlkExpr(B));
+  assert(B == CurrentStmt && Pred->getLocationContext()->getCFG()->isBlkExpr(B));
   
   const GRState* state = GetState(Pred);
   SVal X = state->getBlkExprSVal(B);





More information about the cfe-commits mailing list