From: Ted Kremenek Date: Mon, 26 Jan 2009 06:04:53 +0000 (+0000) Subject: Use tag classes instead of typedefs for GDM entries 'ConstNotEq' and 'ConstEq'. ... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8ee74d50501f66c55b68e2b9cb2ab75b9690eb7b;p=clang Use tag classes instead of typedefs for GDM entries 'ConstNotEq' and 'ConstEq'. This avoids collisions in the GDM. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63002 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/BasicConstraintManager.cpp b/lib/Analysis/BasicConstraintManager.cpp index c875691167..7496c5f5aa 100644 --- a/lib/Analysis/BasicConstraintManager.cpp +++ b/lib/Analysis/BasicConstraintManager.cpp @@ -21,11 +21,29 @@ using namespace clang; -namespace { + +namespace { class VISIBILITY_HIDDEN ConstNotEq {}; } +namespace { class VISIBILITY_HIDDEN ConstEq {}; } typedef llvm::ImmutableMap ConstNotEqTy; typedef llvm::ImmutableMap ConstEqTy; + +static int ConstEqIndex = 0; +static int ConstNotEqIndex = 0; +namespace clang { +template<> +struct GRStateTrait : public GRStatePartialTrait { + static inline void* GDMIndex() { return &ConstNotEqIndex; } +}; + +template<> +struct GRStateTrait : public GRStatePartialTrait { + static inline void* GDMIndex() { return &ConstEqIndex; } +}; +} + +namespace { // BasicConstraintManager only tracks equality and inequality constraints of // constants and integer variables. class VISIBILITY_HIDDEN BasicConstraintManager : public ConstraintManager { @@ -437,26 +455,12 @@ BasicConstraintManager::AssumeInBound(const GRState* St, SVal Idx, return St; } -static int ConstEqTyIndex = 0; -static int ConstNotEqTyIndex = 0; - -namespace clang { - template<> - struct GRStateTrait : public GRStatePartialTrait { - static inline void* GDMIndex() { return &ConstNotEqTyIndex; } - }; - - template<> - struct GRStateTrait : public GRStatePartialTrait { - static inline void* GDMIndex() { return &ConstEqTyIndex; } - }; -} const GRState* BasicConstraintManager::AddEQ(const GRState* St, SymbolRef sym, const llvm::APSInt& V) { // Create a new state with the old binding replaced. GRStateRef state(St, StateMgr); - return state.set(sym, &V); + return state.set(sym, &V); } const GRState* BasicConstraintManager::AddNE(const GRState* St, SymbolRef sym, @@ -465,7 +469,7 @@ const GRState* BasicConstraintManager::AddNE(const GRState* St, SymbolRef sym, GRStateRef state(St, StateMgr); // First, retrieve the NE-set associated with the given symbol. - ConstNotEqTy::data_type* T = state.get(sym); + ConstNotEqTy::data_type* T = state.get(sym); GRState::IntSetTy S = T ? *T : ISetFactory.GetEmptySet(); @@ -473,12 +477,12 @@ const GRState* BasicConstraintManager::AddNE(const GRState* St, SymbolRef sym, S = ISetFactory.Add(S, &V); // Create a new state with the old binding replaced. - return state.set(sym, S); + return state.set(sym, S); } const llvm::APSInt* BasicConstraintManager::getSymVal(const GRState* St, SymbolRef sym) { - const ConstEqTy::data_type* T = St->get(sym); + const ConstEqTy::data_type* T = St->get(sym); return T ? *T : NULL; } @@ -486,7 +490,7 @@ bool BasicConstraintManager::isNotEqual(const GRState* St, SymbolRef sym, const llvm::APSInt& V) const { // Retrieve the NE-set associated with the given symbol. - const ConstNotEqTy::data_type* T = St->get(sym); + const ConstNotEqTy::data_type* T = St->get(sym); // See if V is present in the NE-set. return T ? T->contains(&V) : false; @@ -495,7 +499,7 @@ bool BasicConstraintManager::isNotEqual(const GRState* St, SymbolRef sym, bool BasicConstraintManager::isEqual(const GRState* St, SymbolRef sym, const llvm::APSInt& V) const { // Retrieve the EQ-set associated with the given symbol. - const ConstEqTy::data_type* T = St->get(sym); + const ConstEqTy::data_type* T = St->get(sym); // See if V is present in the EQ-set. return T ? **T == V : false; } @@ -507,31 +511,31 @@ BasicConstraintManager::RemoveDeadBindings(const GRState* St, SymbolReaper& SymReaper) { GRStateRef state(St, StateMgr); - ConstEqTy CE = state.get(); - ConstEqTy::Factory& CEFactory = state.get_context(); + ConstEqTy CE = state.get(); + ConstEqTy::Factory& CEFactory = state.get_context(); for (ConstEqTy::iterator I = CE.begin(), E = CE.end(); I!=E; ++I) { SymbolRef sym = I.getKey(); if (SymReaper.maybeDead(sym)) CE = CEFactory.Remove(CE, sym); } - state = state.set(CE); + state = state.set(CE); - ConstNotEqTy CNE = state.get(); - ConstNotEqTy::Factory& CNEFactory = state.get_context(); + ConstNotEqTy CNE = state.get(); + ConstNotEqTy::Factory& CNEFactory = state.get_context(); for (ConstNotEqTy::iterator I = CNE.begin(), E = CNE.end(); I != E; ++I) { SymbolRef sym = I.getKey(); if (SymReaper.maybeDead(sym)) CNE = CNEFactory.Remove(CNE, sym); } - return state.set(CNE); + return state.set(CNE); } void BasicConstraintManager::print(const GRState* St, std::ostream& Out, const char* nl, const char *sep) { // Print equality constraints. - ConstEqTy CE = St->get(); + ConstEqTy CE = St->get(); if (!CE.isEmpty()) { Out << nl << sep << "'==' constraints:"; @@ -545,7 +549,7 @@ void BasicConstraintManager::print(const GRState* St, std::ostream& Out, // Print != constraints. - ConstNotEqTy CNE = St->get(); + ConstNotEqTy CNE = St->get(); if (!CNE.isEmpty()) { Out << nl << sep << "'!=' constraints:";