diff options
| author | Jordy Rose <jediknil@belkadan.com> | 2010-07-01 20:09:55 +0000 |
|---|---|---|
| committer | Jordy Rose <jediknil@belkadan.com> | 2010-07-01 20:09:55 +0000 |
| commit | f7488ec6dc7be25c33b05195d9c235035d431611 (patch) | |
| tree | c1fb17456b7cd07bd14a598cc59b3b829d87a187 /clang | |
| parent | 19ecba740fc90e7b408cd7b2209291ff25eda6cb (diff) | |
| download | bcm5719-llvm-f7488ec6dc7be25c33b05195d9c235035d431611.tar.gz bcm5719-llvm-f7488ec6dc7be25c33b05195d9c235035d431611.zip | |
Add an ivar to SymbolReaper for the current statement, and then stop passing the current statement around everywhere. Preparation for symbolic extents.
llvm-svn: 107422
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/include/clang/Checker/PathSensitive/Checker.h | 5 | ||||
| -rw-r--r-- | clang/include/clang/Checker/PathSensitive/Environment.h | 2 | ||||
| -rw-r--r-- | clang/include/clang/Checker/PathSensitive/GRState.h | 2 | ||||
| -rw-r--r-- | clang/include/clang/Checker/PathSensitive/GRTransferFuncs.h | 2 | ||||
| -rw-r--r-- | clang/include/clang/Checker/PathSensitive/Store.h | 2 | ||||
| -rw-r--r-- | clang/include/clang/Checker/PathSensitive/SymbolManager.h | 10 | ||||
| -rw-r--r-- | clang/lib/Checker/BasicStore.cpp | 6 | ||||
| -rw-r--r-- | clang/lib/Checker/CFRefCount.cpp | 5 | ||||
| -rw-r--r-- | clang/lib/Checker/Environment.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/Checker/FlatStore.cpp | 2 | ||||
| -rw-r--r-- | clang/lib/Checker/GRExprEngine.cpp | 6 | ||||
| -rw-r--r-- | clang/lib/Checker/GRState.cpp | 6 | ||||
| -rw-r--r-- | clang/lib/Checker/MallocChecker.cpp | 5 | ||||
| -rw-r--r-- | clang/lib/Checker/RegionStore.cpp | 13 | ||||
| -rw-r--r-- | clang/lib/Checker/SymbolManager.cpp | 4 |
15 files changed, 36 insertions, 38 deletions
diff --git a/clang/include/clang/Checker/PathSensitive/Checker.h b/clang/include/clang/Checker/PathSensitive/Checker.h index 8bedd23914f..49dc3fa7dc4 100644 --- a/clang/include/clang/Checker/PathSensitive/Checker.h +++ b/clang/include/clang/Checker/PathSensitive/Checker.h @@ -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) {} diff --git a/clang/include/clang/Checker/PathSensitive/Environment.h b/clang/include/clang/Checker/PathSensitive/Environment.h index b9bbebc652f..2981731f863 100644 --- a/clang/include/clang/Checker/PathSensitive/Environment.h +++ b/clang/include/clang/Checker/PathSensitive/Environment.h @@ -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); }; diff --git a/clang/include/clang/Checker/PathSensitive/GRState.h b/clang/include/clang/Checker/PathSensitive/GRState.h index a872edc0643..020f339b35b 100644 --- a/clang/include/clang/Checker/PathSensitive/GRState.h +++ b/clang/include/clang/Checker/PathSensitive/GRState.h @@ -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); diff --git a/clang/include/clang/Checker/PathSensitive/GRTransferFuncs.h b/clang/include/clang/Checker/PathSensitive/GRTransferFuncs.h index 13325edea77..374f99820bd 100644 --- a/clang/include/clang/Checker/PathSensitive/GRTransferFuncs.h +++ b/clang/include/clang/Checker/PathSensitive/GRTransferFuncs.h @@ -66,7 +66,7 @@ public: GRExprEngine& Engine, GRStmtNodeBuilder& Builder, ExplodedNode* Pred, - Stmt* S, const GRState* state, + const GRState* state, SymbolReaper& SymReaper) {} // Return statements. diff --git a/clang/include/clang/Checker/PathSensitive/Store.h b/clang/include/clang/Checker/PathSensitive/Store.h index 87a8314041d..79388561586 100644 --- a/clang/include/clang/Checker/PathSensitive/Store.h +++ b/clang/include/clang/Checker/PathSensitive/Store.h @@ -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; diff --git a/clang/include/clang/Checker/PathSensitive/SymbolManager.h b/clang/include/clang/Checker/PathSensitive/SymbolManager.h index dea877c0657..681b3765eda 100644 --- a/clang/include/clang/Checker/PathSensitive/SymbolManager.h +++ b/clang/include/clang/Checker/PathSensitive/SymbolManager.h @@ -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); diff --git a/clang/lib/Checker/BasicStore.cpp b/clang/lib/Checker/BasicStore.cpp index 6e0fa66d544..e1c488d0d23 100644 --- a/clang/lib/Checker/BasicStore.cpp +++ b/clang/lib/Checker/BasicStore.cpp @@ -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; diff --git a/clang/lib/Checker/CFRefCount.cpp b/clang/lib/Checker/CFRefCount.cpp index c2c47333c4d..8f65bf77bc6 100644 --- a/clang/lib/Checker/CFRefCount.cpp +++ b/clang/lib/Checker/CFRefCount.cpp @@ -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 diff --git a/clang/lib/Checker/Environment.cpp b/clang/lib/Checker/Environment.cpp index addfc21c180..48152ceb46f 100644 --- a/clang/lib/Checker/Environment.cpp +++ b/clang/lib/Checker/Environment.cpp @@ -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); diff --git a/clang/lib/Checker/FlatStore.cpp b/clang/lib/Checker/FlatStore.cpp index 7f1c579c6ed..2b6b1acad9a 100644 --- a/clang/lib/Checker/FlatStore.cpp +++ b/clang/lib/Checker/FlatStore.cpp @@ -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){ diff --git a/clang/lib/Checker/GRExprEngine.cpp b/clang/lib/Checker/GRExprEngine.cpp index 723106e1dfa..89b123d1bbe 100644 --- a/clang/lib/Checker/GRExprEngine.cpp +++ b/clang/lib/Checker/GRExprEngine.cpp @@ -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()) diff --git a/clang/lib/Checker/GRState.cpp b/clang/lib/Checker/GRState.cpp index b16e922776e..b14398a2e19 100644 --- a/clang/lib/Checker/GRState.cpp +++ b/clang/lib/Checker/GRState.cpp @@ -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); diff --git a/clang/lib/Checker/MallocChecker.cpp b/clang/lib/Checker/MallocChecker.cpp index 95f70e0925a..85ce35bd463 100644 --- a/clang/lib/Checker/MallocChecker.cpp +++ b/clang/lib/Checker/MallocChecker.cpp @@ -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; diff --git a/clang/lib/Checker/RegionStore.cpp b/clang/lib/Checker/RegionStore.cpp index 336d3925adc..c239adbe3dd 100644 --- a/clang/lib/Checker/RegionStore.cpp +++ b/clang/lib/Checker/RegionStore.cpp @@ -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. diff --git a/clang/lib/Checker/SymbolManager.cpp b/clang/lib/Checker/SymbolManager.cpp index f3a803c57d3..0bf51d760b8 100644 --- a/clang/lib/Checker/SymbolManager.cpp +++ b/clang/lib/Checker/SymbolManager.cpp @@ -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()) |

