summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2010-03-25 01:39:39 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2010-03-25 01:39:39 +0000
commitb6e1c13c36b17590108e91e4b414a3e68d6a049f (patch)
treed3de66b2d024a5664716bf9c45b27ae3bb3a5434 /clang
parent563fe3cc12054dd04abcbc911e8128584a2e33df (diff)
downloadbcm5719-llvm-b6e1c13c36b17590108e91e4b414a3e68d6a049f.tar.gz
bcm5719-llvm-b6e1c13c36b17590108e91e4b414a3e68d6a049f.zip
Add methods to remove a GDM entry.
Instead of setting the ReturnExpr GDM to NULL, remove it. llvm-svn: 99470
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/Checker/PathSensitive/GRState.h12
-rw-r--r--clang/lib/Checker/GRExprEngine.cpp2
-rw-r--r--clang/lib/Checker/GRState.cpp12
3 files changed, 25 insertions, 1 deletions
diff --git a/clang/include/clang/Checker/PathSensitive/GRState.h b/clang/include/clang/Checker/PathSensitive/GRState.h
index 657266b7508..04ff424255e 100644
--- a/clang/include/clang/Checker/PathSensitive/GRState.h
+++ b/clang/include/clang/Checker/PathSensitive/GRState.h
@@ -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);
diff --git a/clang/lib/Checker/GRExprEngine.cpp b/clang/lib/Checker/GRExprEngine.cpp
index b5521859d17..6a8466d1d7b 100644
--- a/clang/lib/Checker/GRExprEngine.cpp
+++ b/clang/lib/Checker/GRExprEngine.cpp
@@ -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.
diff --git a/clang/lib/Checker/GRState.cpp b/clang/lib/Checker/GRState.cpp
index 2defbcd93c0..f2952bc9bea 100644
--- a/clang/lib/Checker/GRState.cpp
+++ b/clang/lib/Checker/GRState.cpp
@@ -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.
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud