aboutsummaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer/Core/RegionStore.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2011-07-28 23:07:46 +0000
committerTed Kremenek <kremenek@apple.com>2011-07-28 23:07:46 +0000
commitfa7a95c62aa573a30d87c215b320b0086ed08bdc (patch)
tree71858f6f6c9dfea149934a01b4b0570ddc7319cb /lib/StaticAnalyzer/Core/RegionStore.cpp
parent31d922fdbf52ea14856f395cb1079173b33cefcd (diff)
[analyzer] Add StoreManager::includedInBindings() to to query whether a region is used in any bindings.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136416 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/RegionStore.cpp')
-rw-r--r--lib/StaticAnalyzer/Core/RegionStore.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/StaticAnalyzer/Core/RegionStore.cpp b/lib/StaticAnalyzer/Core/RegionStore.cpp
index c06d1a5682..852af29d81 100644
--- a/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ b/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.
//===----------------------------------------------------------------------===//