]> granicus.if.org Git - clang/commitdiff
To make the analysis independent on the locally stored liveness and cfg
authorZhongxing Xu <xuzhongxing@gmail.com>
Mon, 17 Aug 2009 06:19:58 +0000 (06:19 +0000)
committerZhongxing Xu <xuzhongxing@gmail.com>
Mon, 17 Aug 2009 06:19:58 +0000 (06:19 +0000)
of GRStateManager and GRExprEngine, pass the initial location context
to the getInitialState() method.

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

include/clang/Analysis/PathSensitive/AnalysisContext.h
include/clang/Analysis/PathSensitive/GRCoreEngine.h
include/clang/Analysis/PathSensitive/GRExprEngine.h
include/clang/Analysis/PathSensitive/GRState.h
include/clang/Analysis/PathSensitive/GRSubEngine.h
include/clang/Analysis/PathSensitive/Store.h
lib/Analysis/BasicStore.cpp
lib/Analysis/GRCoreEngine.cpp
lib/Analysis/GRExprEngine.cpp
lib/Analysis/GRState.cpp
lib/Analysis/RegionStore.cpp

index 7141f56d118e559e3f8c9d2eb7ba597cec5f4654..e7ef89ae6965bcb8ff756a47deeda4901d76bdee 100644 (file)
@@ -79,6 +79,10 @@ public:
 
   LocationContext *getParent() const { return Parent; }
 
+  LiveVariables *getLiveVariables() const { 
+    return getAnalysisContext()->getLiveVariables();
+  }
+
   void Profile(llvm::FoldingSetNodeID &ID) {
     Profile(ID, Kind, Ctx, Parent);
   }
index 29336a195a2ee5e42d25411eb05fc18e1b830884..8d93963e75189d0f940685af3fa269d60bc7d122 100644 (file)
@@ -69,8 +69,8 @@ class GRCoreEngine {
                     ExplodedNode* Pred);  
 
   /// Get the initial state from the subengine.
