[cfe-commits] r99470 - in /cfe/trunk: include/clang/Checker/PathSensitive/GRState.h lib/Checker/GRExprEngine.cpp lib/Checker/GRState.cpp

Zhongxing Xu xuzhongxing at gmail.com
Wed Mar 24 18:39:39 PDT 2010


Author: zhongxingxu
Date: Wed Mar 24 20:39:39 2010
New Revision: 99470

URL: http://llvm.org/viewvc/llvm-project?rev=99470&view=rev
Log:
Add methods to remove a GDM entry.
Instead of setting the ReturnExpr GDM to NULL, remove it.

Modified:
    cfe/trunk/include/clang/Checker/PathSensitive/GRState.h
    cfe/trunk/lib/Checker/GRExprEngine.cpp
    cfe/trunk/lib/Checker/GRState.cpp

Modified: cfe/trunk/include/clang/Checker/PathSensitive/GRState.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/GRState.h?rev=99470&r1=99469&r2=99470&view=diff
==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/GRState.h (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/GRState.h Wed Mar 24 20:39:39 2010
@@ -302,6 +302,8 @@
   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 @@
 
   // 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 @@
      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 @@
   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);

Modified: cfe/trunk/lib/Checker/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/GRExprEngine.cpp?rev=99470&r1=99469&r2=99470&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Checker/GRExprEngine.cpp Wed Mar 24 20:39:39 2010
@@ -1330,7 +1330,7 @@
     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.

Modified: cfe/trunk/lib/Checker/GRState.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/GRState.cpp?rev=99470&r1=99469&r2=99470&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/GRState.cpp (original)
+++ cfe/trunk/lib/Checker/GRState.cpp Wed Mar 24 20:39:39 2010
@@ -227,6 +227,18 @@
   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.
 //===----------------------------------------------------------------------===//





More information about the cfe-commits mailing list