[cfe-commits] r47714 - in /cfe/trunk: Analysis/GRExprEngine.cpp Analysis/GRSimpleVals.cpp Analysis/GRSimpleVals.h Analysis/ValueState.cpp include/clang/Analysis/PathSensitive/ExplodedGraph.h include/clang/Analysis/PathSensitive/GRExprEngine.h include/clang/Analysis/PathSensitive/GRTransferFuncs.h include/clang/Analysis/PathSensitive/ValueState.h
Ted Kremenek
kremenek at apple.com
Thu Feb 28 02:21:52 PST 2008
Author: kremenek
Date: Thu Feb 28 04:21:43 2008
New Revision: 47714
URL: http://llvm.org/viewvc/llvm-project?rev=47714&view=rev
Log:
Merged ValueState and ValueStateImpl into just ValueState, with GRExprEngine::StateTy just becoming ValueState*.
Modified:
cfe/trunk/Analysis/GRExprEngine.cpp
cfe/trunk/Analysis/GRSimpleVals.cpp
cfe/trunk/Analysis/GRSimpleVals.h
cfe/trunk/Analysis/ValueState.cpp
cfe/trunk/include/clang/Analysis/PathSensitive/ExplodedGraph.h
cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h
cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
cfe/trunk/include/clang/Analysis/PathSensitive/ValueState.h
Modified: cfe/trunk/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/GRExprEngine.cpp?rev=47714&r1=47713&r2=47714&view=diff
==============================================================================
--- cfe/trunk/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/Analysis/GRExprEngine.cpp Thu Feb 28 04:21:43 2008
@@ -26,7 +26,7 @@
using llvm::cast;
using llvm::APSInt;
-GRExprEngine::StateTy GRExprEngine::getInitialState() {
+ValueState* GRExprEngine::getInitialState() {
// The LiveVariables information already has a compilation of all VarDecls
// used in the function. Iterate through this set, and "symbolicate"
@@ -35,7 +35,7 @@
typedef LiveVariables::AnalysisDataTy LVDataTy;
LVDataTy& D = Liveness.getAnalysisData();
- ValueStateImpl StateImpl = *StateMgr.getInitialState().getImpl();
+ ValueState StateImpl = *StateMgr.getInitialState();
for (LVDataTy::decl_iterator I=D.begin_decl(), E=D.end_decl(); I != E; ++I) {
@@ -50,8 +50,7 @@
return StateMgr.getPersistentState(StateImpl);
}
-GRExprEngine::StateTy
-GRExprEngine::SetRVal(StateTy St, Expr* Ex, const RVal& V) {
+ValueState* GRExprEngine::SetRVal(ValueState* St, Expr* Ex, RVal V) {
if (!StateCleaned) {
St = RemoveDeadBindings(CurrentStmt, St);
@@ -70,9 +69,10 @@
return StateMgr.SetRVal(St, Ex, V, isBlkExpr, false);
}
-const GRExprEngine::StateTy::BufferTy&
-GRExprEngine::SetRVal(StateTy St, Expr* Ex, const RVal::BufferTy& RB,
- StateTy::BufferTy& RetBuf) {
+#if 0
+const ValueState::BufferTy&
+GRExprEngine::SetRVal(ValueState* St, Expr* Ex, const RVal::BufferTy& RB,
+ ValueState::BufferTy& RetBuf) {
assert (RetBuf.empty());
@@ -81,9 +81,9 @@
return RetBuf;
}
+#endif
-GRExprEngine::StateTy
-GRExprEngine::SetRVal(StateTy St, const LVal& LV, const RVal& RV) {
+ValueState* GRExprEngine::SetRVal(ValueState* St, LVal LV, RVal RV) {
if (!StateCleaned) {
St = RemoveDeadBindings(CurrentStmt, St);
@@ -93,8 +93,8 @@
return StateMgr.SetRVal(St, LV, RV);
}
-GRExprEngine::StateTy
-GRExprEngine::MarkBranch(StateTy St, Stmt* Terminator, bool branchTaken) {
+ValueState* GRExprEngine::MarkBranch(ValueState* St, Stmt* Terminator,
+ bool branchTaken) {
switch (Terminator->getStmtClass()) {
default:
@@ -151,7 +151,7 @@
BranchNodeBuilder& builder) {
// Remove old bindings for subexpressions.
- StateTy PrevState = StateMgr.RemoveSubExprBindings(builder.getState());
+ ValueState* PrevState = StateMgr.RemoveSubExprBindings(builder.getState());
// Check for NULL conditions; e.g. "for(;;)"
if (!Condition) {
@@ -204,7 +204,7 @@
bool isFeasible = true;
- StateTy St = Assume(PrevState, V, true, isFeasible);
+ ValueState* St = Assume(PrevState, V, true, isFeasible);
if (isFeasible)
builder.generateNode(MarkBranch(St, Term, true), true);
@@ -224,7 +224,7 @@
bool isFeasible = false;
- StateTy St = Assume(PrevState, V, false, isFeasible);
+ ValueState* St = Assume(PrevState, V, false, isFeasible);
if (isFeasible)
builder.generateNode(MarkBranch(St, Term, false), false);
@@ -239,7 +239,7 @@
/// nodes by processing the 'effects' of a computed goto jump.
void GRExprEngine::ProcessIndirectGoto(IndirectGotoNodeBuilder& builder) {
- StateTy St = builder.getState();
+ ValueState* St = builder.getState();
RVal V = GetRVal(St, builder.getTarget());
// Three possibilities:
@@ -286,7 +286,7 @@
typedef SwitchNodeBuilder::iterator iterator;
- StateTy St = builder.getState();
+ ValueState* St = builder.getState();
Expr* CondE = builder.getCondition();
RVal CondV = GetRVal(St, CondE);
@@ -296,7 +296,7 @@
return;
}
- StateTy DefaultSt = St;
+ ValueState* DefaultSt = St;
// While most of this can be assumed (such as the signedness), having it
// just computed makes sure everything makes the same assumptions end-to-end.
@@ -342,7 +342,7 @@
// Now "assume" that the case matches.
bool isFeasible = false;
- StateTy StNew = Assume(St, Res, true, isFeasible);
+ ValueState* StNew = Assume(St, Res, true, isFeasible);
if (isFeasible) {
builder.generateCaseStmtNode(I, StNew);
@@ -382,7 +382,7 @@
assert (B == CurrentStmt && getCFG().isBlkExpr(B));
- StateTy St = Pred->getState();
+ ValueState* St = Pred->getState();
RVal X = GetBlkExprRVal(St, B);
assert (X.isUndef());
@@ -410,7 +410,7 @@
// the payoff is not likely to be large. Instead, we do eager evaluation.
bool isFeasible = false;
- StateTy NewState = Assume(St, X, true, isFeasible);
+ ValueState* NewState = Assume(St, X, true, isFeasible);
if (isFeasible)
Nodify(Dst, B, Pred, SetBlkExprRVal(NewState, B, MakeConstantVal(1U, B)));
@@ -446,7 +446,7 @@
// dead mappings removed.
if (Dst.size() == 1 && *Dst.begin() == StmtEntryNode) {
- StateTy St = RemoveDeadBindings(S, StmtEntryNode->getState());
+ ValueState* St = RemoveDeadBindings(S, StmtEntryNode->getState());
builder.generateNode(S, St, StmtEntryNode);
}
@@ -458,7 +458,7 @@
}
GRExprEngine::NodeTy*
-GRExprEngine::Nodify(NodeSet& Dst, Stmt* S, NodeTy* Pred, StateTy St) {
+GRExprEngine::Nodify(NodeSet& Dst, Stmt* S, NodeTy* Pred, ValueState* St) {
// If the state hasn't changed, don't generate a new node.
if (St == Pred->getState())
@@ -470,12 +470,14 @@
return N;
}
+#if 0
void GRExprEngine::Nodify(NodeSet& Dst, Stmt* S, NodeTy* Pred,
- const StateTy::BufferTy& SB) {
+ const ValueState::BufferTy& SB) {
- for (StateTy::BufferTy::const_iterator I=SB.begin(), E=SB.end(); I!=E; ++I)
+ for (ValueState::BufferTy::const_iterator I=SB.begin(), E=SB.end(); I!=E; ++I)
Nodify(Dst, S, Pred, *I);
}
+#endif
void GRExprEngine::VisitDeclRefExpr(DeclRefExpr* D, NodeTy* Pred, NodeSet& Dst){
@@ -487,7 +489,7 @@
// If we are here, we are loading the value of the decl and binding
// it to the block-level expression.
- StateTy St = Pred->getState();
+ ValueState* St = Pred->getState();
Nodify(Dst, D, Pred, SetRVal(St, D, GetRVal(St, D)));
}
@@ -524,7 +526,7 @@
// Finally, evaluate the function call.
for (NodeSet::iterator DI = DstTmp.begin(), DE = DstTmp.end(); DI!=DE; ++DI) {
- StateTy St = (*DI)->getState();
+ ValueState* St = (*DI)->getState();
RVal L = GetLVal(St, Callee);
// Check for undefined control-flow.
@@ -589,7 +591,7 @@
for (NodeSet::iterator I1 = S1.begin(), E1 = S1.end(); I1 != E1; ++I1) {
NodeTy* N = *I1;
- StateTy St = N->getState();
+ ValueState* St = N->getState();
RVal V = GetRVal(St, Ex);
Nodify(Dst, CastE, N, SetRVal(St, CastE, EvalCast(V, CastE->getType())));
}
@@ -598,7 +600,7 @@
void GRExprEngine::VisitDeclStmt(DeclStmt* DS, GRExprEngine::NodeTy* Pred,
GRExprEngine::NodeSet& Dst) {
- StateTy St = Pred->getState();
+ ValueState* St = Pred->getState();
for (const ScopedDecl* D = DS->getDecl(); D; D = D->getNextDeclarator())
if (const VarDecl* VD = dyn_cast<VarDecl>(D)) {
@@ -638,7 +640,7 @@
assert (Ex == CurrentStmt && getCFG().isBlkExpr(Ex));
- StateTy St = Pred->getState();
+ ValueState* St = Pred->getState();
RVal X = GetBlkExprRVal(St, Ex);
assert (X.isUndef());
@@ -697,7 +699,7 @@
for (NodeSet::iterator I = DstTmp.begin(), DE = DstTmp.end(); I != DE; ++I) {
NodeTy* N = *I;
- StateTy St = N->getState();
+ ValueState* St = N->getState();
// FIXME: Bifurcate when dereferencing a symbolic with no constraints?
@@ -735,7 +737,7 @@
// "Assume" that the pointer is Not-NULL.
- StateTy StNotNull = Assume(St, LV, true, isFeasibleNotNull);
+ ValueState* StNotNull = Assume(St, LV, true, isFeasibleNotNull);
if (isFeasibleNotNull) {
@@ -750,7 +752,7 @@
// Now "assume" that the pointer is NULL.
- StateTy StNull = Assume(St, LV, false, isFeasibleNull);
+ ValueState* StNull = Assume(St, LV, false, isFeasibleNull);
if (isFeasibleNull) {
@@ -800,7 +802,7 @@
for (NodeSet::iterator I1 = S1.begin(), E1 = S1.end(); I1 != E1; ++I1) {
NodeTy* N1 = *I1;
- StateTy St = N1->getState();
+ ValueState* St = N1->getState();
RVal SubV = use_GetLVal ? GetLVal(St, U->getSubExpr()) :
GetRVal(St, U->getSubExpr());
@@ -907,7 +909,7 @@
SourceLocation Loc = U->getExprLoc();
uint64_t size = getContext().getTypeSize(T, Loc) / 8;
- StateTy St = Pred->getState();
+ ValueState* St = Pred->getState();
St = SetRVal(St, U, NonLVal::MakeVal(ValMgr, size, U->getType(), Loc));
Nodify(Dst, U, Pred, St);
@@ -975,7 +977,7 @@
for (NodeSet::iterator I2 = S2.begin(), E2 = S2.end(); I2 != E2; ++I2) {
NodeTy* N2 = *I2;
- StateTy St = N2->getState();
+ ValueState* St = N2->getState();
Expr* RHS = B->getRHS();
RVal RightV = GetRVal(St, RHS);
@@ -1004,7 +1006,7 @@
// First, "assume" that the denominator is 0 or undefined.
bool isFeasible = false;
- StateTy ZeroSt = Assume(St, RightV, false, isFeasible);
+ ValueState* ZeroSt = Assume(St, RightV, false, isFeasible);
if (isFeasible) {
NodeTy* DivZeroNode = Builder->generateNode(B, ZeroSt, N2);
@@ -1160,7 +1162,7 @@
// First, "assume" that the denominator is 0.
bool isFeasible = false;
- StateTy ZeroSt = Assume(St, RightV, false, isFeasible);
+ ValueState* ZeroSt = Assume(St, RightV, false, isFeasible);
if (isFeasible) {
NodeTy* DivZeroNode = Builder->generateNode(B, ZeroSt, N2);
@@ -1236,7 +1238,7 @@
break;
}
else if (B->getOpcode() == BinaryOperator::Comma) {
- StateTy St = Pred->getState();
+ ValueState* St = Pred->getState();
Nodify(Dst, B, Pred, SetRVal(St, B, GetRVal(St, B->getRHS())));
break;
}
@@ -1301,7 +1303,7 @@
case Stmt::StmtExprClass: {
StmtExpr* SE = cast<StmtExpr>(S);
- StateTy St = Pred->getState();
+ ValueState* St = Pred->getState();
Expr* LastExpr = cast<Expr>(*SE->getSubStmt()->body_rbegin());
Nodify(Dst, SE, Pred, SetRVal(St, SE, GetRVal(St, LastExpr)));
break;
@@ -1339,7 +1341,7 @@
// "Assume" logic.
//===----------------------------------------------------------------------===//
-GRExprEngine::StateTy GRExprEngine::Assume(StateTy St, LVal Cond,
+ValueState* GRExprEngine::Assume(ValueState* St, LVal Cond,
bool Assumption,
bool& isFeasible) {
switch (Cond.getSubKind()) {
@@ -1370,7 +1372,7 @@
}
}
-GRExprEngine::StateTy GRExprEngine::Assume(StateTy St, NonLVal Cond,
+ValueState* GRExprEngine::Assume(ValueState* St, NonLVal Cond,
bool Assumption,
bool& isFeasible) {
switch (Cond.getSubKind()) {
@@ -1405,18 +1407,18 @@
}
}
-GRExprEngine::StateTy
-GRExprEngine::AssumeSymNE(StateTy St, SymbolID sym,
+ValueState*
+GRExprEngine::AssumeSymNE(ValueState* St, SymbolID sym,
const llvm::APSInt& V, bool& isFeasible) {
// First, determine if sym == X, where X != V.
- if (const llvm::APSInt* X = St.getSymVal(sym)) {
+ if (const llvm::APSInt* X = St->getSymVal(sym)) {
isFeasible = *X != V;
return St;
}
// Second, determine if sym != V.
- if (St.isNotEqual(sym, V)) {
+ if (St->isNotEqual(sym, V)) {
isFeasible = true;
return St;
}
@@ -1428,18 +1430,18 @@
return StateMgr.AddNE(St, sym, V);
}
-GRExprEngine::StateTy
-GRExprEngine::AssumeSymEQ(StateTy St, SymbolID sym,
+ValueState*
+GRExprEngine::AssumeSymEQ(ValueState* St, SymbolID sym,
const llvm::APSInt& V, bool& isFeasible) {
// First, determine if sym == X, where X != V.
- if (const llvm::APSInt* X = St.getSymVal(sym)) {
+ if (const llvm::APSInt* X = St->getSymVal(sym)) {
isFeasible = *X == V;
return St;
}
// Second, determine if sym != V.
- if (St.isNotEqual(sym, V)) {
+ if (St->isNotEqual(sym, V)) {
isFeasible = false;
return St;
}
@@ -1451,8 +1453,8 @@
return StateMgr.AddEQ(St, sym, V);
}
-GRExprEngine::StateTy
-GRExprEngine::AssumeSymInt(StateTy St, bool Assumption,
+ValueState*
+GRExprEngine::AssumeSymInt(ValueState* St, bool Assumption,
const SymIntConstraint& C, bool& isFeasible) {
switch (C.getOpcode()) {
@@ -1486,14 +1488,13 @@
struct VISIBILITY_HIDDEN DOTGraphTraits<GRExprEngine::NodeTy*> :
public DefaultDOTGraphTraits {
- static void PrintVarBindings(std::ostream& Out, GRExprEngine::StateTy St) {
+ static void PrintVarBindings(std::ostream& Out, ValueState* St) {
Out << "Variables:\\l";
bool isFirst = true;
- for (GRExprEngine::StateTy::vb_iterator I=St.vb_begin(),
- E=St.vb_end(); I!=E;++I) {
+ for (ValueState::vb_iterator I=St->vb_begin(), E=St->vb_end(); I!=E;++I) {
if (isFirst)
isFirst = false;
@@ -1507,12 +1508,11 @@
}
- static void PrintSubExprBindings(std::ostream& Out, GRExprEngine::StateTy St){
+ static void PrintSubExprBindings(std::ostream& Out, ValueState* St){
bool isFirst = true;
- for (GRExprEngine::StateTy::seb_iterator I=St.seb_begin(), E=St.seb_end();
- I != E;++I) {
+ for (ValueState::seb_iterator I=St->seb_begin(), E=St->seb_end();I!=E;++I) {
if (isFirst) {
Out << "\\l\\lSub-Expressions:\\l";
@@ -1528,12 +1528,11 @@
}
}
- static void PrintBlkExprBindings(std::ostream& Out, GRExprEngine::StateTy St){
+ static void PrintBlkExprBindings(std::ostream& Out, ValueState* St){
bool isFirst = true;
- for (GRExprEngine::StateTy::beb_iterator I=St.beb_begin(), E=St.beb_end();
- I != E; ++I) {
+ for (ValueState::beb_iterator I=St->beb_begin(), E=St->beb_end(); I!=E;++I){
if (isFirst) {
Out << "\\l\\lBlock-level Expressions:\\l";
isFirst = false;
@@ -1548,8 +1547,8 @@
}
}
- static void PrintEQ(std::ostream& Out, GRExprEngine::StateTy St) {
- ValueState::ConstEqTy CE = St.getImpl()->ConstEq;
+ static void PrintEQ(std::ostream& Out, ValueState* St) {
+ ValueState::ConstEqTy CE = St->ConstEq;
if (CE.isEmpty())
return;
@@ -1560,8 +1559,8 @@
Out << "\\l $" << I.getKey() << " : " << I.getData()->toString();
}
- static void PrintNE(std::ostream& Out, GRExprEngine::StateTy St) {
- ValueState::ConstNotEqTy NE = St.getImpl()->ConstNotEq;
+ static void PrintNE(std::ostream& Out, ValueState* St) {
+ ValueState::ConstNotEqTy NE = St->ConstNotEq;
if (NE.isEmpty())
return;
@@ -1692,9 +1691,9 @@
}
}
- Out << "\\|StateID: " << (void*) N->getState().getImpl() << "\\|";
+ Out << "\\|StateID: " << (void*) N->getState() << "\\|";
- N->getState().printDOT(Out);
+ N->getState()->printDOT(Out);
Out << "\\l";
return Out.str();
Modified: cfe/trunk/Analysis/GRSimpleVals.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/GRSimpleVals.cpp?rev=47714&r1=47713&r2=47714&view=diff
==============================================================================
--- cfe/trunk/Analysis/GRSimpleVals.cpp (original)
+++ cfe/trunk/Analysis/GRSimpleVals.cpp Thu Feb 28 04:21:43 2008
@@ -340,11 +340,9 @@
// Transfer function for Function Calls.
//===----------------------------------------------------------------------===//
-ValueStateImpl*
+ValueState*
GRSimpleVals::EvalCall(ValueStateManager& StateMgr, ValueManager& ValMgr,
- CallExpr* CE, LVal L, ValueStateImpl* StImpl) {
-
- ValueState St(StImpl);
+ CallExpr* CE, LVal L, ValueState* St) {
// Invalidate all arguments passed in by reference (LVals).
@@ -357,5 +355,5 @@
St = StateMgr.SetRVal(St, cast<LVal>(V), UnknownVal());
}
- return St.getImpl();
+ return St;
}
Modified: cfe/trunk/Analysis/GRSimpleVals.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/GRSimpleVals.h?rev=47714&r1=47713&r2=47714&view=diff
==============================================================================
--- cfe/trunk/Analysis/GRSimpleVals.h (original)
+++ cfe/trunk/Analysis/GRSimpleVals.h Thu Feb 28 04:21:43 2008
@@ -52,10 +52,10 @@
// Calls.
- virtual ValueStateImpl* EvalCall(ValueStateManager& StateMgr,
- ValueManager& ValMgr,
- CallExpr* CE, LVal L,
- ValueStateImpl* StImpl);
+ virtual ValueState* EvalCall(ValueStateManager& StateMgr,
+ ValueManager& ValMgr,
+ CallExpr* CE, LVal L,
+ ValueState* St);
protected:
Modified: cfe/trunk/Analysis/ValueState.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/ValueState.cpp?rev=47714&r1=47713&r2=47714&view=diff
==============================================================================
--- cfe/trunk/Analysis/ValueState.cpp (original)
+++ cfe/trunk/Analysis/ValueState.cpp Thu Feb 28 04:21:43 2008
@@ -1,4 +1,4 @@
-//= ValueState.cpp - Path-Sens. "State" for tracking valuues -----*- C++ -*--=//
+//= ValueState*cpp - Path-Sens. "State" for tracking valuues -----*- C++ -*--=//
//
// The LLVM Compiler Infrastructure
//
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
-// This files defines SymbolID, ExprBindKey, and ValueState.
+// This files defines SymbolID, ExprBindKey, and ValueState*
//
//===----------------------------------------------------------------------===//
@@ -19,19 +19,19 @@
bool ValueState::isNotEqual(SymbolID sym, const llvm::APSInt& V) const {
// Retrieve the NE-set associated with the given symbol.
- ConstNotEqTy::TreeTy* T = Data->ConstNotEq.SlimFind(sym);
+ ConstNotEqTy::TreeTy* T = ConstNotEq.SlimFind(sym);
// See if V is present in the NE-set.
return T ? T->getValue().second.contains(&V) : false;
}
const llvm::APSInt* ValueState::getSymVal(SymbolID sym) const {
- ConstEqTy::TreeTy* T = Data->ConstEq.SlimFind(sym);
+ ConstEqTy::TreeTy* T = ConstEq.SlimFind(sym);
return T ? T->getValue().second : NULL;
}
-ValueState
-ValueStateManager::RemoveDeadBindings(ValueState St, Stmt* Loc,
+ValueState*
+ValueStateManager::RemoveDeadBindings(ValueState* St, Stmt* Loc,
const LiveVariables& Liveness) {
// This code essentially performs a "mark-and-sweep" of the VariableBindings.
@@ -45,14 +45,14 @@
llvm::SmallPtrSet<ValueDecl*, 10> Marked;
llvm::SmallSet<SymbolID, 20> MarkedSymbols;
- ValueStateImpl NewSt = *St;
+ ValueState NewSt = *St;
// Drop bindings for subexpressions.
NewSt.SubExprBindings = EXFactory.GetEmptyMap();
// Iterate over the block-expr bindings.
- for (ValueState::beb_iterator I = St.beb_begin(), E = St.beb_end();
+ for (ValueState::beb_iterator I = St->beb_begin(), E = St->beb_end();
I!=E ; ++I) {
Expr* BlkExpr = I.getKey();
@@ -81,7 +81,7 @@
// Iterate over the variable bindings.
- for (ValueState::vb_iterator I = St.vb_begin(), E = St.vb_end(); I!=E ; ++I)
+ for (ValueState::vb_iterator I = St->vb_begin(), E = St->vb_end(); I!=E ; ++I)
if (Liveness.isLive(Loc, I.getKey())) {
WList.push_back(I.getKey());
@@ -128,16 +128,16 @@
}
// Remove dead variable bindings.
- for (ValueState::vb_iterator I = St.vb_begin(), E = St.vb_end(); I!=E ; ++I)
+ for (ValueState::vb_iterator I = St->vb_begin(), E = St->vb_end(); I!=E ; ++I)
if (!Marked.count(I.getKey()))
NewSt.VarBindings = Remove(NewSt, I.getKey());
// Remove dead symbols.
- for (ValueState::ce_iterator I = St.ce_begin(), E=St.ce_end(); I!=E; ++I)
+ for (ValueState::ce_iterator I = St->ce_begin(), E=St->ce_end(); I!=E; ++I)
if (!MarkedSymbols.count(I.getKey()))
NewSt.ConstEq = CEFactory.Remove(NewSt.ConstEq, I.getKey());
- for (ValueState::cne_iterator I = St.cne_begin(), E=St.cne_end(); I!=E; ++I)
+ for (ValueState::cne_iterator I = St->cne_begin(), E=St->cne_end(); I!=E; ++I)
if (!MarkedSymbols.count(I.getKey()))
NewSt.ConstNotEq = CNEFactory.Remove(NewSt.ConstNotEq, I.getKey());
@@ -145,7 +145,7 @@
}
-RVal ValueStateManager::GetRVal(ValueState St, const LVal& LV, QualType T) {
+RVal ValueStateManager::GetRVal(ValueState* St, LVal LV, QualType T) {
if (isa<UnknownVal>(LV))
return UnknownVal();
@@ -184,8 +184,7 @@
return UnknownVal();
}
-ValueState
-ValueStateManager::AddNE(ValueState St, SymbolID sym, const llvm::APSInt& V) {
+ValueState* ValueStateManager::AddNE(ValueState* St, SymbolID sym, const llvm::APSInt& V) {
// First, retrieve the NE-set associated with the given symbol.
ValueState::ConstNotEqTy::TreeTy* T = St->ConstNotEq.SlimFind(sym);
@@ -195,25 +194,24 @@
S = ISetFactory.Add(S, &V);
// Create a new state with the old binding replaced.
- ValueStateImpl NewSt = *St;
+ ValueState NewSt = *St;
NewSt.ConstNotEq = CNEFactory.Add(NewSt.ConstNotEq, sym, S);
// Get the persistent copy.
return getPersistentState(NewSt);
}
-ValueState
-ValueStateManager::AddEQ(ValueState St, SymbolID sym, const llvm::APSInt& V) {
+ValueState* ValueStateManager::AddEQ(ValueState* St, SymbolID sym, const llvm::APSInt& V) {
// Create a new state with the old binding replaced.
- ValueStateImpl NewSt = *St;
+ ValueState NewSt = *St;
NewSt.ConstEq = CEFactory.Add(NewSt.ConstEq, sym, &V);
// Get the persistent copy.
return getPersistentState(NewSt);
}
-RVal ValueStateManager::GetRVal(ValueState St, Expr* E) {
+RVal ValueStateManager::GetRVal(ValueState* St, Expr* E) {
for (;;) {
@@ -336,7 +334,7 @@
return T ? T->getValue().second : UnknownVal();
}
-RVal ValueStateManager::GetBlkExprRVal(ValueState St, Expr* E) {
+RVal ValueStateManager::GetBlkExprRVal(ValueState* St, Expr* E) {
E = E->IgnoreParens();
@@ -358,7 +356,7 @@
}
}
-RVal ValueStateManager::GetLVal(ValueState St, Expr* E) {
+RVal ValueStateManager::GetLVal(ValueState* St, Expr* E) {
E = E->IgnoreParens();
@@ -386,8 +384,8 @@
return GetRVal(St, E);
}
-ValueState
-ValueStateManager::SetRVal(ValueState St, Expr* E, RVal V,
+ValueState*
+ValueStateManager::SetRVal(ValueState* St, Expr* E, RVal V,
bool isBlkExpr, bool Invalidate) {
assert (E);
@@ -396,7 +394,7 @@
if (Invalidate) {
- ValueStateImpl NewSt = *St;
+ ValueState NewSt = *St;
if (isBlkExpr)
NewSt.BlockExprBindings = EXFactory.Remove(NewSt.BlockExprBindings, E);
@@ -409,7 +407,7 @@
return St;
}
- ValueStateImpl NewSt = *St;
+ ValueState NewSt = *St;
if (isBlkExpr) {
NewSt.BlockExprBindings = EXFactory.Add(NewSt.BlockExprBindings, E, V);
@@ -422,7 +420,7 @@
}
-ValueState ValueStateManager::SetRVal(ValueState St, LVal LV, RVal V) {
+ValueState* ValueStateManager::SetRVal(ValueState* St, LVal LV, RVal V) {
switch (LV.getSubKind()) {
@@ -437,34 +435,34 @@
}
}
-void ValueStateManager::BindVar(ValueStateImpl& StImpl, VarDecl* D, RVal V) {
+void ValueStateManager::BindVar(ValueState& StImpl, VarDecl* D, RVal V) {
StImpl.VarBindings = VBFactory.Add(StImpl.VarBindings, D, V);
}
-ValueState ValueStateManager::BindVar(ValueState St, VarDecl* D, RVal V) {
+ValueState* ValueStateManager::BindVar(ValueState* St, VarDecl* D, RVal V) {
// Create a new state with the old binding removed.
- ValueStateImpl NewSt = *St;
+ ValueState NewSt = *St;
NewSt.VarBindings = VBFactory.Add(NewSt.VarBindings, D, V);
// Get the persistent copy.
return getPersistentState(NewSt);
}
-ValueState ValueStateManager::UnbindVar(ValueState St, VarDecl* D) {
+ValueState* ValueStateManager::UnbindVar(ValueState* St, VarDecl* D) {
// Create a new state with the old binding removed.
- ValueStateImpl NewSt = *St;
+ ValueState NewSt = *St;
NewSt.VarBindings = VBFactory.Remove(NewSt.VarBindings, D);
// Get the persistent copy.
return getPersistentState(NewSt);
}
-ValueState ValueStateManager::getInitialState() {
+ValueState* ValueStateManager::getInitialState() {
// Create a state with empty variable bindings.
- ValueStateImpl StateImpl(EXFactory.GetEmptyMap(),
+ ValueState StateImpl(EXFactory.GetEmptyMap(),
VBFactory.GetEmptyMap(),
CNEFactory.GetEmptyMap(),
CEFactory.GetEmptyMap());
@@ -472,17 +470,17 @@
return getPersistentState(StateImpl);
}
-ValueState ValueStateManager::getPersistentState(const ValueStateImpl &State) {
+ValueState* ValueStateManager::getPersistentState(ValueState& State) {
llvm::FoldingSetNodeID ID;
State.Profile(ID);
void* InsertPos;
- if (ValueStateImpl* I = StateSet.FindNodeOrInsertPos(ID, InsertPos))
+ if (ValueState* I = StateSet.FindNodeOrInsertPos(ID, InsertPos))
return I;
- ValueStateImpl* I = (ValueStateImpl*) Alloc.Allocate<ValueStateImpl>();
- new (I) ValueStateImpl(State);
+ ValueState* I = (ValueState*) Alloc.Allocate<ValueState>();
+ new (I) ValueState(State);
StateSet.InsertNode(I, InsertPos);
return I;
}
@@ -541,12 +539,12 @@
// Print equality constraints.
- if (!Data->ConstEq.isEmpty()) {
+ if (!ConstEq.isEmpty()) {
Out << "\\l\\|'==' constraints:";
- for (ConstEqTy::iterator I = Data->ConstEq.begin(),
- E = Data->ConstEq.end(); I!=E; ++I) {
+ for (ConstEqTy::iterator I = ConstEq.begin(),
+ E = ConstEq.end(); I!=E; ++I) {
Out << "\\l $" << I.getKey()
<< " : " << I.getData()->toString();
@@ -555,12 +553,12 @@
// Print != constraints.
- if (!Data->ConstNotEq.isEmpty()) {
+ if (!ConstNotEq.isEmpty()) {
Out << "\\l\\|'!=' constraints:";
- for (ConstNotEqTy::iterator I = Data->ConstNotEq.begin(),
- EI = Data->ConstNotEq.end(); I != EI; ++I) {
+ for (ConstNotEqTy::iterator I = ConstNotEq.begin(),
+ EI = ConstNotEq.end(); I != EI; ++I) {
Out << "\\l $" << I.getKey() << " : ";
isFirst = true;
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/ExplodedGraph.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/ExplodedGraph.h?rev=47714&r1=47713&r2=47714&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/ExplodedGraph.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/ExplodedGraph.h Thu Feb 28 04:21:43 2008
@@ -163,7 +163,7 @@
// Profiling (for FoldingSet).
inline void Profile(llvm::FoldingSetNodeID& ID) const {
- StateTy::Profile(ID, getState());
+ GRTrait<StateTy>::Profile(ID, getState());
}
// Iterators over successor and predecessor vertices.
@@ -317,7 +317,7 @@
llvm::FoldingSetNodeID profile;
void* InsertPos = 0;
- StateTy::Profile(profile, State);
+ GRTrait<StateTy>::Profile(profile, State);
NodeTy* V = VSet->FindNodeOrInsertPos(profile, InsertPos);
if (!V) {
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h?rev=47714&r1=47713&r2=47714&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h Thu Feb 28 04:21:43 2008
@@ -13,9 +13,8 @@
//
//===----------------------------------------------------------------------===//
-#include "ValueState.h"
-
#include "clang/Analysis/PathSensitive/GRCoreEngine.h"
+#include "clang/Analysis/PathSensitive/ValueState.h"
#include "clang/Analysis/PathSensitive/GRTransferFuncs.h"
namespace clang {
@@ -23,7 +22,7 @@
class GRExprEngine {
public:
- typedef ValueStateManager::StateTy StateTy;
+ typedef ValueState* StateTy;
typedef ExplodedGraph<GRExprEngine> GraphTy;
typedef GraphTy::NodeTy NodeTy;
@@ -155,7 +154,7 @@
/// getInitialState - Return the initial state used for the root vertex
/// in the ExplodedGraph.
- StateTy getInitialState();
+ ValueState* getInitialState();
bool isUndefControlFlow(const NodeTy* N) const {
return N->isSink() && UndefBranches.count(const_cast<NodeTy*>(N)) != 0;
@@ -219,45 +218,47 @@
/// that all subexpression mappings are removed and that any
/// block-level expressions that are not live at 'S' also have their
/// mappings removed.
- inline StateTy RemoveDeadBindings(Stmt* S, StateTy St) {
+ inline ValueState* RemoveDeadBindings(Stmt* S, ValueState* St) {
return StateMgr.RemoveDeadBindings(St, S, Liveness);
}
- StateTy SetRVal(StateTy St, Expr* Ex, const RVal& V);
+ ValueState* SetRVal(ValueState* St, Expr* Ex, RVal V);
- StateTy SetRVal(StateTy St, const Expr* Ex, const RVal& V) {
+ ValueState* SetRVal(ValueState* St, const Expr* Ex, RVal V) {
return SetRVal(St, const_cast<Expr*>(Ex), V);
}
- StateTy SetBlkExprRVal(StateTy St, Expr* Ex, const RVal& V) {
+ ValueState* SetBlkExprRVal(ValueState* St, Expr* Ex, RVal V) {
return StateMgr.SetRVal(St, Ex, V, true, false);
}
+#if 0
/// SetRVal - This version of SetRVal is used to batch process a set
/// of different possible RVals and return a set of different states.
- const StateTy::BufferTy& SetRVal(StateTy St, Expr* Ex,
- const RVal::BufferTy& V,
- StateTy::BufferTy& RetBuf);
+ const ValueState*::BufferTy& SetRVal(ValueState* St, Expr* Ex,
+ const RVal::BufferTy& V,
+ ValueState*::BufferTy& RetBuf);
+#endif
- StateTy SetRVal(StateTy St, const LVal& LV, const RVal& V);
+ ValueState* SetRVal(ValueState* St, LVal LV, RVal V);
- RVal GetRVal(const StateTy& St, Expr* Ex) {
+ RVal GetRVal(ValueState* St, Expr* Ex) {
return StateMgr.GetRVal(St, Ex);
}
- RVal GetRVal(const StateTy& St, const Expr* Ex) {
+ RVal GetRVal(ValueState* St, const Expr* Ex) {
return GetRVal(St, const_cast<Expr*>(Ex));
}
- RVal GetBlkExprRVal(const StateTy& St, Expr* Ex) {
+ RVal GetBlkExprRVal(ValueState* St, Expr* Ex) {
return StateMgr.GetBlkExprRVal(St, Ex);
}
- RVal GetRVal(const StateTy& St, const LVal& LV, QualType T = QualType()) {
+ RVal GetRVal(ValueState* St, LVal LV, QualType T = QualType()) {
return StateMgr.GetRVal(St, LV, T);
}
- RVal GetLVal(const StateTy& St, Expr* Ex) {
+ RVal GetLVal(ValueState* St, Expr* Ex) {
return StateMgr.GetLVal(St, Ex);
}
@@ -267,7 +268,8 @@
/// Assume - Create new state by assuming that a given expression
/// is true or false.
- StateTy Assume(StateTy St, RVal Cond, bool Assumption, bool& isFeasible) {
+ ValueState* Assume(ValueState* St, RVal Cond, bool Assumption,
+ bool& isFeasible) {
if (Cond.isUnknown()) {
isFeasible = true;
@@ -280,23 +282,29 @@
return Assume(St, cast<NonLVal>(Cond), Assumption, isFeasible);
}
- StateTy Assume(StateTy St, LVal Cond, bool Assumption, bool& isFeasible);
- StateTy Assume(StateTy St, NonLVal Cond, bool Assumption, bool& isFeasible);
+ ValueState* Assume(ValueState* St, LVal Cond, bool Assumption,
+ bool& isFeasible);
+
+ ValueState* Assume(ValueState* St, NonLVal Cond, bool Assumption,
+ bool& isFeasible);
- StateTy AssumeSymNE(StateTy St, SymbolID sym, const llvm::APSInt& V,
- bool& isFeasible);
+ ValueState* AssumeSymNE(ValueState* St, SymbolID sym, const llvm::APSInt& V,
+ bool& isFeasible);
- StateTy AssumeSymEQ(StateTy St, SymbolID sym, const llvm::APSInt& V,
- bool& isFeasible);
+ ValueState* AssumeSymEQ(ValueState* St, SymbolID sym, const llvm::APSInt& V,
+ bool& isFeasible);
- StateTy AssumeSymInt(StateTy St, bool Assumption, const SymIntConstraint& C,
- bool& isFeasible);
+ ValueState* AssumeSymInt(ValueState* St, bool Assumption,
+ const SymIntConstraint& C, bool& isFeasible);
- NodeTy* Nodify(NodeSet& Dst, Stmt* S, NodeTy* Pred, StateTy St);
+ NodeTy* Nodify(NodeSet& Dst, Stmt* S, NodeTy* Pred, ValueState* St);
+#if 0
/// Nodify - This version of Nodify is used to batch process a set of states.
/// The states are not guaranteed to be unique.
- void Nodify(NodeSet& Dst, Stmt* S, NodeTy* Pred, const StateTy::BufferTy& SB);
+ void Nodify(NodeSet& Dst, Stmt* S, NodeTy* Pred,
+ const ValueState*::BufferTy& SB);
+#endif
/// HandleUndefinedStore - Create the necessary sink node to represent
/// a store to an "undefined" LVal.
@@ -387,10 +395,10 @@
return TF->EvalBinOp(ValMgr, Op, cast<NonLVal>(L), cast<NonLVal>(R));
}
- StateTy EvalCall(CallExpr* CE, LVal L, StateTy St) {
- return StateTy(TF->EvalCall(StateMgr, ValMgr, CE, L, St.getImpl()));
+ ValueState* EvalCall(CallExpr* CE, LVal L, ValueState* St) {
+ return TF->EvalCall(StateMgr, ValMgr, CE, L, St);
}
- StateTy MarkBranch(StateTy St, Stmt* Terminator, bool branchTaken);
+ ValueState* MarkBranch(ValueState* St, Stmt* Terminator, bool branchTaken);
};
} // end clang namespace
\ No newline at end of file
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h?rev=47714&r1=47713&r2=47714&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h Thu Feb 28 04:21:43 2008
@@ -19,7 +19,7 @@
namespace clang {
- class ValueStateImpl;
+ class ValueState;
class ValueStateManager;
class GRTransferFuncs {
@@ -53,10 +53,9 @@
// Calls.
- virtual ValueStateImpl* EvalCall(ValueStateManager& StateMgr,
- ValueManager& ValMgr,
- CallExpr* CE, LVal L,
- ValueStateImpl* StImpl) = 0;
+ virtual ValueState* EvalCall(ValueStateManager& StateMgr,
+ ValueManager& ValMgr, CallExpr* CE, LVal L,
+ ValueState* St) = 0;
};
} // end clang namespace
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/ValueState.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/ValueState.h?rev=47714&r1=47713&r2=47714&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/ValueState.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/ValueState.h Thu Feb 28 04:21:43 2008
@@ -1,4 +1,4 @@
-//== ValueState.h - Path-Sens. "State" for tracking valuues -----*- C++ -*--==//
+//== ValueState*h - Path-Sens. "State" for tracking valuues -----*- C++ -*--==//
//
// The LLVM Compiler Infrastructure
//
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
-// This files defines SymbolID, ExprBindKey, and ValueState.
+// This files defines SymbolID, ExprBindKey, and ValueState*
//
//===----------------------------------------------------------------------===//
@@ -39,36 +39,42 @@
namespace clang {
//===----------------------------------------------------------------------===//
-// ValueState - An ImmutableMap type Stmt*/Decl*/Symbols to RVals.
+// ValueState- An ImmutableMap type Stmt*/Decl*/Symbols to RVals.
//===----------------------------------------------------------------------===//
-namespace vstate {
- typedef llvm::ImmutableSet<llvm::APSInt*> IntSetTy;
+/// ValueState - This class encapsulates the actual data values for
+/// for a "state" in our symbolic value tracking. It is intended to be
+/// used as a functional object; that is once it is created and made
+/// "persistent" in a FoldingSet its values will never change.
+class ValueState : public llvm::FoldingSetNode {
+public:
+ // Typedefs.
+
+ typedef llvm::ImmutableSet<llvm::APSInt*> IntSetTy;
typedef llvm::ImmutableMap<Expr*,RVal> ExprBindingsTy;
typedef llvm::ImmutableMap<VarDecl*,RVal> VarBindingsTy;
typedef llvm::ImmutableMap<SymbolID,IntSetTy> ConstNotEqTy;
typedef llvm::ImmutableMap<SymbolID,const llvm::APSInt*> ConstEqTy;
-}
-/// ValueStateImpl - This class encapsulates the actual data values for
-/// for a "state" in our symbolic value tracking. It is intended to be
-/// used as a functional object; that is once it is created and made
-/// "persistent" in a FoldingSet its values will never change.
-class ValueStateImpl : public llvm::FoldingSetNode {
private:
- void operator=(const ValueStateImpl& R) const;
+ void operator=(const ValueState& R) const;
+
+ // FIXME: Make these private.
+
+public:
+ ExprBindingsTy SubExprBindings;
+ ExprBindingsTy BlockExprBindings;
+ VarBindingsTy VarBindings;
+ ConstNotEqTy ConstNotEq;
+ ConstEqTy ConstEq;
+
public:
- vstate::ExprBindingsTy SubExprBindings;
- vstate::ExprBindingsTy BlockExprBindings;
- vstate::VarBindingsTy VarBindings;
- vstate::ConstNotEqTy ConstNotEq;
- vstate::ConstEqTy ConstEq;
-
- /// This ctor is used when creating the first ValueStateImpl object.
- ValueStateImpl(vstate::ExprBindingsTy EB, vstate::VarBindingsTy VB,
- vstate::ConstNotEqTy CNE, vstate::ConstEqTy CE)
+
+ /// This ctor is used when creating the first ValueState object.
+ ValueState(ExprBindingsTy EB, VarBindingsTy VB,
+ ConstNotEqTy CNE, ConstEqTy CE)
: SubExprBindings(EB),
BlockExprBindings(EB),
VarBindings(VB),
@@ -77,7 +83,7 @@
/// Copy ctor - We must explicitly define this or else the "Next" ptr
/// in FoldingSetNode will also get copied.
- ValueStateImpl(const ValueStateImpl& RHS)
+ ValueState(const ValueState& RHS)
: llvm::FoldingSetNode(),
SubExprBindings(RHS.SubExprBindings),
BlockExprBindings(RHS.BlockExprBindings),
@@ -85,111 +91,63 @@
ConstNotEq(RHS.ConstNotEq),
ConstEq(RHS.ConstEq) {}
- /// Profile - Profile the contents of a ValueStateImpl object for use
+ /// Profile - Profile the contents of a ValueState object for use
/// in a FoldingSet.
- static void Profile(llvm::FoldingSetNodeID& ID, const ValueStateImpl& V) {
- V.SubExprBindings.Profile(ID);
- V.BlockExprBindings.Profile(ID);
- V.VarBindings.Profile(ID);
- V.ConstNotEq.Profile(ID);
- V.ConstEq.Profile(ID);
+ static void Profile(llvm::FoldingSetNodeID& ID, ValueState* V) {
+ V->SubExprBindings.Profile(ID);
+ V->BlockExprBindings.Profile(ID);
+ V->VarBindings.Profile(ID);
+ V->ConstNotEq.Profile(ID);
+ V->ConstEq.Profile(ID);
}
/// Profile - Used to profile the contents of this object for inclusion
/// in a FoldingSet.
- void Profile(llvm::FoldingSetNodeID& ID) const {
- Profile(ID, *this);
+ void Profile(llvm::FoldingSetNodeID& ID) {
+ Profile(ID, this);
}
-};
-
-/// ValueState - This class represents a "state" in our symbolic value
-/// tracking. It is really just a "smart pointer", wrapping a pointer
-/// to ValueStateImpl object. Making this class a smart pointer means that its
-/// size is always the size of a pointer, which allows easy conversion to
-/// void* when being handled by GRCoreEngine. It also forces us to unique states;
-/// consequently, a ValueStateImpl* with a specific address will always refer
-/// to the unique state with those values.
-class ValueState {
- ValueStateImpl* Data;
-public:
- ValueState(ValueStateImpl* D) : Data(D) {}
- ValueState() : Data(0) {}
-
- // Accessors.
- ValueStateImpl* getImpl() const { return Data; }
- ValueStateImpl& operator*() { return *Data; }
- ValueStateImpl* operator->() { return Data; }
-
- // Typedefs.
- typedef vstate::IntSetTy IntSetTy;
- typedef vstate::ExprBindingsTy ExprBindingsTy;
- typedef vstate::VarBindingsTy VarBindingsTy;
- typedef vstate::ConstNotEqTy ConstNotEqTy;
- typedef vstate::ConstEqTy ConstEqTy;
-
- typedef llvm::SmallVector<ValueState,5> BufferTy;
-
// Queries.
bool isNotEqual(SymbolID sym, const llvm::APSInt& V) const;
const llvm::APSInt* getSymVal(SymbolID sym) const;
-
+
// Iterators.
typedef VarBindingsTy::iterator vb_iterator;
- vb_iterator vb_begin() const { return Data->VarBindings.begin(); }
- vb_iterator vb_end() const { return Data->VarBindings.end(); }
+ vb_iterator vb_begin() const { return VarBindings.begin(); }
+ vb_iterator vb_end() const { return VarBindings.end(); }
typedef ExprBindingsTy::iterator seb_iterator;
- seb_iterator seb_begin() const { return Data->SubExprBindings.begin(); }
- seb_iterator seb_end() const { return Data->SubExprBindings.end(); }
+ seb_iterator seb_begin() const { return SubExprBindings.begin(); }
+ seb_iterator seb_end() const { return SubExprBindings.end(); }
typedef ExprBindingsTy::iterator beb_iterator;
- beb_iterator beb_begin() const { return Data->BlockExprBindings.begin(); }
- beb_iterator beb_end() const { return Data->BlockExprBindings.end(); }
+ beb_iterator beb_begin() const { return BlockExprBindings.begin(); }
+ beb_iterator beb_end() const { return BlockExprBindings.end(); }
typedef ConstNotEqTy::iterator cne_iterator;
- cne_iterator cne_begin() const { return Data->ConstNotEq.begin(); }
- cne_iterator cne_end() const { return Data->ConstNotEq.end(); }
+ cne_iterator cne_begin() const { return ConstNotEq.begin(); }
+ cne_iterator cne_end() const { return ConstNotEq.end(); }
typedef ConstEqTy::iterator ce_iterator;
- ce_iterator ce_begin() const { return Data->ConstEq.begin(); }
- ce_iterator ce_end() const { return Data->ConstEq.end(); }
-
- // Profiling and equality testing.
-
- bool operator==(const ValueState& RHS) const {
- return Data == RHS.Data;
- }
-
- static void Profile(llvm::FoldingSetNodeID& ID, const ValueState& V) {
- ID.AddPointer(V.getImpl());
- }
-
- void Profile(llvm::FoldingSetNodeID& ID) const {
- Profile(ID, *this);
- }
+ ce_iterator ce_begin() const { return ConstEq.begin(); }
+ ce_iterator ce_end() const { return ConstEq.end(); }
void printDOT(std::ostream& Out) const;
void print(std::ostream& Out) const;
- void printStdErr() const { print(*llvm::cerr); }
-
+ void printStdErr() const { print(*llvm::cerr); }
};
-template<> struct GRTrait<ValueState> {
- static inline void* toPtr(ValueState St) {
- return reinterpret_cast<void*>(St.getImpl());
- }
- static inline ValueState toState(void* P) {
- return ValueState(static_cast<ValueStateImpl*>(P));
+template<> struct GRTrait<ValueState*> {
+ static inline void* toPtr(ValueState* St) { return (void*) St; }
+ static inline ValueState* toState(void* P) { return (ValueState*) P; }
+ static inline void Profile(llvm::FoldingSetNodeID& profile, ValueState* St) {
+ ValueState::Profile(profile, St);
}
};
class ValueStateManager {
-public:
- typedef ValueState StateTy;
-
private:
ValueState::IntSetTy::Factory ISetFactory;
ValueState::ExprBindingsTy::Factory EXFactory;
@@ -199,7 +157,7 @@
/// StateSet - FoldingSet containing all the states created for analyzing
/// a particular function. This is used to unique states.
- llvm::FoldingSet<ValueStateImpl> StateSet;
+ llvm::FoldingSet<ValueState> StateSet;
/// ValueMgr - Object that manages the data for all created RVals.
ValueManager ValMgr;
@@ -220,16 +178,16 @@
return VBFactory.Remove(B, V);
}
- inline ValueState::ExprBindingsTy Remove(const ValueStateImpl& V, Expr* E) {
+ inline ValueState::ExprBindingsTy Remove(const ValueState& V, Expr* E) {
return Remove(V.BlockExprBindings, E);
}
- inline ValueState::VarBindingsTy Remove(const ValueStateImpl& V, VarDecl* D) {
+ inline ValueState::VarBindingsTy Remove(const ValueState& V, VarDecl* D) {
return Remove(V.VarBindings, D);
}
- ValueState BindVar(ValueState St, VarDecl* D, RVal V);
- ValueState UnbindVar(ValueState St, VarDecl* D);
+ ValueState* BindVar(ValueState* St, VarDecl* D, RVal V);
+ ValueState* UnbindVar(ValueState* St, VarDecl* D);
public:
ValueStateManager(ASTContext& Ctx, llvm::BumpPtrAllocator& alloc)
@@ -241,36 +199,36 @@
ValMgr(Ctx, alloc),
Alloc(alloc) {}
- ValueState getInitialState();
+ ValueState* getInitialState();
ValueManager& getValueManager() { return ValMgr; }
SymbolManager& getSymbolManager() { return SymMgr; }
- ValueState RemoveDeadBindings(ValueState St, Stmt* Loc,
- const LiveVariables& Liveness);
+ ValueState* RemoveDeadBindings(ValueState* St, Stmt* Loc,
+ const LiveVariables& Liveness);
- ValueState RemoveSubExprBindings(ValueState St) {
- ValueStateImpl NewSt = *St;
+ ValueState* RemoveSubExprBindings(ValueState* St) {
+ ValueState NewSt = *St;
NewSt.SubExprBindings = EXFactory.GetEmptyMap();
return getPersistentState(NewSt);
}
- ValueState SetRVal(ValueState St, Expr* E, RVal V,
- bool isBlkExpr, bool Invalidate);
+ ValueState* SetRVal(ValueState* St, Expr* E, RVal V, bool isBlkExpr,
+ bool Invalidate);
- ValueState SetRVal(ValueState St, LVal LV, RVal V);
+ ValueState* SetRVal(ValueState* St, LVal LV, RVal V);
- RVal GetRVal(ValueState St, Expr* E);
- RVal GetRVal(ValueState St, const LVal& LV, QualType T = QualType());
- RVal GetLVal(ValueState St, Expr* E);
+ RVal GetRVal(ValueState* St, Expr* E);
+ RVal GetRVal(ValueState* St, LVal LV, QualType T = QualType());
+ RVal GetLVal(ValueState* St, Expr* E);
- RVal GetBlkExprRVal(ValueState St, Expr* Ex);
+ RVal GetBlkExprRVal(ValueState* St, Expr* Ex);
- void BindVar(ValueStateImpl& StImpl, VarDecl* D, RVal V);
- ValueState getPersistentState(const ValueStateImpl& Impl);
+ void BindVar(ValueState& StImpl, VarDecl* D, RVal V);
+ ValueState* getPersistentState(ValueState& Impl);
- ValueState AddEQ(ValueState St, SymbolID sym, const llvm::APSInt& V);
- ValueState AddNE(ValueState St, SymbolID sym, const llvm::APSInt& V);
+ ValueState* AddEQ(ValueState* St, SymbolID sym, const llvm::APSInt& V);
+ ValueState* AddNE(ValueState* St, SymbolID sym, const llvm::APSInt& V);
};
} // end clang namespace
More information about the cfe-commits
mailing list