aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/RegionStore.cpp
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2009-06-25 05:52:16 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2009-06-25 05:52:16 +0000
commite4df9c465782c5d4b1751b399bfecc113abbb389 (patch)
treed188efedd741af9444c96050e162b445481e21a7 /lib/Analysis/RegionStore.cpp
parentc00346fff95b961241abffdcc257a90e6cb1cb4b (diff)
remove RegionKills GDM. Now UnknownVal is bound to regions explicitly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74168 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/RegionStore.cpp')
-rw-r--r--lib/Analysis/RegionStore.cpp49
1 files changed, 5 insertions, 44 deletions
diff --git a/lib/Analysis/RegionStore.cpp b/lib/Analysis/RegionStore.cpp
index 2bb97e9f82..e87245f9c2 100644
--- a/lib/Analysis/RegionStore.cpp
+++ b/lib/Analysis/RegionStore.cpp
@@ -103,25 +103,6 @@ namespace clang {
}
//===----------------------------------------------------------------------===//
-// Region "killsets".
-//===----------------------------------------------------------------------===//
-//
-// RegionStore lazily adds value bindings to regions when the analyzer handles
-// assignment statements. Killsets track which default values have been
-// killed, thus distinguishing between "unknown" values and default
-// values. Regions are added to killset only when they are assigned "unknown"
-// directly, otherwise we should have their value in the region bindings.
-//
-namespace { class VISIBILITY_HIDDEN RegionKills {}; }
-static int RegionKillsIndex = 0;
-namespace clang {
- template<> struct GRStateTrait<RegionKills>
- : public GRStatePartialTrait< llvm::ImmutableSet<const MemRegion*> > {
- static void* GDMIndex() { return &RegionKillsIndex; }
- };
-}
-
-//===----------------------------------------------------------------------===//
// Regions with default values.
//===----------------------------------------------------------------------===//
//
@@ -874,10 +855,6 @@ SVal RegionStoreManager::Retrieve(const GRState *state, Loc L, QualType T) {
if (V)
return *V;
- // Check if the region is in killset.
- if (state->contains<RegionKills>(R))
- return UnknownVal();
-
if (const ObjCIvarRegion *IVR = dyn_cast<ObjCIvarRegion>(R)) {
const MemRegion *SR = IVR->getSuperRegion();
@@ -944,10 +921,6 @@ SVal RegionStoreManager::RetrieveElement(const GRState* state,
if (V)
return *V;
- // Check if the region is killed.
- if (state->contains<RegionKills>(R))
- return UnknownVal();
-
// Check if the region is an element region of a string literal.
if (const StringRegion *StrR=dyn_cast<StringRegion>(R->getSuperRegion())) {
const StringLiteral *Str = StrR->getStringLiteral();
@@ -999,10 +972,6 @@ SVal RegionStoreManager::RetrieveField(const GRState* state,
if (V)
return *V;
- // Check if the region is killed.
- if (state->contains<RegionKills>(R))
- return UnknownVal();
-
const MemRegion* SuperR = R->getSuperRegion();
const SVal* D = state->get<RegionDefaultValue>(SuperR);
if (D) {
@@ -1114,12 +1083,7 @@ const GRState *RegionStoreManager::Bind(const GRState *state, Loc L, SVal V) {
RegionBindingsTy B = GetRegionBindings(state->getStore());
- if (V.isUnknown()) {
- B = RBFactory.Remove(B, R); // Remove the binding.
- state = state->add<RegionKills>(R); // Add the region to the killset.
- }
- else
- B = RBFactory.Add(B, R, V);
+ B = RBFactory.Add(B, R, V);
return state->makeWithStore(B.getRoot());
}
@@ -1266,20 +1230,17 @@ RegionStoreManager::BindStruct(const GRState *state, const TypedRegion* R,
const GRState *RegionStoreManager::KillStruct(const GRState *state,
const TypedRegion* R){
- // (1) Kill the struct region because it is assigned "unknown".
- // (2) Set the default value of the struct region to "unknown".
- state = state->add<RegionKills>(R)->set<RegionDefaultValue>(R, UnknownVal());
- Store store = state->getStore();
- RegionBindingsTy B = GetRegionBindings(store);
+ // Set the default value of the struct region to "unknown".
+ state = state->set<RegionDefaultValue>(R, UnknownVal());
// Remove all bindings for the subregions of the struct.
+ Store store = state->getStore();
+ RegionBindingsTy B = GetRegionBindings(store);
for (RegionBindingsTy::iterator I = B.begin(), E = B.end(); I != E; ++I) {
const MemRegion* R = I.getKey();
if (const SubRegion* subRegion = dyn_cast<SubRegion>(R))
if (subRegion->isSubRegionOf(R))
store = Remove(store, ValMgr.makeLoc(subRegion));
- // FIXME: Maybe we should also remove the bindings for the "views" of the
- // subregions.
}
return state->makeWithStore(store);