// Typedefs.
typedef llvm::ImmutableSet<llvm::APSInt*> IntSetTy;
typedef llvm::ImmutableMap<void*, void*> GenericDataMap;
- typedef llvm::ImmutableMap<SymbolID,const llvm::APSInt*> ConstEqTy;
typedef GRStateManager ManagerTy;
// FIXME: Make these private.
public:
GenericDataMap GDM;
- ConstEqTy ConstEq;
public:
/// This ctor is used when creating the first GRState object.
- GRState(const Environment& env, Store st, GenericDataMap gdm, ConstEqTy CE)
+ GRState(const Environment& env, Store st, GenericDataMap gdm)
: Env(env),
St(st),
- GDM(gdm),
- ConstEq(CE) {}
+ GDM(gdm) {}
/// Copy ctor - We must explicitly define this or else the "Next" ptr
/// in FoldingSetNode will also get copied.
: llvm::FoldingSetNode(),
Env(RHS.Env),
St(RHS.St),
- GDM(RHS.GDM),
- ConstEq(RHS.ConstEq) {}
+ GDM(RHS.GDM) {}
/// getEnvironment - Return the environment associated with this state.
/// The environment is the mapping from expressions to values.
V->Env.Profile(ID);
ID.AddPointer(V->St);
V->GDM.Profile(ID);
- V->ConstEq.Profile(ID);
}
/// Profile - Used to profile the contents of this object for inclusion
typedef llvm::DenseMap<void*,std::pair<void*,void (*)(void*)> > GDMContextsTy;
GDMContextsTy GDMContexts;
-
- // FIXME: Refactor these elsewhere.
- GRState::ConstEqTy::Factory CEFactory;
-
+
/// Printers - A set of printer objects used for pretty-printing a GRState.
/// GRStateManager owns these objects.
std::vector<GRState::Printer*> Printers;
StMgr(stmgr),
ISetFactory(alloc),
GDMFactory(alloc),
- CEFactory(alloc),
BasicVals(Ctx, alloc),
SymMgr(alloc),
Alloc(alloc),
//===----------------------------------------------------------------------===//
typedef llvm::ImmutableMap<SymbolID,GRState::IntSetTy> ConstNotEqTy;
+typedef llvm::ImmutableMap<SymbolID,const llvm::APSInt*> ConstEqTy;
+static int ConstEqTyIndex = 0;
static int ConstNotEqTyIndex = 0;
namespace clang {
struct GRStateTrait<ConstNotEqTy> : public GRStatePartialTrait<ConstNotEqTy> {
static inline void* GDMIndex() { return &ConstNotEqTyIndex; }
};
+
+ template<>
+ struct GRStateTrait<ConstEqTy> : public GRStatePartialTrait<ConstEqTy> {
+ static inline void* GDMIndex() { return &ConstEqTyIndex; }
+ };
}
bool GRState::isNotEqual(SymbolID sym, const llvm::APSInt& V) const {
}
bool GRState::isEqual(SymbolID sym, const llvm::APSInt& V) const {
-
// Retrieve the EQ-set associated with the given symbol.
- const ConstEqTy::data_type* T = ConstEq.lookup(sym);
-
+ const ConstEqTy::data_type* T = get<ConstEqTy>(sym);
// See if V is present in the EQ-set.
return T ? **T == V : false;
}
const llvm::APSInt* GRState::getSymVal(SymbolID sym) const {
- ConstEqTy::data_type* T = ConstEq.lookup(sym);
+ const ConstEqTy::data_type* T = get<ConstEqTy>(sym);
return T ? *T : NULL;
}
NewSt.St = StMgr->RemoveDeadBindings(St->getStore(), Loc, Liveness, DRoots,
LSymbols, DSymbols);
+
+ GRStateRef state(getPersistentState(NewSt), *this);
+
// Remove the dead symbols from the symbol tracker.
// FIXME: Refactor into something else that manages symbol values.
- for (GRState::ConstEqTy::iterator I = St->ConstEq.begin(),
- E=St->ConstEq.end(); I!=E; ++I) {
- SymbolID sym = I.getKey();
-
+ ConstEqTy CE = state.get<ConstEqTy>();
+ ConstEqTy::Factory& CEFactory = state.get_context<ConstEqTy>();
+
+ for (ConstEqTy::iterator I = CE.begin(), E = CE.end(); I!=E; ++I) {
+ SymbolID sym = I.getKey();
if (!LSymbols.count(sym)) {
DSymbols.insert(sym);
- NewSt.ConstEq = CEFactory.Remove(NewSt.ConstEq, sym);
+ CE = CEFactory.Remove(CE, sym);
}
}
- GRStateRef state(getPersistentState(NewSt), *this);
ConstNotEqTy CNE = state.get<ConstNotEqTy>();
ConstNotEqTy::Factory& CNEFactory = state.get_context<ConstNotEqTy>();
const GRState* GRStateManager::AddEQ(const GRState* St, SymbolID sym,
const llvm::APSInt& V) {
-
// Create a new state with the old binding replaced.
- GRState NewSt = *St;
- NewSt.ConstEq = CEFactory.Add(NewSt.ConstEq, sym, &V);
-
- // Get the persistent copy.
- return getPersistentState(NewSt);
+ GRStateRef state(St, *this);
+ return state.set<ConstEqTy>(sym, &V);
}
const GRState* GRStateManager::getInitialState() {
GRState StateImpl(EnvMgr.getInitialEnvironment(), StMgr->getInitialStore(),
- GDMFactory.GetEmptyMap(),
- CEFactory.GetEmptyMap());
+ GDMFactory.GetEmptyMap());
return getPersistentState(StateImpl);
}
// Print equality constraints.
// FIXME: Make just another printer do this.
-
- if (!ConstEq.isEmpty()) {
-
+ ConstEqTy CE = get<ConstEqTy>();
+
+ if (!CE.isEmpty()) {
Out << nl << sep << "'==' constraints:";
-
- for (ConstEqTy::iterator I = ConstEq.begin(),
- E = ConstEq.end(); I!=E; ++I) {
-
+
+ for (ConstEqTy::iterator I = CE.begin(), E = CE.end(); I!=E; ++I)
Out << nl << " $" << I.getKey()
<< " : " << I.getData()->toString();
- }
}
// Print != constraints.
ConstNotEqTy CNE = get<ConstNotEqTy>();
if (!CNE.isEmpty()) {
-
Out << nl << sep << "'!=' constraints:";
for (ConstNotEqTy::iterator I = CNE.begin(), EI = CNE.end(); I!=EI; ++I) {