From: Ted Kremenek Date: Tue, 12 Aug 2008 21:49:24 +0000 (+0000) Subject: Added GenericDataMap as a component of ValueState. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=450202284e7e0a1758be935ee6ae1296cc9dc97d;p=clang Added GenericDataMap as a component of ValueState. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54704 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Analysis/PathSensitive/ValueState.h b/include/clang/Analysis/PathSensitive/ValueState.h index 46f62e12eb..8566c252c6 100644 --- a/include/clang/Analysis/PathSensitive/ValueState.h +++ b/include/clang/Analysis/PathSensitive/ValueState.h @@ -55,6 +55,7 @@ class ValueState : public llvm::FoldingSetNode { public: // Typedefs. typedef llvm::ImmutableSet IntSetTy; + typedef llvm::ImmutableMap GenericDataMap; typedef llvm::ImmutableMap ConstNotEqTy; typedef llvm::ImmutableMap ConstEqTy; @@ -70,6 +71,7 @@ private: // FIXME: Make these private. public: + GenericDataMap GDM; ConstNotEqTy ConstNotEq; ConstEqTy ConstEq; void* CheckerState; @@ -77,10 +79,11 @@ public: public: /// This ctor is used when creating the first ValueState object. - ValueState(const Environment& env, Store st, + ValueState(const Environment& env, Store st, GenericDataMap gdm, ConstNotEqTy CNE, ConstEqTy CE) : Env(env), St(st), + GDM(gdm), ConstNotEq(CNE), ConstEq(CE), CheckerState(NULL) {} @@ -91,6 +94,7 @@ public: : llvm::FoldingSetNode(), Env(RHS.Env), St(RHS.St), + GDM(RHS.GDM), ConstNotEq(RHS.ConstNotEq), ConstEq(RHS.ConstEq), CheckerState(RHS.CheckerState) {} @@ -103,11 +107,15 @@ public: /// is a mapping from locations to values. Store getStore() const { return St; } + /// getGDM - Return the generic data map associated with this state. + GenericDataMap getGDM() const { return GDM; } + /// Profile - Profile the contents of a ValueState object for use /// in a FoldingSet. static void Profile(llvm::FoldingSetNodeID& ID, const ValueState* V) { V->Env.Profile(ID); ID.AddPointer(V->St); + V->GDM.Profile(ID); V->ConstNotEq.Profile(ID); V->ConstEq.Profile(ID); ID.AddPointer(V->CheckerState); @@ -228,6 +236,7 @@ private: EnvironmentManager EnvMgr; llvm::OwningPtr StMgr; ValueState::IntSetTy::Factory ISetFactory; + ValueState::GenericDataMap::Factory GDMFactory; ValueState::ConstNotEqTy::Factory CNEFactory; ValueState::ConstEqTy::Factory CEFactory; @@ -276,6 +285,7 @@ public: : EnvMgr(alloc), StMgr(stmgr), ISetFactory(alloc), + GDMFactory(alloc), CNEFactory(alloc), CEFactory(alloc), BasicVals(Ctx, alloc), @@ -338,9 +348,21 @@ public: return SetRVal(St, Ex, V, isBlkExpr, true); } + + // Methods that manipulate the GDM. + const ValueState* addGDM(const ValueState* St, void* Key, void* Data) { + ValueState::GenericDataMap M1 = St->getGDM(); + ValueState::GenericDataMap M2 = GDMFactory.Add(M2, Key, Data); + + if (M1 == M2) + return St; + + ValueState NewSt = *St; + NewSt.GDM = M2; + return getPersistentState(NewSt); + } // Methods that query & manipulate the Store. - RVal GetRVal(const ValueState* St, LVal LV, QualType T = QualType()) { return StMgr->GetRVal(St->getStore(), LV, T); } diff --git a/lib/Analysis/ValueState.cpp b/lib/Analysis/ValueState.cpp index ffc4c28f2c..55e5b4a78d 100644 --- a/lib/Analysis/ValueState.cpp +++ b/lib/Analysis/ValueState.cpp @@ -180,6 +180,7 @@ const ValueState* ValueStateManager::getInitialState() { ValueState StateImpl(EnvMgr.getInitialEnvironment(), StMgr->getInitialStore(), + GDMFactory.GetEmptyMap(), CNEFactory.GetEmptyMap(), CEFactory.GetEmptyMap());