[analyzer] Add StoreManager::includedInBindings() to to query whether a region is used in any bindings.

llvm-svn: 136416
This commit is contained in:
Ted Kremenek 2011-07-28 23:07:46 +00:00
parent 6b1a761f3e
commit ae16d1cc67
2 changed files with 22 additions and 2 deletions

View File

@ -153,6 +153,9 @@ public:
virtual StoreRef BindDeclWithNoInit(Store store, const VarRegion *VR) = 0;
virtual bool includedInBindings(Store store,
const MemRegion *region) const = 0;
/// If the StoreManager supports it, increment the reference count of
/// the specified Store object.
virtual void incrementReferenceCount(Store store) {}
@ -270,10 +273,8 @@ public:
};
// FIXME: Do we need to pass GRStateManager anymore?
StoreManager *CreateBasicStoreManager(GRStateManager& StMgr);
StoreManager *CreateRegionStoreManager(GRStateManager& StMgr);
StoreManager *CreateFieldsOnlyRegionStoreManager(GRStateManager& StMgr);
StoreManager *CreateFlatStoreManager(GRStateManager &StMgr);
} // end GR namespace

View File

@ -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.
//===----------------------------------------------------------------------===//