-  const GRState* getInitialState() { 
-    return SubEngine.getInitialState();
+  const GRState* getInitialState(const LocationContext *InitLoc) { 
+    return SubEngine.getInitialState(InitLoc);
   }
 
   void ProcessEndPath(GREndPathNodeBuilder& Builder);
index dcf4e56d11e2964e2f022ace2c6393c58ae3310a..a651f95b90f28fd5e4cb5c9384be14945dea7c0e 100644 (file)
@@ -246,7 +246,7 @@ public:
   
   /// getInitialState - Return the initial state used for the root vertex
   ///  in the ExplodedGraph.
-  const GRState* getInitialState();
+  const GRState* getInitialState(const LocationContext *InitLoc);
   
   ExplodedGraph& getGraph() { return G; }
   const ExplodedGraph& getGraph() const { return G; }
index c31e1fc6088e84b987240cbe89d13b0d3c87b8f5..6439043aa931b55aaad09c073f2b96e31e10911a 100644 (file)
@@ -454,7 +454,7 @@ public:
   
   ~GRStateManager();
 
-  const GRState *getInitialState();
+  const GRState *getInitialState(const LocationContext *InitLoc);
         
   ASTContext &getContext() { return ValueMgr.getContext(); }
   const ASTContext &getContext() const { return ValueMgr.getContext(); }
index caf88a960a84707ab74a45a816a14721e7266125..f4636095adaed8010edd72cc89f4ed7e8d6e5776 100644 (file)
@@ -25,12 +25,13 @@ class GRBranchNodeBuilder;
 class GRIndirectGotoNodeBuilder;
 class GRSwitchNodeBuilder;
 class GREndPathNodeBuilder;
+class LocationContext;
 
 class GRSubEngine {
 public:
   virtual ~GRSubEngine() {}
 
-  virtual const GRState* getInitialState() = 0;
+  virtual const GRState* getInitialState(const LocationContext *InitLoc) = 0;
 
   virtual GRStateManager& getStateManager() = 0;
 
index fcc5e54cf7c89246ae69cd0712cfe8bc6dabdcd8..a9fbcc55d5e7fd7e291d05cd6f5dc5902e501d71 100644 (file)
@@ -77,7 +77,7 @@ public:
   
   /// getInitialStore - Returns the initial "empty" store representing the
   ///  value bindings upon entry to an analyzed function.
-  virtual Store getInitialStore() = 0;
+  virtual Store getInitialStore(const LocationContext *InitLoc) = 0;
   
   /// getRegionManager - Returns the internal RegionManager object that is
   ///  used to query and manipulate MemRegion objects.
index b044d400ae7836646a2baebdbea92e48c7d0038a..aed5bdc66befe5576669d388d2d43e9190eeef24 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "clang/AST/ExprObjC.h"
 #include "clang/Analysis/Analyses/LiveVariables.h"
+#include "clang/Analysis/PathSensitive/AnalysisContext.h"
 #include "clang/Analysis/PathSensitive/GRState.h"
 #include "llvm/ADT/ImmutableMap.h"
 #include "llvm/Support/Compiler.h"
@@ -61,7 +62,7 @@ public:
   
   Store BindInternal(Store St, Loc loc, SVal V);  
   Store Remove(Store St, Loc loc);
-  Store getInitialStore();
+  Store getInitialStore(const LocationContext *InitLoc);
 
   // FIXME: Investigate what is using this. This method should be removed.
   virtual Loc getLoc(const VarDecl* VD) {
@@ -488,12 +489,12 @@ Store BasicStoreManager::scanForIvars(Stmt *B, const Decl* SelfDecl, Store St) {
   return St;
 }
 
-Store BasicStoreManager::getInitialStore() {  
+Store BasicStoreManager::getInitialStore(const LocationContext *InitLoc) {  
   // The LiveVariables information already has a compilation of all VarDecls
   // used in the function.  Iterate through this set, and "symbolicate"
   // any VarDecl whose value originally comes from outside the function.
   typedef LiveVariables::AnalysisDataTy LVDataTy;
-  LVDataTy& D = StateMgr.getLiveVariables().getAnalysisData();
+  LVDataTy& D = InitLoc->getLiveVariables()->getAnalysisData();
   Store St = VBFactory.GetEmptyMap().getRoot();
 
   for (LVDataTy::decl_iterator I=D.begin_decl(), E=D.end_decl(); I != E; ++I) {
index cd20e3ca6654cd15ff8566ceada726972fcbc398..3ff27fc498ae351e7bd71fc10e9e0c977fc7977b 100644 (file)
@@ -170,7 +170,7 @@ bool GRCoreEngine::ExecuteWorkList(const LocationContext *L, unsigned Steps) {
     WList->setBlockCounter(BCounterFactory.GetEmptyCounter());
     
     // Generate the root.
-    GenerateNode(StartLoc, getInitialState(), 0);
+    GenerateNode(StartLoc, getInitialState(L), 0);
   }
   
   while (Steps && WList->hasWork()) {
index 849dd354bbdef3febc1a425570ece0c8b0bcc35b..740ad8a6b3af99c8037d0ad66700a14cd95f2e43 100644 (file)
@@ -202,8 +202,8 @@ void GRExprEngine::AddCheck(GRSimpleAPICheck *A) {
   ((MappedBatchAuditor*) BatchAuditor.get())->AddCheck(A);
 }
 
-const GRState* GRExprEngine::getInitialState() {
-  const GRState *state = StateMgr.getInitialState();
+const GRState* GRExprEngine::getInitialState(const LocationContext *InitLoc) {
+  const GRState *state = StateMgr.getInitialState(InitLoc);
   
   // Precondition: the first argument of 'main' is an integer guaranteed
   //  to be > 0.
index dc7c799288ccf440dc3c1128fd9154c64d1e7e2a..828ea26eea7983e601499c0d0d90f3b54a3512f2 100644 (file)
@@ -115,12 +115,12 @@ const GRState *GRState::bindExpr(const Stmt* Ex, SVal V,
   return bindExpr(Ex, V, isBlkExpr, Invalidate);
 }
 
-const GRState* GRStateManager::getInitialState() {
-  GRState StateImpl(this, EnvMgr.getInitialEnvironment(), 
-                    StoreMgr->getInitialStore(),
-                    GDMFactory.GetEmptyMap());
+const GRState* GRStateManager::getInitialState(const LocationContext *InitLoc) {
+  GRState State(this, EnvMgr.getInitialEnvironment(), 
+                StoreMgr->getInitialStore(InitLoc),
+                GDMFactory.GetEmptyMap());
 
-  return getPersistentState(StateImpl);
+  return getPersistentState(State);
 }
 
 const GRState* GRStateManager::getPersistentState(GRState& State) {
index 48e6de7cd8d57eb6be3ec53cc8797bf42cfc28ce..8efa0cc0010a5d48f181cba84253218b37991597 100644 (file)
@@ -231,7 +231,9 @@ public:
   SVal EvalBinOp(const GRState *state, BinaryOperator::Opcode Op,Loc L,
                  NonLoc R, QualType resultTy);
 
-  Store getInitialStore() { return RBFactory.GetEmptyMap().getRoot(); }
+  Store getInitialStore(const LocationContext *InitLoc) { 
+    return RBFactory.GetEmptyMap().getRoot(); 
+  }
   
   /// getSelfRegion - Returns the region for the 'self' (Objective-C) or
   ///  'this' object (C++).  When used when analyzing a normal function this