Browse Source

Rename 'unbindLoc()' (in ProgramState) and 'Remove()' to
'killBinding()'. The name is more specific, and one just forwarded
to the other.

Add some doxygen comments along the way.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162350 91177308-0d34-0410-b5e6-96231b3b80d8

Ted Kremenek 13 years ago
parent
commit
56a46b51df

+ 1 - 1
include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h

@@ -237,7 +237,7 @@ public:
 
 
   ProgramStateRef bindDefault(SVal loc, SVal V) const;
   ProgramStateRef bindDefault(SVal loc, SVal V) const;
 
 
-  ProgramStateRef unbindLoc(Loc LV) const;
+  ProgramStateRef killBinding(Loc LV) const;
 
 
   /// invalidateRegions - Returns the state with bindings for the given regions
   /// invalidateRegions - Returns the state with bindings for the given regions
   ///  cleared from the store. The regions are provided as a continuous array
   ///  cleared from the store. The regions are provided as a continuous array

+ 7 - 1
include/clang/StaticAnalyzer/Core/PathSensitive/Store.h

@@ -67,7 +67,13 @@ public:
   virtual StoreRef Bind(Store store, Loc loc, SVal val) = 0;
   virtual StoreRef Bind(Store store, Loc loc, SVal val) = 0;
 
 
   virtual StoreRef BindDefault(Store store, const MemRegion *R, SVal V);
   virtual StoreRef BindDefault(Store store, const MemRegion *R, SVal V);
-  virtual StoreRef Remove(Store St, Loc L) = 0;
+
+  /// \brief Create a new store with the specified binding removed.
+  ///
+  /// \brief \param ST the original store, that is the basis for the new store.
+  ///
+  /// \brief \param L the location whose binding should be removed.
+  virtual StoreRef killBinding(Store St, Loc L) = 0;
 
 
   /// \brief Create a new store that binds a value to a compound literal.
   /// \brief Create a new store that binds a value to a compound literal.
   ///
   ///

+ 1 - 1
lib/StaticAnalyzer/Checkers/CStringChecker.cpp

@@ -833,7 +833,7 @@ ProgramStateRef CStringChecker::InvalidateBuffer(CheckerContext &C,
   // If we have a non-region value by chance, just remove the binding.
   // If we have a non-region value by chance, just remove the binding.
   // FIXME: is this necessary or correct? This handles the non-Region
   // FIXME: is this necessary or correct? This handles the non-Region
   //  cases.  Is it ever valid to store to these?
   //  cases.  Is it ever valid to store to these?
-  return state->unbindLoc(*L);
+  return state->killBinding(*L);
 }
 }
 
 
 bool CStringChecker::SummarizeRegion(raw_ostream &os, ASTContext &Ctx,
 bool CStringChecker::SummarizeRegion(raw_ostream &os, ASTContext &Ctx,

+ 3 - 2
lib/StaticAnalyzer/Core/ProgramState.cpp

@@ -192,11 +192,12 @@ ProgramState::invalidateRegionsImpl(ArrayRef<const MemRegion *> Regions,
   return makeWithStore(newStore);
   return makeWithStore(newStore);
 }
 }
 
 
-ProgramStateRef ProgramState::unbindLoc(Loc LV) const {
+ProgramStateRef ProgramState::killBinding(Loc LV) const {
   assert(!isa<loc::MemRegionVal>(LV) && "Use invalidateRegion instead.");
   assert(!isa<loc::MemRegionVal>(LV) && "Use invalidateRegion instead.");
 
 
   Store OldStore = getStore();
   Store OldStore = getStore();
-  const StoreRef &newStore = getStateManager().StoreMgr->Remove(OldStore, LV);
+  const StoreRef &newStore =
+    getStateManager().StoreMgr->killBinding(OldStore, LV);
 
 
   if (newStore.getStore() == OldStore)
   if (newStore.getStore() == OldStore)
     return this;
     return this;

+ 11 - 6
lib/StaticAnalyzer/Core/RegionStore.cpp

@@ -244,7 +244,7 @@ public:   // Made public for helper classes.
 
 
   RegionBindings removeBinding(RegionBindings B, BindingKey K);
   RegionBindings removeBinding(RegionBindings B, BindingKey K);
   RegionBindings removeBinding(RegionBindings B, const MemRegion *R,
   RegionBindings removeBinding(RegionBindings B, const MemRegion *R,
-                        BindingKey::Kind k);
+                               BindingKey::Kind k);
 
 
   RegionBindings removeBinding(RegionBindings B, const MemRegion *R) {
   RegionBindings removeBinding(RegionBindings B, const MemRegion *R) {
     return removeBinding(removeBinding(B, R, BindingKey::Direct), R,
     return removeBinding(removeBinding(B, R, BindingKey::Direct), R,
@@ -292,7 +292,12 @@ public: // Part of public interface to class.
   /// as a Default binding.
   /// as a Default binding.
   StoreRef BindAggregate(Store store, const TypedRegion *R, SVal DefaultVal);
   StoreRef BindAggregate(Store store, const TypedRegion *R, SVal DefaultVal);
 
 
-  StoreRef Remove(Store store, Loc LV);
+  /// \brief Create a new store with the specified binding removed.
+  ///
+  /// \brief \param ST the original store, that is the basis for the new store.
+  ///
+  /// \brief \param L the location whose binding should be removed.
+  StoreRef killBinding(Store ST, Loc LV);
 
 
   void incrementReferenceCount(Store store) {
   void incrementReferenceCount(Store store) {
     GetRegionBindings(store).manualRetain();    
     GetRegionBindings(store).manualRetain();    
@@ -1540,14 +1545,14 @@ bool RegionStoreManager::includedInBindings(Store store,
 // Binding values to regions.
 // Binding values to regions.
 //===----------------------------------------------------------------------===//
 //===----------------------------------------------------------------------===//
 
 
-StoreRef RegionStoreManager::Remove(Store store, Loc L) {
+StoreRef RegionStoreManager::killBinding(Store ST, Loc L) {
   if (isa<loc::MemRegionVal>(L))
   if (isa<loc::MemRegionVal>(L))
     if (const MemRegion* R = cast<loc::MemRegionVal>(L).getRegion())
     if (const MemRegion* R = cast<loc::MemRegionVal>(L).getRegion())
-      return StoreRef(removeBinding(GetRegionBindings(store),
+      return StoreRef(removeBinding(GetRegionBindings(ST),
                                     R).getRootWithoutRetain(),
                                     R).getRootWithoutRetain(),
                       *this);
                       *this);
 
 
-  return StoreRef(store, *this);
+  return StoreRef(ST, *this);
 }
 }
 
 
 StoreRef RegionStoreManager::Bind(Store store, Loc L, SVal V) {
 StoreRef RegionStoreManager::Bind(Store store, Loc L, SVal V) {
@@ -1852,7 +1857,7 @@ RegionBindings RegionStoreManager::removeBinding(RegionBindings B,
 
 
 RegionBindings RegionStoreManager::removeBinding(RegionBindings B,
 RegionBindings RegionStoreManager::removeBinding(RegionBindings B,
                                                  const MemRegion *R,
                                                  const MemRegion *R,
-                                                BindingKey::Kind k){
+                                                 BindingKey::Kind k){
   return removeBinding(B, BindingKey::Make(R, k));
   return removeBinding(B, BindingKey::Make(R, k));
 }
 }