diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-02-14 03:16:10 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-02-14 03:16:10 +0000 |
commit | 5216ad7e095873f19e535ad1efba91973f05d8e8 (patch) | |
tree | 28c6f51a1e5e4d29edc2109f9595a9c00841fa0e /lib/Analysis/GRState.cpp | |
parent | 3327f6ead9362e5689674a4aaab5b7f23ea0dea3 (diff) |
Added GRStateManager::scanReachableSymbols(), a method which scans the reachable
symbols from an SVal.
- Fixed a bug in EnvironmentManager::RemoveDeadBindings() where it did not mark
live all the symbols reachable from a live block-level expression.
- Fixed a bug in the retain/release checker where it did not stop tracking
symbols that 'escaped' via compound literals being assigned to something the
BasicStoreManager didn't reason about.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64534 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/GRState.cpp')
-rw-r--r-- | lib/Analysis/GRState.cpp | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/lib/Analysis/GRState.cpp b/lib/Analysis/GRState.cpp index ea6f7a03d6..0788b432ba 100644 --- a/lib/Analysis/GRState.cpp +++ b/lib/Analysis/GRState.cpp @@ -45,7 +45,7 @@ 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, Loc, SymReaper, *this, RegionRoots); // Clean up the store. @@ -205,6 +205,35 @@ const GRState* GRStateManager::addGDM(const GRState* St, void* Key, void* Data){ } //===----------------------------------------------------------------------===// +// Utility. +//===----------------------------------------------------------------------===// + +bool GRStateManager::scanReachableSymbols(nonloc::CompoundVal val, + SymbolVisitor& visitor) { + for (nonloc::CompoundVal::iterator I=val.begin(), E=val.end(); I!=E; ++I) + if (!scanReachableSymbols(*I, visitor)) return false; + + return true; +} + +bool GRStateManager::scanReachableSymbols(SVal val, SymbolVisitor& visitor) { + + // FIXME: Scan through through the reachable regions. + // if (isa<Loc>(val)) { ... } + + if (loc::SymbolVal *X = dyn_cast<loc::SymbolVal>(&val)) + return visitor.VisitSymbol(X->getSymbol()); + + if (nonloc::SymbolVal *X = dyn_cast<nonloc::SymbolVal>(&val)) + return visitor.VisitSymbol(X->getSymbol()); + + if (nonloc::CompoundVal *X = dyn_cast<nonloc::CompoundVal>(&val)) + return scanReachableSymbols(*X, visitor); + + return true; +} + +//===----------------------------------------------------------------------===// // Queries. //===----------------------------------------------------------------------===// |