]> granicus.if.org Git - clang/commitdiff
Add an ivar to SymbolReaper for the current statement, and then stop passing the...
authorJordy Rose <jediknil@belkadan.com>
Thu, 1 Jul 2010 20:09:55 +0000 (20:09 +0000)
committerJordy Rose <jediknil@belkadan.com>
Thu, 1 Jul 2010 20:09:55 +0000 (20:09 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107422 91177308-0d34-0410-b5e6-96231b3b80d8

15 files changed:
include/clang/Checker/PathSensitive/Checker.h
include/clang/Checker/PathSensitive/Environment.h
include/clang/Checker/PathSensitive/GRState.h
include/clang/Checker/PathSensitive/GRTransferFuncs.h
include/clang/Checker/PathSensitive/Store.h
include/clang/Checker/PathSensitive/SymbolManager.h
lib/Checker/BasicStore.cpp
lib/Checker/CFRefCount.cpp
lib/Checker/Environment.cpp
lib/Checker/FlatStore.cpp
lib/Checker/GRExprEngine.cpp
lib/Checker/GRState.cpp
lib/Checker/MallocChecker.cpp
lib/Checker/RegionStore.cpp
lib/Checker/SymbolManager.cpp

index 8bedd23914fdf2221ea29e50e4860413b536d561..49dc3fa7dc44e9d1bb51c3f9a34100cb7f15d08d 100644 (file)
@@ -253,7 +253,7 @@ private:
                           SymbolReaper &SymReaper, void *tag) {
     CheckerContext C(Dst, Builder, Eng, Pred, tag, 
                      ProgramPoint::PostPurgeDeadSymbolsKind, 0, S);
-    EvalDeadSymbols(C, S, SymReaper);
+    EvalDeadSymbols(C, SymReaper);
   }
 
 public:
@@ -263,8 +263,7 @@ public:
   virtual void VisitLocation(CheckerContext &C, const Stmt *S, SVal location) {}
   virtual void PreVisitBind(CheckerContext &C, const Stmt *AssignE,
                             const Stmt *StoreE, SVal location, SVal val) {}
-  virtual void EvalDeadSymbols(CheckerContext &C, const Stmt *S,
-                               SymbolReaper &SymReaper) {}
+  virtual void EvalDeadSymbols(CheckerContext &C, SymbolReaper &SymReaper) {}
   virtual void EvalEndPath(GREndPathNodeBuilder &B, void *tag,
                            GRExprEngine &Eng) {}
 
index b9bbebc652f243a662c6a5bab0aaf62230769513..2981731f863c63b5349c71ddf885f126b43bb704 100644 (file)
@@ -86,7 +86,7 @@ public:
   Environment BindExpr(Environment Env, const Stmt *S, SVal V,
                        bool Invalidate);
 
-  Environment RemoveDeadBindings(Environment Env, const Stmt *S,
+  Environment RemoveDeadBindings(Environment Env,
                                  SymbolReaper &SymReaper, const GRState *ST,
                           llvm::SmallVectorImpl<const MemRegion*>& RegionRoots);
 };
index a872edc064326c49e8f25300f315376ebb485b11..020f339b35b3e2aa49a1f63435a6c4d6b1ac093a 100644 (file)
@@ -448,7 +448,7 @@ public:
   StoreManager& getStoreManager() { return *StoreMgr; }
   ConstraintManager& getConstraintManager() { return *ConstraintMgr; }
 
-  const GRState* RemoveDeadBindings(const GRState* St, Stmt* Loc,
+  const GRState* RemoveDeadBindings(const GRState* St,
                                     const StackFrameContext *LCtx,
                                     SymbolReaper& SymReaper);
 
index 13325edea778db0dc2202ea5ac8470aaac1bc8c6..374f99820bd0f0ab8efd2babf961417b7682852f 100644 (file)
@@ -66,7 +66,7 @@ public:
                                GRExprEngine& Engine,
                                GRStmtNodeBuilder& Builder,
                                ExplodedNode* Pred,
-                               Stmt* S, const GRState* state,
+                               const GRState* state,
                                SymbolReaper& SymReaper) {}
 
   // Return statements.
index 87a8314041d7d123f505229edd434aa33e7a497e..793885615864cab07977f5d21d04d04b4b9e8356 100644 (file)
@@ -148,7 +148,7 @@ public:
     return UnknownVal();
   }
 
