[cfe-commits] r74168 - /cfe/trunk/lib/Analysis/RegionStore.cpp

Zhongxing Xu xuzhongxing at gmail.com
Wed Jun 24 22:52:16 PDT 2009


Author: zhongxingxu
Date: Thu Jun 25 00:52:16 2009
New Revision: 74168

URL: http://llvm.org/viewvc/llvm-project?rev=74168&view=rev
Log:
remove RegionKills GDM. Now UnknownVal is bound to regions explicitly.

Modified:
    cfe/trunk/lib/Analysis/RegionStore.cpp

Modified: cfe/trunk/lib/Analysis/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/RegionStore.cpp?rev=74168&r1=74167&r2=74168&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/RegionStore.cpp (original)
+++ cfe/trunk/lib/Analysis/RegionStore.cpp Thu Jun 25 00:52:16 2009
@@ -103,25 +103,6 @@
 }
 
 //===----------------------------------------------------------------------===//
-// 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 @@
   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 @@
   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 @@
   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 @@
   
   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 @@
 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);





More information about the cfe-commits mailing list