From ae16d1cc67965df6c494c68b3e8a2d152e014af1 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Thu, 28 Jul 2011 23:07:46 +0000 Subject: [analyzer] Add StoreManager::includedInBindings() to to query whether a region is used in any bindings. llvm-svn: 136416 --- clang/lib/StaticAnalyzer/Core/RegionStore.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'clang/lib/StaticAnalyzer/Core/RegionStore.cpp') diff --git a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp index c06d1a56826..852af29d812 100644 --- a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp +++ b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp @@ -307,6 +307,8 @@ public: // Part of public interface to class. void decrementReferenceCount(Store store) { GetRegionBindings(store).manualRelease(); } + + bool includedInBindings(Store store, const MemRegion *region) const; //===------------------------------------------------------------------===// // Loading values from regions. @@ -1284,6 +1286,23 @@ SVal RegionStoreManager::RetrieveArray(Store store, const TypedRegion * R) { return svalBuilder.makeLazyCompoundVal(StoreRef(store, *this), R); } +bool RegionStoreManager::includedInBindings(Store store, + const MemRegion *region) const { + RegionBindings B = GetRegionBindings(store); + region = region->getBaseRegion(); + + for (RegionBindings::iterator it = B.begin(), ei = B.end(); it != ei; ++it) { + const BindingKey &K = it.getKey(); + if (region == K.getRegion()) + return true; + const SVal &D = it.getData(); + if (const MemRegion *r = D.getAsRegion()) + if (r == region) + return true; + } + return false; +} + //===----------------------------------------------------------------------===// // Binding values to regions. //===----------------------------------------------------------------------===// -- cgit v1.2.3