-  virtual const GRState *RemoveDeadBindings(GRState &state, Stmt* Loc,
+  virtual const GRState *RemoveDeadBindings(GRState &state,
                                             const StackFrameContext *LCtx,
                                             SymbolReaper& SymReaper,
                       llvm::SmallVectorImpl<const MemRegion*>& RegionRoots) = 0;
index dea877c0657f9087bb7a4239f981136690f411c3..681b3765edaa4142e4a2ecdaeb6c66dcf45a0d9b 100644 (file)
@@ -330,21 +330,23 @@ class SymbolReaper {
   SetTy TheLiving;
   SetTy TheDead;
   const LocationContext *LCtx;
+  const Stmt *Loc;
   SymbolManager& SymMgr;
 
 public:
-  SymbolReaper(const LocationContext *ctx, SymbolManager& symmgr)
-    : LCtx(ctx), SymMgr(symmgr) {}
+  SymbolReaper(const LocationContext *ctx, const Stmt *s, SymbolManager& symmgr)
+   : LCtx(ctx), Loc(s), SymMgr(symmgr) {}
 
   ~SymbolReaper() {}
 
   const LocationContext *getLocationContext() const { return LCtx; }
+  const Stmt *getCurrentStatement() const { return Loc; }
 
   bool isLive(SymbolRef sym);
 
-  bool isLive(const Stmt* Loc, const Stmt* ExprVal) const;
+  bool isLive(const Stmt *ExprVal) const;
 
-  bool isLive(const Stmt* Loc, const VarRegion *VR) const;
+  bool isLive(const VarRegion *VR) const;
   
   void markLive(SymbolRef sym);
   bool maybeDead(SymbolRef sym);
index 6e0fa66d544bf157dabd58b12cc707a61154b500..e1c488d0d238aeb140cc6dd37951269528716641 100644 (file)
@@ -72,7 +72,7 @@ public:
 
   /// RemoveDeadBindings - Scans a BasicStore of 'state' for dead values.
   ///  It updatees the GRState object in place with the values removed.
-  const GRState *RemoveDeadBindings(GRState &state, Stmt* Loc, 
+  const GRState *RemoveDeadBindings(GRState &state,
                            const StackFrameContext *LCtx,
                            SymbolReaper& SymReaper,
                           llvm::SmallVectorImpl<const MemRegion*>& RegionRoots);
@@ -251,7 +251,7 @@ Store BasicStoreManager::Remove(Store store, Loc loc) {
   }
 }
 
-const GRState *BasicStoreManager::RemoveDeadBindings(GRState &state, Stmt* Loc,
+const GRState *BasicStoreManager::RemoveDeadBindings(GRState &state,
                                             const StackFrameContext *LCtx,
                                             SymbolReaper& SymReaper,
                            llvm::SmallVectorImpl<const MemRegion*>& RegionRoots)
@@ -263,7 +263,7 @@ const GRState *BasicStoreManager::RemoveDeadBindings(GRState &state, Stmt* Loc,
   // Iterate over the variable bindings.
   for (BindingsTy::iterator I=B.begin(), E=B.end(); I!=E ; ++I) {
     if (const VarRegion *VR = dyn_cast<VarRegion>(I.getKey())) {
-      if (SymReaper.isLive(Loc, VR))
+      if (SymReaper.isLive(VR))
         RegionRoots.push_back(VR);
       else
         continue;
index c2c47333c4d877dd8aa76e1a3a1d4bbbd554216f..8f65bf77bc6b8c0b0f8c0a2048b1df125f324e52 100644 (file)
@@ -1849,7 +1849,7 @@ public:
                                GRExprEngine& Engine,
                                GRStmtNodeBuilder& Builder,
                                ExplodedNode* Pred,
-                               Stmt* S, const GRState* state,
+                               const GRState* state,
                                SymbolReaper& SymReaper);
 
   std::pair<ExplodedNode*, const GRState *>
@@ -3400,10 +3400,9 @@ void CFRefCount::EvalDeadSymbols(ExplodedNodeSet& Dst,
                                  GRExprEngine& Eng,
                                  GRStmtNodeBuilder& Builder,
                                  ExplodedNode* Pred,
-                                 Stmt* S,
                                  const GRState* state,
                                  SymbolReaper& SymReaper) {
-
+  Stmt *S = Builder.getStmt();
   RefBindings B = state->get<RefBindings>();
 
   // Update counts from autorelease pools
index addfc21c1805e77cb160f6cd651655e06540709d..48152ceb46f073c94a0b3cded0b8b4175e98b047 100644 (file)
@@ -125,7 +125,7 @@ static bool isBlockExprInCallers(const Stmt *E, const LocationContext *LC) {
 //   - Mark the region in DRoots if the binding is a loc::MemRegionVal.
 
 Environment
-EnvironmentManager::RemoveDeadBindings(Environment Env, const Stmt *S,
+EnvironmentManager::RemoveDeadBindings(Environment Env,
                                        SymbolReaper &SymReaper,
                                        const GRState *ST,
                               llvm::SmallVectorImpl<const MemRegion*> &DRoots) {
@@ -163,7 +163,7 @@ EnvironmentManager::RemoveDeadBindings(Environment Env, const Stmt *S,
     if (!C.isBlkExpr(BlkExpr))
       continue;
 
-    if (SymReaper.isLive(S, BlkExpr)) {
+    if (SymReaper.isLive(BlkExpr)) {
       // Copy the binding to the new map.
       NewEnv.ExprBindings = F.Add(NewEnv.ExprBindings, BlkExpr, X);
 
index 7f1c579c6edb742c1373d33db38c508ab60d980f..2b6b1acad9a9e28091fbf6549e8e555eba12a47d 100644 (file)
@@ -44,7 +44,7 @@ public:
   }
 
   SVal ArrayToPointer(Loc Array);
-  const GRState *RemoveDeadBindings(GRState &state, Stmt* Loc, 
+  const GRState *RemoveDeadBindings(GRState &state, 
                            const StackFrameContext *LCtx,
                            SymbolReaper& SymReaper,
                          llvm::SmallVectorImpl<const MemRegion*>& RegionRoots){
index 723106e1dfa18c3a183cbf2a64b1a411bf1aa9dd..89b123d1bbe664cfa66a3e7b48df879a07087e05 100644 (file)
@@ -537,10 +537,10 @@ void GRExprEngine::ProcessStmt(CFGElement CE, GRStmtNodeBuilder& builder) {
   // Create the cleaned state.
   const ExplodedNode *BasePred = Builder->getBasePredecessor();
 
-  SymbolReaper SymReaper(BasePred->getLocationContext(), SymMgr);
+  SymbolReaper SymReaper(BasePred->getLocationContext(), CurrentStmt, SymMgr);
 
   CleanedState = AMgr.shouldPurgeDead()
-    ? StateMgr.RemoveDeadBindings(EntryNode->getState(), CurrentStmt, 
+    ? StateMgr.RemoveDeadBindings(EntryNode->getState(), 
                          BasePred->getLocationContext()->getCurrentStackFrame(),
                                   SymReaper)
     : EntryNode->getState();
@@ -559,7 +559,7 @@ void GRExprEngine::ProcessStmt(CFGElement CE, GRStmtNodeBuilder& builder) {
 
     // FIXME: This should soon be removed.
     ExplodedNodeSet Tmp2;
-    getTF().EvalDeadSymbols(Tmp2, *this, *Builder, EntryNode, CurrentStmt,
+    getTF().EvalDeadSymbols(Tmp2, *this, *Builder, EntryNode,
                             CleanedState, SymReaper);
 
     if (Checkers.empty())
index b16e922776e53c6f1b9180cb2fb404c698a4bca5..b14398a2e19e19faf6cf861b441132f028cb3cbc 100644 (file)
@@ -34,7 +34,7 @@ GRStateManager::~GRStateManager() {
 }
 
 const GRState*
-GRStateManager::RemoveDeadBindings(const GRState* state, Stmt* Loc,
+GRStateManager::RemoveDeadBindings(const GRState* state,
                                    const StackFrameContext *LCtx,
                                    SymbolReaper& SymReaper) {
 
@@ -47,11 +47,11 @@ GRStateManager::RemoveDeadBindings(const GRState* state, Stmt* Loc,
   llvm::SmallVector<const MemRegion*, 10> RegionRoots;
   GRState NewState = *state;
 
-  NewState.Env = EnvMgr.RemoveDeadBindings(NewState.Env, Loc, SymReaper,
+  NewState.Env = EnvMgr.RemoveDeadBindings(NewState.Env, SymReaper,
                                            state, RegionRoots);
 
   // Clean up the store.
-  const GRState *s = StoreMgr->RemoveDeadBindings(NewState, Loc, LCtx, 
+  const GRState *s = StoreMgr->RemoveDeadBindings(NewState, LCtx, 
                                                   SymReaper, RegionRoots);
 
   return ConstraintMgr->RemoveDeadBindings(s, SymReaper);
index 95f70e0925a83be898f04510a235be63b4ff3d73..85ce35bd4635b8289439efec050c0c4936448750 100644 (file)
@@ -68,7 +68,7 @@ public:
       II_malloc(0), II_free(0), II_realloc(0), II_calloc(0) {}
   static void *getTag();
   bool EvalCallExpr(CheckerContext &C, const CallExpr *CE);
-  void EvalDeadSymbols(CheckerContext &C,const Stmt *S,SymbolReaper &SymReaper);
+  void EvalDeadSymbols(CheckerContext &C, SymbolReaper &SymReaper);
   void EvalEndPath(GREndPathNodeBuilder &B, void *tag, GRExprEngine &Eng);
   void PreVisitReturnStmt(CheckerContext &C, const ReturnStmt *S);
   const GRState *EvalAssume(const GRState *state, SVal Cond, bool Assumption);
@@ -471,8 +471,7 @@ void MallocChecker::CallocMem(CheckerContext &C, const CallExpr *CE) {
   C.addTransition(state);
 }
 
-void MallocChecker::EvalDeadSymbols(CheckerContext &C, const Stmt *S,
-                                    SymbolReaper &SymReaper) {
+void MallocChecker::EvalDeadSymbols(CheckerContext &C,SymbolReaper &SymReaper) {
   for (SymbolReaper::dead_iterator I = SymReaper.dead_begin(),
          E = SymReaper.dead_end(); I != E; ++I) {
     SymbolRef Sym = *I;
index 336d3925adcd3bacceeb87cf94100c3734bb44f3..c239adbe3dd8f5721affd28e218498abd3f9cbf9 100644 (file)
@@ -360,7 +360,7 @@ public: // Part of public interface to class.
 
   /// RemoveDeadBindings - Scans the RegionStore of 'state' for dead values.
   ///  It returns a new Store with these values removed.
-  const GRState *RemoveDeadBindings(GRState &state, Stmt* Loc, 
+  const GRState *RemoveDeadBindings(GRState &state, 
                                     const StackFrameContext *LCtx,
                                     SymbolReaper& SymReaper,
                           llvm::SmallVectorImpl<const MemRegion*>& RegionRoots);
@@ -1734,15 +1734,14 @@ class RemoveDeadBindingsWorker :
   public ClusterAnalysis<RemoveDeadBindingsWorker> {
   llvm::SmallVector<const SymbolicRegion*, 12> Postponed;
   SymbolReaper &SymReaper;
-  Stmt *Loc;
   const StackFrameContext *CurrentLCtx;
   
 public:
   RemoveDeadBindingsWorker(RegionStoreManager &rm, GRStateManager &stateMgr,
                            RegionBindings b, SymbolReaper &symReaper,
-                           Stmt *loc, const StackFrameContext *LCtx)
+                           const StackFrameContext *LCtx)
     : ClusterAnalysis<RemoveDeadBindingsWorker>(rm, stateMgr, b),
-      SymReaper(symReaper), Loc(loc), CurrentLCtx(LCtx) {}
+      SymReaper(symReaper), CurrentLCtx(LCtx) {}
 
   // Called by ClusterAnalysis.
   void VisitAddedToCluster(const MemRegion *baseR, RegionCluster &C);
@@ -1758,7 +1757,7 @@ void RemoveDeadBindingsWorker::VisitAddedToCluster(const MemRegion *baseR,
                                                    RegionCluster &C) {
 
   if (const VarRegion *VR = dyn_cast<VarRegion>(baseR)) {
-    if (SymReaper.isLive(Loc, VR))
+    if (SymReaper.isLive(VR))
       AddToWorkList(baseR, C);
 
     return;
@@ -1865,13 +1864,13 @@ bool RemoveDeadBindingsWorker::UpdatePostponed() {
   return changed;
 }
 
-const GRState *RegionStoreManager::RemoveDeadBindings(GRState &state, Stmt* Loc,
+const GRState *RegionStoreManager::RemoveDeadBindings(GRState &state,
                                              const StackFrameContext *LCtx,
                                              SymbolReaper& SymReaper,
                            llvm::SmallVectorImpl<const MemRegion*>& RegionRoots)
 {
   RegionBindings B = GetRegionBindings(state.getStore());
-  RemoveDeadBindingsWorker W(*this, StateMgr, B, SymReaper, Loc, LCtx);
+  RemoveDeadBindingsWorker W(*this, StateMgr, B, SymReaper, LCtx);
   W.GenerateClusters();
 
   // Enqueue the region roots onto the worklist.
index f3a803c57d32a92841ee76a4d144bbccaca5812c..0bf51d760b86dad83f80b3d54e800053aa509479 100644 (file)
@@ -215,11 +215,11 @@ bool SymbolReaper::isLive(SymbolRef sym) {
   return isa<SymbolRegionValue>(sym);
 }
 
-bool SymbolReaper::isLive(const Stmt* Loc, const Stmt* ExprVal) const {
+bool SymbolReaper::isLive(const Stmt* ExprVal) const {
   return LCtx->getLiveVariables()->isLive(Loc, ExprVal);
 }
 
-bool SymbolReaper::isLive(const Stmt *Loc, const VarRegion *VR) const {
+bool SymbolReaper::isLive(const VarRegion *VR) const {
   const StackFrameContext *SFC = VR->getStackFrame();
 
   if (SFC == LCtx->getCurrentStackFrame())