From 0541d106eae48f4238097df03a72028a610e0dce Mon Sep 17 00:00:00 2001 From: Zhongxing Xu Date: Thu, 25 Mar 2010 01:39:39 +0000 Subject: [PATCH] Add methods to remove a GDM entry. 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 | 12 ++++++++++++ lib/Checker/GRExprEngine.cpp | 2 +- lib/Checker/GRState.cpp | 12 ++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/include/clang/Checker/PathSensitive/GRState.h b/include/clang/Checker/PathSensitive/GRState.h index 657266b750..04ff424255 100644 --- a/include/clang/Checker/PathSensitive/GRState.h +++ b/include/clang/Checker/PathSensitive/GRState.h @@ -302,6 +302,8 @@ public: template const GRState *remove(typename GRStateTrait::key_type K, typename GRStateTrait::context_type C) const; + template + const GRState *remove() const; template const GRState *set(typename GRStateTrait::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::MakeVoidPtr(GRStateTrait::Remove(st->get(), K, C))); } + template + const GRState *remove(const GRState *st) { + return removeGDM(st, GRStateTrait::GDMIndex()); + } void* FindGDMContext(void* index, void* (*CreateContext)(llvm::BumpPtrAllocator&), @@ -702,6 +709,11 @@ const GRState *GRState::remove(typename GRStateTrait::key_type K, return getStateManager().remove(this, K, C); } +template +const GRState *GRState::remove() const { + return getStateManager().remove(this); +} + template const GRState *GRState::set(typename GRStateTrait::data_type D) const { return getStateManager().set(this, D); diff --git a/lib/Checker/GRExprEngine.cpp b/lib/Checker/GRExprEngine.cpp index b5521859d1..6a8466d1d7 100644 --- a/lib/Checker/GRExprEngine.cpp +++ b/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(0); + state = state->remove(); } // Bind the constructed object value to CXXConstructExpr. diff --git a/lib/Checker/GRState.cpp b/lib/Checker/GRState.cpp index 2defbcd93c..f2952bc9be 100644 --- a/lib/Checker/GRState.cpp +++ b/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. //===----------------------------------------------------------------------===// -- 2.40.0