From: Ted Kremenek Date: Tue, 2 Feb 2010 22:38:47 +0000 (+0000) Subject: Remove RegionStoreSubRegionMap::iterator and RegionStoreSubRegionMap::begin_end(... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=df165014c2defd9120a8f105a855d6a8b35befbe;p=clang Remove RegionStoreSubRegionMap::iterator and RegionStoreSubRegionMap::begin_end(). This is a precursor to using DenseSet to represent region sets instead of ImmutableSet. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95151 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Checker/RegionStore.cpp b/lib/Checker/RegionStore.cpp index 376921f00e..9cdb516068 100644 --- a/lib/Checker/RegionStore.cpp +++ b/lib/Checker/RegionStore.cpp @@ -178,9 +178,11 @@ static bool IsAnyPointerOrIntptr(QualType ty, ASTContext &Ctx) { namespace { class RegionStoreSubRegionMap : public SubRegionMap { - typedef llvm::ImmutableSet SetTy; - typedef llvm::DenseMap Map; - SetTy::Factory F; +public: + typedef llvm::ImmutableSet Set; + typedef llvm::DenseMap Map; +private: + Set::Factory F; Map M; public: bool add(const MemRegion* Parent, const MemRegion* SubRegion) { @@ -198,6 +200,11 @@ public: void process(llvm::SmallVectorImpl &WL, const SubRegion *R); ~RegionStoreSubRegionMap() {} + + const Set *getSubRegions(const MemRegion *Parent) const { + Map::const_iterator I = M.find(Parent); + return I == M.end() ? NULL : &I->second; + } bool iterSubRegions(const MemRegion* Parent, Visitor& V) const { Map::const_iterator I = M.find(Parent); @@ -205,23 +212,14 @@ public: if (I == M.end()) return true; - llvm::ImmutableSet S = I->second; - for (llvm::ImmutableSet::iterator SI=S.begin(),SE=S.end(); - SI != SE; ++SI) { + Set S = I->second; + for (Set::iterator SI=S.begin(),SE=S.end(); SI != SE; ++SI) { if (!V.Visit(Parent, *SI)) return false; } return true; } - - typedef SetTy::iterator iterator; - - std::pair begin_end(const MemRegion *R) { - Map::iterator I = M.find(R); - SetTy S = I == M.end() ? F.GetEmptySet() : I->second; - return std::make_pair(S.begin(), S.end()); - } }; class RegionStoreManager : public StoreManager { @@ -235,7 +233,7 @@ public: RegionStoreManager(GRStateManager& mgr, const RegionStoreFeatures &f) : StoreManager(mgr), Features(f), - RBFactory(mgr.getAllocator()) {} + RBFactory(mgr.getAllocator(), 3) {} virtual ~RegionStoreManager() { for (SMCache::iterator I = SC.begin(), E = SC.end(); I != E; ++I) @@ -508,13 +506,15 @@ SubRegionMap *RegionStoreManager::getSubRegionMap(const GRState *state) { // Binding invalidation. //===----------------------------------------------------------------------===// + void RegionStoreManager::RemoveSubRegionBindings(RegionBindings &B, const MemRegion *R, RegionStoreSubRegionMap &M) { - RegionStoreSubRegionMap::iterator I, E; - - for (llvm::tie(I, E) = M.begin_end(R); I != E; ++I) - RemoveSubRegionBindings(B, *I, M); + + if (const RegionStoreSubRegionMap::Set *S = M.getSubRegions(R)) + for (RegionStoreSubRegionMap::Set::iterator I = S->begin(), E = S->end(); + I != E; ++I) + RemoveSubRegionBindings(B, *I, M); B = Remove(B, R); } @@ -552,9 +552,10 @@ const GRState *RegionStoreManager::InvalidateRegions(const GRState *state, visited = 1; // Add subregions to work list. - RegionStoreSubRegionMap::iterator I, E; - for (llvm::tie(I, E) = SubRegions->begin_end(R); I!=E; ++I) - WorkList.push_back(*I); + if (const RegionStoreSubRegionMap::Set *S = SubRegions->getSubRegions(R)) + for (RegionStoreSubRegionMap::Set::iterator I = S->begin(), E = S->end(); + I != E; ++I) + WorkList.push_back(*I); // Get the old binding. Is it a region? If so, add it to the worklist. if (Optional V = getDirectBinding(B, R)) { @@ -1884,10 +1885,11 @@ tryAgain: SM = getRegionStoreSubRegionMap(state_N->getStore()); M = SM; } - - RegionStoreSubRegionMap::iterator I, E; - for (llvm::tie(I, E) = M->begin_end(R); I != E; ++I) - WorkList.push_back(std::make_pair(state_N, *I)); + + if (const RegionStoreSubRegionMap::Set *S = M->getSubRegions(R)) + for (RegionStoreSubRegionMap::Set::iterator I = S->begin(), E = S->end(); + I != E; ++I) + WorkList.push_back(std::make_pair(state_N, *I)); // Enqueue the super region. if (const SubRegion *SR = dyn_cast(R)) {