]> granicus.if.org Git - clang/commitdiff
Add methods to remove a GDM entry.
authorZhongxing Xu <xuzhongxing@gmail.com>
Thu, 25 Mar 2010 01:39:39 +0000 (01:39 +0000)
committerZhongxing Xu <xuzhongxing@gmail.com>
Thu, 25 Mar 2010 01:39:39 +0000 (01:39 +0000)
Instead of setting the ReturnExpr GDM to NULL, remove it.

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

include/clang/Checker/PathSensitive/GRState.h
lib/Checker/GRExprEngine.cpp
lib/Checker/GRState.cpp

index 657266b7508dc2f64b7b040f7866563669ef59c5..04ff424255e732cb9f55840417daf22b452f0fdc 100644 (file)
@@ -302,6 +302,8 @@ public:
   template<typename T>
   const GRState *remove(typename GRStateTrait<T>::key_type K,
                         typename GRStateTrait<T>::context_type C) const;
+  template <typename T>
+  const GRState *remove() const;
 
   template<typename T>
   const GRState *set(typename GRStateTrait<T>::data_type D) const;
@@ -464,6 +466,7 @@ public:
 
   // Methods that manipulate the GDM.
   const GRState* addGDM(const GRState* St, void* Key, void* Data);
+  const GRState *removeGDM(const GRState *state, void *Key);
 
   // Methods that query & manipulate the Store.
 
@@ -528,6 +531,10 @@ public:
      GRStateTrait<T>::MakeVoidPtr(GRStateTrait<T>::Remove(st->get<T>(), K, C)));
   }
 
+  template <typename T>
+  const GRState *remove(const GRState *st) {
+    return removeGDM(st, GRStateTrait<T>::GDMIndex());
+  }
 
   void* FindGDMContext(void* index,
                        void* (*CreateContext)(llvm::BumpPtrAllocator&),
@@ -702,6 +709,11 @@ const GRState *GRState::remove(typename GRStateTrait<T>::key_type K,
   return getStateManager().remove<T>(this, K, C);
 }
 
+template <typename T>
+const GRState *GRState::remove() const {
+  return getStateManager().remove<T>(this);
+}
+
 template<typename T>
 const GRState *GRState::set(typename GRStateTrait<T>::data_type D) const {
   return getStateManager().set<T>(this, D);
index b5521859d1789314bb30031161bad6d0374595ec..6a8466d1d7b0a2ffb60c87de1bcd7fb1366d4dfb 100644 (file)
@@ -1330,7 +1330,7 @@ void GRExprEngine::ProcessCallExit(GRCallExitNodeBuilder &B) {
     SVal RetVal = state->getSVal(ReturnedExpr);
     state = state->BindExpr(CE, RetVal);
     // Clear the return expr GDM.
-    state = state->set<ReturnExpr>(0);
+    state = state->remove<ReturnExpr>();
   }
 
   // Bind the constructed object value to CXXConstructExpr.
index 2defbcd93c01b4a229cfdbd585ca4db8fa0b8307..f2952bc9bead3c2ad016a1f54f26ca75d57cdf84 100644 (file)
@@ -227,6 +227,18 @@ const GRState* GRStateManager::addGDM(const GRState* St, void* Key, void* Data){
   return getPersistentState(NewSt);
 }
 
+const GRState *GRStateManager::removeGDM(const GRState *state, void *Key) {
+  GRState::GenericDataMap OldM = state->getGDM();
+  GRState::GenericDataMap NewM = GDMFactory.Remove(OldM, Key);
+
+  if (NewM == OldM)
+    return state;
+
+  GRState NewState = *state;
+  NewState.GDM = NewM;
+  return getPersistentState(NewState);
+}
+
 //===----------------------------------------------------------------------===//
 // Utility.
 //===----------------------------------------------------------------------===//