From 18d6fd45de22bbfa7f2f935a7817854f692aa8f2 Mon Sep 17 00:00:00 2001 From: Zhongxing Xu Date: Mon, 10 Nov 2008 09:39:04 +0000 Subject: [PATCH] Implement RegionStoreManager::RemoveDeadBindings(). This prunes several false warning caused by removal of symbolic constraints. Currently we just mark all symbols live. Further optimization for dead binding removal needed. llvm-svn: 58982 --- clang/lib/Analysis/RegionStore.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/clang/lib/Analysis/RegionStore.cpp b/clang/lib/Analysis/RegionStore.cpp index 20a8ae0d05c6..8372a1023eb4 100644 --- a/clang/lib/Analysis/RegionStore.cpp +++ b/clang/lib/Analysis/RegionStore.cpp @@ -83,10 +83,7 @@ public: Store RemoveDeadBindings(Store store, Stmt* Loc, const LiveVariables& Live, llvm::SmallVectorImpl& RegionRoots, - LiveSymbolsTy& LSymbols, DeadSymbolsTy& DSymbols) { - // FIXME: Implement this. - return store; - } + LiveSymbolsTy& LSymbols, DeadSymbolsTy& DSymbols); Store BindDecl(Store store, const VarDecl* VD, Expr* Ex, SVal InitVal, unsigned Count); @@ -432,6 +429,25 @@ Store RegionStoreManager::BindCompoundLiteral(Store store, return store; } +Store RegionStoreManager::RemoveDeadBindings(Store store, Stmt* Loc, + const LiveVariables& Live, + llvm::SmallVectorImpl& RegionRoots, + LiveSymbolsTy& LSymbols, DeadSymbolsTy& DSymbols) { + + RegionBindingsTy B = GetRegionBindings(store); + typedef SVal::symbol_iterator symbol_iterator; + + // FIXME: Mark all region binding value's symbol as live. We also omit symbols + // in SymbolicRegions. + for (RegionBindingsTy::iterator I = B.begin(), E = B.end(); I != E; ++I) { + SVal X = I.getData(); + for (symbol_iterator SI=X.symbol_begin(), SE=X.symbol_end(); SI!=SE; ++SI) + LSymbols.insert(*SI); + } + + return store; +} + void RegionStoreManager::print(Store store, std::ostream& Out, const char* nl, const char *sep) { llvm::raw_os_ostream OS(Out);