diff options
| author | Ted Kremenek <kremenek@apple.com> | 2009-03-03 01:35:36 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2009-03-03 01:35:36 +0000 |
| commit | 8dc671cdc93e02953b1f69e10719cbb7d7b94199 (patch) | |
| tree | 7ee799dbe0a69f67c8a9f33e5b2636edcde61bea /clang/lib/Analysis/RegionStore.cpp | |
| parent | a458c4ff65b27cc2f9843878b0417ce1500ba1d3 (diff) | |
| download | bcm5719-llvm-8dc671cdc93e02953b1f69e10719cbb7d7b94199.tar.gz bcm5719-llvm-8dc671cdc93e02953b1f69e10719cbb7d7b94199.zip | |
Add StoreManager::getSubRegionMap(). This method returns an opaque mapping for clients of StoreManagers from MemRegions to their subregions.
llvm-svn: 65914
Diffstat (limited to 'clang/lib/Analysis/RegionStore.cpp')
| -rw-r--r-- | clang/lib/Analysis/RegionStore.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/clang/lib/Analysis/RegionStore.cpp b/clang/lib/Analysis/RegionStore.cpp index a76a870eb44..0671a806d22 100644 --- a/clang/lib/Analysis/RegionStore.cpp +++ b/clang/lib/Analysis/RegionStore.cpp @@ -105,6 +105,37 @@ namespace clang { namespace { +class VISIBILITY_HIDDEN RegionStoreSubRegionMap : public SubRegionMap { + typedef llvm::DenseMap<const MemRegion*, + llvm::ImmutableSet<const MemRegion*> > Map; + + llvm::ImmutableSet<const MemRegion*>::Factory F; + Map M; + +public: + void add(const MemRegion* Parent, const MemRegion* SubRegion) { + Map::iterator I = M.find(Parent); + M.insert(std::make_pair(Parent, + F.Add(I == M.end() ? F.GetEmptySet() : I->second, SubRegion))); + } + + ~RegionStoreSubRegionMap() {} + + void iterSubRegions(const MemRegion* Parent, Visitor& V) const { + Map::iterator I = M.find(Parent); + + if (I == M.end()) + return; + + llvm::ImmutableSet<const MemRegion*> S = I->second; + for (llvm::ImmutableSet<const MemRegion*>::iterator SI=S.begin(),SE=S.end(); + SI != SE; ++SI) { + if (!V.Visit(Parent, *SI)) + return; + } + } +}; + class VISIBILITY_HIDDEN RegionStoreManager : public StoreManager { RegionBindingsTy::Factory RBFactory; RegionViews::Factory RVFactory; @@ -128,6 +159,8 @@ public: MemRegionManager& getRegionManager() { return MRMgr; } + std::auto_ptr<SubRegionMap> getSubRegionMap(const GRState *state); + const GRState* BindCompoundLiteral(const GRState* St, const CompoundLiteralExpr* CL, SVal V); @@ -268,6 +301,18 @@ StoreManager* clang::CreateRegionStoreManager(GRStateManager& StMgr) { return new RegionStoreManager(StMgr); } +std::auto_ptr<SubRegionMap> +RegionStoreManager::getSubRegionMap(const GRState *state) { + RegionBindingsTy B = GetRegionBindings(state->getStore()); + RegionStoreSubRegionMap *M = new RegionStoreSubRegionMap(); + + for (RegionBindingsTy::iterator I=B.begin(), E=B.end(); I!=E; ++I) { + if (const SubRegion* R = dyn_cast<SubRegion>(I.getKey())) + M->add(R->getSuperRegion(), R); + } + + return std::auto_ptr<SubRegionMap>(M); +} /// getLValueString - Returns an SVal representing the lvalue of a /// StringLiteral. Within RegionStore a StringLiteral has an |

