diff options
| author | Ted Kremenek <kremenek@apple.com> | 2011-02-19 01:59:33 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2011-02-19 01:59:33 +0000 |
| commit | fda368751546cfd739dd4c7effface9b836c1ef9 (patch) | |
| tree | 3f40e584eea3aae81d82a13becce9f7d7521ee51 /clang/lib/StaticAnalyzer/Core/FlatStore.cpp | |
| parent | f66e5b695f8c64f9bae55f545be38c3aefb19769 (diff) | |
| download | bcm5719-llvm-fda368751546cfd739dd4c7effface9b836c1ef9.tar.gz bcm5719-llvm-fda368751546cfd739dd4c7effface9b836c1ef9.zip | |
Add 'StoreRef' smart pointer to allow more fine-grain memory lifetime control of Store objects.
This yields a minor memory reduction (for larger functions) on Sqlite at the cost of slightly
higher memory usage on some functions because of the increased size of GRState (which can be optimized).
I expect the real memory savings from this enhancement will come when we aggressively
canabilize more of the ExplodedGraph.
llvm-svn: 126012
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/FlatStore.cpp')
| -rw-r--r-- | clang/lib/StaticAnalyzer/Core/FlatStore.cpp | 69 |
1 files changed, 35 insertions, 34 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/FlatStore.cpp b/clang/lib/StaticAnalyzer/Core/FlatStore.cpp index c3da72af5a3..99a5eadaca2 100644 --- a/clang/lib/StaticAnalyzer/Core/FlatStore.cpp +++ b/clang/lib/StaticAnalyzer/Core/FlatStore.cpp @@ -31,13 +31,13 @@ public: BVFactory(mgr.getAllocator()) {} SVal Retrieve(Store store, Loc L, QualType T); - Store Bind(Store store, Loc L, SVal val); - Store Remove(Store St, Loc L); - Store BindCompoundLiteral(Store store, const CompoundLiteralExpr* cl, + StoreRef Bind(Store store, Loc L, SVal val); + StoreRef Remove(Store St, Loc L); + StoreRef BindCompoundLiteral(Store store, const CompoundLiteralExpr* cl, const LocationContext *LC, SVal v); - Store getInitialStore(const LocationContext *InitLoc) { - return RBFactory.getEmptyMap().getRoot(); + StoreRef getInitialStore(const LocationContext *InitLoc) { + return StoreRef(RBFactory.getEmptyMap().getRoot(), *this); } SubRegionMap *getSubRegionMap(Store store) { @@ -45,22 +45,23 @@ public: } SVal ArrayToPointer(Loc Array); - Store removeDeadBindings(Store store, const StackFrameContext *LCtx, - SymbolReaper& SymReaper, - llvm::SmallVectorImpl<const MemRegion*>& RegionRoots){ - return store; + StoreRef removeDeadBindings(Store store, const StackFrameContext *LCtx, + SymbolReaper& SymReaper, + llvm::SmallVectorImpl<const MemRegion*>& RegionRoots){ + return StoreRef(store, *this); } - Store BindDecl(Store store, const VarRegion *VR, SVal initVal); + StoreRef BindDecl(Store store, const VarRegion *VR, SVal initVal); - Store BindDeclWithNoInit(Store store, const VarRegion *VR); + StoreRef BindDeclWithNoInit(Store store, const VarRegion *VR); typedef llvm::DenseSet<SymbolRef> InvalidatedSymbols; - Store invalidateRegions(Store store, const MemRegion * const *I, - const MemRegion * const *E, const Expr *Ex, - unsigned Count, InvalidatedSymbols *IS, - bool invalidateGlobals, InvalidatedRegions *Regions); + StoreRef invalidateRegions(Store store, const MemRegion * const *I, + const MemRegion * const *E, const Expr *Ex, + unsigned Count, InvalidatedSymbols *IS, + bool invalidateGlobals, + InvalidatedRegions *Regions); void print(Store store, llvm::raw_ostream& Out, const char* nl, const char *sep); @@ -115,7 +116,7 @@ SVal FlatStoreManager::RetrieveRegionWithNoBinding(const MemRegion *R, return svalBuilder.getRegionValueSymbolVal(cast<TypedRegion>(R)); } -Store FlatStoreManager::Bind(Store store, Loc L, SVal val) { +StoreRef FlatStoreManager::Bind(Store store, Loc L, SVal val) { const MemRegion *R = cast<loc::MemRegionVal>(L).getRegion(); RegionBindings B = getRegionBindings(store); const BindingVal *V = B.lookup(R); @@ -127,45 +128,45 @@ Store FlatStoreManager::Bind(Store store, Loc L, SVal val) { RegionInterval RI = RegionToInterval(R); // FIXME: FlatStore should handle regions with unknown intervals. if (!RI.R) - return B.getRoot(); + return StoreRef(B.getRoot(), *this); BV = BVFactory.add(BV, RI.I, val); B = RBFactory.add(B, RI.R, BV); - return B.getRoot(); + return StoreRef(B.getRoot(), *this); } -Store FlatStoreManager::Remove(Store store, Loc L) { - return store; +StoreRef FlatStoreManager::Remove(Store store, Loc L) { + return StoreRef(store, *this); } -Store FlatStoreManager::BindCompoundLiteral(Store store, +StoreRef FlatStoreManager::BindCompoundLiteral(Store store, const CompoundLiteralExpr* cl, const LocationContext *LC, SVal v) { - return store; + return StoreRef(store, *this); } SVal FlatStoreManager::ArrayToPointer(Loc Array) { return Array; } -Store FlatStoreManager::BindDecl(Store store, const VarRegion *VR, - SVal initVal) { +StoreRef FlatStoreManager::BindDecl(Store store, const VarRegion *VR, + SVal initVal) { return Bind(store, svalBuilder.makeLoc(VR), initVal); } -Store FlatStoreManager::BindDeclWithNoInit(Store store, const VarRegion *VR) { - return store; +StoreRef FlatStoreManager::BindDeclWithNoInit(Store store, const VarRegion *VR){ + return StoreRef(store, *this); } -Store FlatStoreManager::invalidateRegions(Store store, - const MemRegion * const *I, - const MemRegion * const *E, - const Expr *Ex, unsigned Count, - InvalidatedSymbols *IS, - bool invalidateGlobals, - InvalidatedRegions *Regions) { +StoreRef FlatStoreManager::invalidateRegions(Store store, + const MemRegion * const *I, + const MemRegion * const *E, + const Expr *Ex, unsigned Count, + InvalidatedSymbols *IS, + bool invalidateGlobals, + InvalidatedRegions *Regions) { assert(false && "Not implemented"); - return store; + return StoreRef(store, *this); } void FlatStoreManager::print(Store store, llvm::raw_ostream& Out, |

