- SetSVal(GRState*, Loc, SVal) => BindLoc
 - SetSVal(GRState*, Expr*, SVal) => BindExpr 

llvm-svn: 58421
This commit is contained in:
Zhongxing Xu 2008-10-30 05:33:54 +00:00
parent 9655394b6e
commit a15cfd4db9
8 changed files with 84 additions and 85 deletions

View File

@ -139,8 +139,8 @@ public:
return Environment(F.GetEmptyMap(), F.GetEmptyMap()); return Environment(F.GetEmptyMap(), F.GetEmptyMap());
} }
Environment SetSVal(const Environment& Env, Expr* E, SVal V, Environment BindExpr(const Environment& Env, Expr* E, SVal V,
bool isBlkExpr, bool Invalidate); bool isBlkExpr, bool Invalidate);
Environment RemoveDeadBindings(Environment Env, Stmt* Loc, Environment RemoveDeadBindings(Environment Env, Stmt* Loc,
const LiveVariables& Liveness, const LiveVariables& Liveness,

View File

@ -405,22 +405,22 @@ protected:
public: public:
const GRState* SetSVal(const GRState* St, Expr* Ex, SVal V) { const GRState* BindExpr(const GRState* St, Expr* Ex, SVal V) {
return StateMgr.SetSVal(St, Ex, V); return StateMgr.BindExpr(St, Ex, V);
} }
const GRState* SetSVal(const GRState* St, const Expr* Ex, SVal V) { const GRState* BindExpr(const GRState* St, const Expr* Ex, SVal V) {
return SetSVal(St, const_cast<Expr*>(Ex), V); return BindExpr(St, const_cast<Expr*>(Ex), V);
} }
protected: protected:
const GRState* SetBlkExprSVal(const GRState* St, Expr* Ex, SVal V) { const GRState* BindBlkExpr(const GRState* St, Expr* Ex, SVal V) {
return StateMgr.SetSVal(St, Ex, V, true, false); return StateMgr.BindExpr(St, Ex, V, true, false);
} }
const GRState* SetSVal(const GRState* St, Loc LV, SVal V) { const GRState* BindLoc(const GRState* St, Loc LV, SVal V) {
return StateMgr.SetSVal(St, LV, V); return StateMgr.BindLoc(St, LV, V);
} }
SVal GetSVal(const GRState* St, Expr* Ex) { SVal GetSVal(const GRState* St, Expr* Ex) {

View File

@ -398,11 +398,11 @@ public:
return St->getEnvironment().GetBlkExprSVal(Ex, BasicVals); return St->getEnvironment().GetBlkExprSVal(Ex, BasicVals);
} }
const GRState* SetSVal(const GRState* St, Expr* Ex, SVal V, const GRState* BindExpr(const GRState* St, Expr* Ex, SVal V,
bool isBlkExpr, bool Invalidate) { bool isBlkExpr, bool Invalidate) {
const Environment& OldEnv = St->getEnvironment(); const Environment& OldEnv = St->getEnvironment();
Environment NewEnv = EnvMgr.SetSVal(OldEnv, Ex, V, isBlkExpr, Invalidate); Environment NewEnv = EnvMgr.BindExpr(OldEnv, Ex, V, isBlkExpr, Invalidate);
if (NewEnv == OldEnv) if (NewEnv == OldEnv)
return St; return St;
@ -412,8 +412,8 @@ public:
return getPersistentState(NewSt); return getPersistentState(NewSt);
} }
const GRState* SetSVal(const GRState* St, Expr* Ex, SVal V, const GRState* BindExpr(const GRState* St, Expr* Ex, SVal V,
bool Invalidate = true) { bool Invalidate = true) {
bool isBlkExpr = false; bool isBlkExpr = false;
@ -426,7 +426,7 @@ public:
return St; return St;
} }
return SetSVal(St, Ex, V, isBlkExpr, Invalidate); return BindExpr(St, Ex, V, isBlkExpr, Invalidate);
} }
SVal ArrayToPointer(SVal Array) { SVal ArrayToPointer(SVal Array) {
@ -456,11 +456,11 @@ public:
return StoreMgr->GetRegionSVal(St->getStore(), R); return StoreMgr->GetRegionSVal(St->getStore(), R);
} }
void SetSVal(GRState& St, Loc LV, SVal V) { void BindLoc(GRState& St, Loc LV, SVal V) {
St.St = StoreMgr->Bind(St.St, LV, V); St.St = StoreMgr->Bind(St.St, LV, V);
} }
const GRState* SetSVal(const GRState* St, Loc LV, SVal V); const GRState* BindLoc(const GRState* St, Loc LV, SVal V);
void Unbind(GRState& St, Loc LV) { void Unbind(GRState& St, Loc LV) {
St.St = StoreMgr->Remove(St.St, LV); St.St = StoreMgr->Remove(St.St, LV);
@ -558,16 +558,16 @@ public:
} }
GRStateRef SetSVal(Expr* Ex, SVal V, bool isBlkExpr, bool Invalidate) { GRStateRef SetSVal(Expr* Ex, SVal V, bool isBlkExpr, bool Invalidate) {
return GRStateRef(Mgr->SetSVal(St, Ex, V, isBlkExpr, Invalidate), *Mgr); return GRStateRef(Mgr->BindExpr(St, Ex, V, isBlkExpr, Invalidate), *Mgr);
} }
GRStateRef SetSVal(Expr* Ex, SVal V, bool Invalidate = true) { GRStateRef SetSVal(Expr* Ex, SVal V, bool Invalidate = true) {
return GRStateRef(Mgr->SetSVal(St, Ex, V, Invalidate), *Mgr); return GRStateRef(Mgr->BindExpr(St, Ex, V, Invalidate), *Mgr);
} }
GRStateRef SetSVal(Loc LV, SVal V) { GRStateRef SetSVal(Loc LV, SVal V) {
GRState StImpl = *St; GRState StImpl = *St;
Mgr->SetSVal(StImpl, LV, V); Mgr->BindLoc(StImpl, LV, V);
return GRStateRef(Mgr->getPersistentState(StImpl), *Mgr); return GRStateRef(Mgr->getPersistentState(StImpl), *Mgr);
} }

View File

@ -89,8 +89,8 @@ SVal Environment::GetBlkExprSVal(Expr* E, BasicValueFactory& BasicVals) const {
} }
} }
Environment EnvironmentManager::SetSVal(const Environment& Env, Expr* E, SVal V, Environment EnvironmentManager::BindExpr(const Environment& Env, Expr* E,SVal V,
bool isBlkExpr, bool Invalidate) { bool isBlkExpr, bool Invalidate) {
assert (E); assert (E);
if (V.isUnknown()) { if (V.isUnknown()) {

View File

@ -303,7 +303,7 @@ void GRExprEngine::Visit(Stmt* S, NodeTy* Pred, NodeSet& Dst) {
} }
else if (B->getOpcode() == BinaryOperator::Comma) { else if (B->getOpcode() == BinaryOperator::Comma) {
const GRState* St = GetState(Pred); const GRState* St = GetState(Pred);
MakeNode(Dst, B, Pred, SetSVal(St, B, GetSVal(St, B->getRHS()))); MakeNode(Dst, B, Pred, BindExpr(St, B, GetSVal(St, B->getRHS())));
break; break;
} }
@ -390,7 +390,7 @@ void GRExprEngine::Visit(Stmt* S, NodeTy* Pred, NodeSet& Dst) {
assert (!SE->getSubStmt()->body_empty()); assert (!SE->getSubStmt()->body_empty());
if (Expr* LastExpr = dyn_cast<Expr>(*SE->getSubStmt()->body_rbegin())) if (Expr* LastExpr = dyn_cast<Expr>(*SE->getSubStmt()->body_rbegin()))
MakeNode(Dst, SE, Pred, SetSVal(St, SE, GetSVal(St, LastExpr))); MakeNode(Dst, SE, Pred, BindExpr(St, SE, GetSVal(St, LastExpr)));
else else
Dst.Add(Pred); Dst.Add(Pred);
@ -456,7 +456,7 @@ void GRExprEngine::VisitLValue(Expr* Ex, NodeTy* Pred, NodeSet& Dst) {
case Stmt::StringLiteralClass: { case Stmt::StringLiteralClass: {
const GRState* St = GetState(Pred); const GRState* St = GetState(Pred);
SVal V = StateMgr.GetLValue(St, cast<StringLiteral>(Ex)); SVal V = StateMgr.GetLValue(St, cast<StringLiteral>(Ex));
MakeNode(Dst, Ex, Pred, SetSVal(St, Ex, V)); MakeNode(Dst, Ex, Pred, BindExpr(St, Ex, V));
return; return;
} }
@ -513,7 +513,7 @@ const GRState* GRExprEngine::MarkBranch(const GRState* St,
(Op == BinaryOperator::LOr && !branchTaken) (Op == BinaryOperator::LOr && !branchTaken)
? B->getRHS() : B->getLHS(); ? B->getRHS() : B->getLHS();
return SetBlkExprSVal(St, B, UndefinedVal(Ex)); return BindBlkExpr(St, B, UndefinedVal(Ex));
} }
case Stmt::ConditionalOperatorClass: { // ?: case Stmt::ConditionalOperatorClass: { // ?:
@ -530,7 +530,7 @@ const GRState* GRExprEngine::MarkBranch(const GRState* St,
else else
Ex = C->getRHS(); Ex = C->getRHS();
return SetBlkExprSVal(St, C, UndefinedVal(Ex)); return BindBlkExpr(St, C, UndefinedVal(Ex));
} }
case Stmt::ChooseExprClass: { // ?: case Stmt::ChooseExprClass: { // ?:
@ -538,7 +538,7 @@ const GRState* GRExprEngine::MarkBranch(const GRState* St,
ChooseExpr* C = cast<ChooseExpr>(Terminator); ChooseExpr* C = cast<ChooseExpr>(Terminator);
Expr* Ex = branchTaken ? C->getLHS() : C->getRHS(); Expr* Ex = branchTaken ? C->getLHS() : C->getRHS();
return SetBlkExprSVal(St, C, UndefinedVal(Ex)); return BindBlkExpr(St, C, UndefinedVal(Ex));
} }
} }
} }
@ -664,7 +664,7 @@ void GRExprEngine::VisitGuardedExpr(Expr* Ex, Expr* L, Expr* R,
X = GetBlkExprSVal(St, SE); X = GetBlkExprSVal(St, SE);
// Make sure that we invalidate the previous binding. // Make sure that we invalidate the previous binding.
MakeNode(Dst, Ex, Pred, StateMgr.SetSVal(St, Ex, X, true, true)); MakeNode(Dst, Ex, Pred, StateMgr.BindExpr(St, Ex, X, true, true));
} }
/// ProcessSwitch - Called by GRCoreEngine. Used to generate successor /// ProcessSwitch - Called by GRCoreEngine. Used to generate successor
@ -796,7 +796,7 @@ void GRExprEngine::VisitLogicalExpr(BinaryOperator* B, NodeTy* Pred,
// Handle undefined values. // Handle undefined values.
if (X.isUndef()) { if (X.isUndef()) {
MakeNode(Dst, B, Pred, SetBlkExprSVal(St, B, X)); MakeNode(Dst, B, Pred, BindBlkExpr(St, B, X));
return; return;
} }
@ -812,14 +812,14 @@ void GRExprEngine::VisitLogicalExpr(BinaryOperator* B, NodeTy* Pred,
if (isFeasible) if (isFeasible)
MakeNode(Dst, B, Pred, MakeNode(Dst, B, Pred,
SetBlkExprSVal(NewState, B, MakeConstantVal(1U, B))); BindBlkExpr(NewState, B, MakeConstantVal(1U, B)));
isFeasible = false; isFeasible = false;
NewState = Assume(St, X, false, isFeasible); NewState = Assume(St, X, false, isFeasible);
if (isFeasible) if (isFeasible)
MakeNode(Dst, B, Pred, MakeNode(Dst, B, Pred,
SetBlkExprSVal(NewState, B, MakeConstantVal(0U, B))); BindBlkExpr(NewState, B, MakeConstantVal(0U, B)));
} }
else { else {
// We took the LHS expression. Depending on whether we are '&&' or // We took the LHS expression. Depending on whether we are '&&' or
@ -827,7 +827,7 @@ void GRExprEngine::VisitLogicalExpr(BinaryOperator* B, NodeTy* Pred,
// the short-circuiting. // the short-circuiting.
X = MakeConstantVal( B->getOpcode() == BinaryOperator::LAnd ? 0U : 1U, B); X = MakeConstantVal( B->getOpcode() == BinaryOperator::LAnd ? 0U : 1U, B);
MakeNode(Dst, B, Pred, SetBlkExprSVal(St, B, X)); MakeNode(Dst, B, Pred, BindBlkExpr(St, B, X));
} }
} }
@ -847,7 +847,7 @@ void GRExprEngine::VisitDeclRefExpr(DeclRefExpr* Ex, NodeTy* Pred, NodeSet& Dst,
SVal V = StateMgr.GetLValue(St, VD); SVal V = StateMgr.GetLValue(St, VD);
if (asLValue) if (asLValue)
MakeNode(Dst, Ex, Pred, SetSVal(St, Ex, V)); MakeNode(Dst, Ex, Pred, BindExpr(St, Ex, V));
else else
EvalLoad(Dst, Ex, Pred, St, V); EvalLoad(Dst, Ex, Pred, St, V);
return; return;
@ -857,7 +857,7 @@ void GRExprEngine::VisitDeclRefExpr(DeclRefExpr* Ex, NodeTy* Pred, NodeSet& Dst,
BasicValueFactory& BasicVals = StateMgr.getBasicVals(); BasicValueFactory& BasicVals = StateMgr.getBasicVals();
SVal V = nonloc::ConcreteInt(BasicVals.getValue(ED->getInitVal())); SVal V = nonloc::ConcreteInt(BasicVals.getValue(ED->getInitVal()));
MakeNode(Dst, Ex, Pred, SetSVal(St, Ex, V)); MakeNode(Dst, Ex, Pred, BindExpr(St, Ex, V));
return; return;
} else if (const FunctionDecl* FD = dyn_cast<FunctionDecl>(D)) { } else if (const FunctionDecl* FD = dyn_cast<FunctionDecl>(D)) {
@ -866,7 +866,7 @@ void GRExprEngine::VisitDeclRefExpr(DeclRefExpr* Ex, NodeTy* Pred, NodeSet& Dst,
// FIXME: Does this need to be revised? We were getting cases in // FIXME: Does this need to be revised? We were getting cases in
// real code that did this. // real code that did this.
SVal V = loc::FuncVal(FD); SVal V = loc::FuncVal(FD);
MakeNode(Dst, Ex, Pred, SetSVal(St, Ex, V)); MakeNode(Dst, Ex, Pred, BindExpr(St, Ex, V));
return; return;
} }
@ -892,7 +892,7 @@ void GRExprEngine::VisitArraySubscriptExpr(ArraySubscriptExpr* A, NodeTy* Pred,
SVal V = StateMgr.GetLValue(St, GetSVal(St, Base), GetSVal(St, Idx)); SVal V = StateMgr.GetLValue(St, GetSVal(St, Base), GetSVal(St, Idx));
if (asLValue) if (asLValue)
MakeNode(Dst, A, *I2, SetSVal(St, A, V)); MakeNode(Dst, A, *I2, BindExpr(St, A, V));
else else
EvalLoad(Dst, A, *I2, St, V); EvalLoad(Dst, A, *I2, St, V);
} }
@ -919,7 +919,7 @@ void GRExprEngine::VisitMemberExpr(MemberExpr* M, NodeTy* Pred,
SVal L = StateMgr.GetLValue(St, GetSVal(St, Base), M->getMemberDecl()); SVal L = StateMgr.GetLValue(St, GetSVal(St, Base), M->getMemberDecl());
if (asLValue) if (asLValue)
MakeNode(Dst, M, *I, SetSVal(St, M, L)); MakeNode(Dst, M, *I, BindExpr(St, M, L));
else else
EvalLoad(Dst, M, *I, St, L); EvalLoad(Dst, M, *I, St, L);
} }
@ -981,11 +981,11 @@ void GRExprEngine::EvalLoad(NodeSet& Dst, Expr* Ex, NodeTy* Pred,
MakeNode(Dst, Ex, Pred, St, K); MakeNode(Dst, Ex, Pred, St, K);
else if (location.isUnknown()) { else if (location.isUnknown()) {
// This is important. We must nuke the old binding. // This is important. We must nuke the old binding.
MakeNode(Dst, Ex, Pred, SetSVal(St, Ex, UnknownVal()), K); MakeNode(Dst, Ex, Pred, BindExpr(St, Ex, UnknownVal()), K);
} }
else else
MakeNode(Dst, Ex, Pred, SetSVal(St, Ex, GetSVal(St, cast<Loc>(location), MakeNode(Dst, Ex, Pred, BindExpr(St, Ex, GetSVal(St, cast<Loc>(location),
Ex->getType())), K); Ex->getType())), K);
} }
void GRExprEngine::EvalStore(NodeSet& Dst, Expr* Ex, Expr* StoreE, NodeTy* Pred, void GRExprEngine::EvalStore(NodeSet& Dst, Expr* Ex, Expr* StoreE, NodeTy* Pred,
@ -999,8 +999,8 @@ void GRExprEngine::EvalStore(NodeSet& Dst, Expr* Ex, Expr* StoreE, NodeTy* Pred,
} }
const GRState* GRExprEngine::EvalLocation(Expr* Ex, NodeTy* Pred, const GRState* GRExprEngine::EvalLocation(Expr* Ex, NodeTy* Pred,
const GRState* St, const GRState* St,
SVal location, bool isLoad) { SVal location, bool isLoad) {
// Check for loads/stores from/to undefined values. // Check for loads/stores from/to undefined values.
if (location.isUndef()) { if (location.isUndef()) {
@ -1234,7 +1234,7 @@ void GRExprEngine::VisitCallRec(CallExpr* CE, NodeTy* Pred,
// For __builtin_expect, just return the value of the subexpression. // For __builtin_expect, just return the value of the subexpression.
assert (CE->arg_begin() != CE->arg_end()); assert (CE->arg_begin() != CE->arg_end());
SVal X = GetSVal(St, *(CE->arg_begin())); SVal X = GetSVal(St, *(CE->arg_begin()));
MakeNode(Dst, CE, *DI, SetSVal(St, CE, X)); MakeNode(Dst, CE, *DI, BindExpr(St, CE, X));
continue; continue;
} }
@ -1299,7 +1299,7 @@ void GRExprEngine::VisitObjCIvarRefExpr(ObjCIvarRefExpr* Ex,
SVal location = StateMgr.GetLValue(St, Ex->getDecl(), BaseVal); SVal location = StateMgr.GetLValue(St, Ex->getDecl(), BaseVal);
if (asLValue) if (asLValue)
MakeNode(Dst, Ex, *I, SetSVal(St, Ex, location)); MakeNode(Dst, Ex, *I, BindExpr(St, Ex, location));
else else
EvalLoad(Dst, Ex, *I, St, location); EvalLoad(Dst, Ex, *I, St, location);
} }
@ -1512,7 +1512,7 @@ void GRExprEngine::VisitCast(Expr* CastE, Expr* Ex, NodeTy* Pred, NodeSet& Dst){
// Undefined? // Undefined?
if (V.isUndef()) { if (V.isUndef()) {
MakeNode(Dst, CastE, N, SetSVal(St, CastE, V)); MakeNode(Dst, CastE, N, BindExpr(St, CastE, V));
continue; continue;
} }
@ -1521,7 +1521,7 @@ void GRExprEngine::VisitCast(Expr* CastE, Expr* Ex, NodeTy* Pred, NodeSet& Dst){
if (C.getCanonicalType(T).getUnqualifiedType() == if (C.getCanonicalType(T).getUnqualifiedType() ==
C.getCanonicalType(ExTy).getUnqualifiedType()) { C.getCanonicalType(ExTy).getUnqualifiedType()) {
MakeNode(Dst, CastE, N, SetSVal(St, CastE, V)); MakeNode(Dst, CastE, N, BindExpr(St, CastE, V));
continue; continue;
} }
@ -1534,7 +1534,7 @@ void GRExprEngine::VisitCast(Expr* CastE, Expr* Ex, NodeTy* Pred, NodeSet& Dst){
// If not, flag an error. // If not, flag an error.
V = nonloc::LocAsInteger::Make(getBasicVals(), cast<Loc>(V), bits); V = nonloc::LocAsInteger::Make(getBasicVals(), cast<Loc>(V), bits);
MakeNode(Dst, CastE, N, SetSVal(St, CastE, V)); MakeNode(Dst, CastE, N, BindExpr(St, CastE, V));
continue; continue;
} }
@ -1543,7 +1543,7 @@ void GRExprEngine::VisitCast(Expr* CastE, Expr* Ex, NodeTy* Pred, NodeSet& Dst){
if (nonloc::LocAsInteger *LV = dyn_cast<nonloc::LocAsInteger>(&V)) { if (nonloc::LocAsInteger *LV = dyn_cast<nonloc::LocAsInteger>(&V)) {
// Just unpackage the lval and return it. // Just unpackage the lval and return it.
V = LV->getLoc(); V = LV->getLoc();
MakeNode(Dst, CastE, N, SetSVal(St, CastE, V)); MakeNode(Dst, CastE, N, BindExpr(St, CastE, V));
continue; continue;
} }
@ -1552,12 +1552,12 @@ void GRExprEngine::VisitCast(Expr* CastE, Expr* Ex, NodeTy* Pred, NodeSet& Dst){
assert(T->isPointerType() || T->isReferenceType()); assert(T->isPointerType() || T->isReferenceType());
V = StateMgr.ArrayToPointer(V); V = StateMgr.ArrayToPointer(V);
MakeNode(Dst, CastE, N, SetSVal(St, CastE, V)); MakeNode(Dst, CastE, N, BindExpr(St, CastE, V));
continue; continue;
} }
// All other cases. // All other cases.
MakeNode(Dst, CastE, N, SetSVal(St, CastE, EvalCast(V, CastE->getType()))); MakeNode(Dst, CastE, N, BindExpr(St, CastE, EvalCast(V, CastE->getType())));
} }
} }
@ -1586,7 +1586,7 @@ void GRExprEngine::VisitCompoundLiteralExpr(CompoundLiteralExpr* CL,
assert (!IVals.empty() && "Initializer cannot be empty."); assert (!IVals.empty() && "Initializer cannot be empty.");
St = StateMgr.BindCompoundLiteral(St, R, &IVals[0], &IVals[0]+IVals.size()); St = StateMgr.BindCompoundLiteral(St, R, &IVals[0], &IVals[0]+IVals.size());
MakeNode(Dst, CL, *I, SetSVal(St, CL, loc::MemRegionVal(R))); MakeNode(Dst, CL, *I, BindExpr(St, CL, loc::MemRegionVal(R)));
} }
} }
@ -1653,7 +1653,7 @@ void GRExprEngine::VisitInitListExpr(InitListExpr* E, NodeTy* Pred,
StateMgr.getBasicVals()); StateMgr.getBasicVals());
// Make final state and node. // Make final state and node.
state = SetSVal(state, E, V); state = BindExpr(state, E, V);
MakeNode(Dst, E, Pred, state); MakeNode(Dst, E, Pred, state);
return; return;
@ -1672,7 +1672,7 @@ void GRExprEngine::VisitInitListExpr(InitListExpr* E, NodeTy* Pred,
Visit(Init, Pred, Tmp); Visit(Init, Pred, Tmp);
for (NodeSet::iterator I = Tmp.begin(), EI = Tmp.end(); I != EI; ++I) { for (NodeSet::iterator I = Tmp.begin(), EI = Tmp.end(); I != EI; ++I) {
state = GetState(*I); state = GetState(*I);
MakeNode(Dst, E, *I, SetSVal(state, E, GetSVal(state, Init))); MakeNode(Dst, E, *I, BindExpr(state, E, GetSVal(state, Init)));
} }
return; return;
} }
@ -1716,8 +1716,8 @@ void GRExprEngine::VisitSizeOfAlignOfTypeExpr(SizeOfAlignOfTypeExpr* Ex,
amt = getContext().getTypeAlign(T) / 8; amt = getContext().getTypeAlign(T) / 8;
MakeNode(Dst, Ex, Pred, MakeNode(Dst, Ex, Pred,
SetSVal(GetState(Pred), Ex, BindExpr(GetState(Pred), Ex,
NonLoc::MakeVal(getBasicVals(), amt, Ex->getType()))); NonLoc::MakeVal(getBasicVals(), amt, Ex->getType())));
} }
@ -1741,7 +1741,7 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, NodeTy* Pred,
SVal location = GetSVal(St, Ex); SVal location = GetSVal(St, Ex);
if (asLValue) if (asLValue)
MakeNode(Dst, U, *I, SetSVal(St, U, location)); MakeNode(Dst, U, *I, BindExpr(St, U, location));
else else
EvalLoad(Dst, U, *I, St, location); EvalLoad(Dst, U, *I, St, location);
} }
@ -1767,7 +1767,7 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, NodeTy* Pred,
// For all other types, UnaryOperator::Real is an identity operation. // For all other types, UnaryOperator::Real is an identity operation.
assert (U->getType() == Ex->getType()); assert (U->getType() == Ex->getType());
const GRState* St = GetState(*I); const GRState* St = GetState(*I);
MakeNode(Dst, U, *I, SetSVal(St, U, GetSVal(St, Ex))); MakeNode(Dst, U, *I, BindExpr(St, U, GetSVal(St, Ex)));
} }
return; return;
@ -1791,7 +1791,7 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, NodeTy* Pred,
assert (Ex->getType()->isIntegerType()); assert (Ex->getType()->isIntegerType());
const GRState* St = GetState(*I); const GRState* St = GetState(*I);
SVal X = NonLoc::MakeVal(getBasicVals(), 0, Ex->getType()); SVal X = NonLoc::MakeVal(getBasicVals(), 0, Ex->getType());
MakeNode(Dst, U, *I, SetSVal(St, U, X)); MakeNode(Dst, U, *I, BindExpr(St, U, X));
} }
return; return;
@ -1816,7 +1816,7 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, NodeTy* Pred,
for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) { for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
const GRState* St = GetState(*I); const GRState* St = GetState(*I);
MakeNode(Dst, U, *I, SetSVal(St, U, GetSVal(St, Ex))); MakeNode(Dst, U, *I, BindExpr(St, U, GetSVal(St, Ex)));
} }
return; return;
@ -1832,7 +1832,7 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, NodeTy* Pred,
for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) { for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
const GRState* St = GetState(*I); const GRState* St = GetState(*I);
SVal V = GetSVal(St, Ex); SVal V = GetSVal(St, Ex);
St = SetSVal(St, U, V); St = BindExpr(St, U, V);
MakeNode(Dst, U, *I, St); MakeNode(Dst, U, *I, St);
} }
@ -1860,7 +1860,7 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, NodeTy* Pred,
// V = EvalCast(V, U->getType()); // V = EvalCast(V, U->getType());
if (V.isUnknownOrUndef()) { if (V.isUnknownOrUndef()) {
MakeNode(Dst, U, *I, SetSVal(St, U, V)); MakeNode(Dst, U, *I, BindExpr(St, U, V));
continue; continue;
} }
@ -1871,12 +1871,12 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, NodeTy* Pred,
case UnaryOperator::Not: case UnaryOperator::Not:
// FIXME: Do we need to handle promotions? // FIXME: Do we need to handle promotions?
St = SetSVal(St, U, EvalComplement(cast<NonLoc>(V))); St = BindExpr(St, U, EvalComplement(cast<NonLoc>(V)));
break; break;
case UnaryOperator::Minus: case UnaryOperator::Minus:
// FIXME: Do we need to handle promotions? // FIXME: Do we need to handle promotions?
St = SetSVal(St, U, EvalMinus(U, cast<NonLoc>(V))); St = BindExpr(St, U, EvalMinus(U, cast<NonLoc>(V)));
break; break;
case UnaryOperator::LNot: case UnaryOperator::LNot:
@ -1889,7 +1889,7 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, NodeTy* Pred,
if (isa<Loc>(V)) { if (isa<Loc>(V)) {
loc::ConcreteInt X(getBasicVals().getZeroWithPtrWidth()); loc::ConcreteInt X(getBasicVals().getZeroWithPtrWidth());
SVal Result = EvalBinOp(BinaryOperator::EQ, cast<Loc>(V), X); SVal Result = EvalBinOp(BinaryOperator::EQ, cast<Loc>(V), X);
St = SetSVal(St, U, Result); St = BindExpr(St, U, Result);
} }
else { else {
nonloc::ConcreteInt X(getBasicVals().getValue(0, Ex->getType())); nonloc::ConcreteInt X(getBasicVals().getValue(0, Ex->getType()));
@ -1922,7 +1922,7 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, NodeTy* Pred,
uint64_t size = getContext().getTypeAlign(T) / 8; uint64_t size = getContext().getTypeAlign(T) / 8;
const GRState* St = GetState(Pred); const GRState* St = GetState(Pred);
St = SetSVal(St, U, NonLoc::MakeVal(getBasicVals(), size, U->getType())); St = BindExpr(St, U, NonLoc::MakeVal(getBasicVals(), size, U->getType()));
MakeNode(Dst, U, Pred, St); MakeNode(Dst, U, Pred, St);
return; return;
@ -1939,7 +1939,7 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, NodeTy* Pred,
uint64_t size = getContext().getTypeSize(T) / 8; uint64_t size = getContext().getTypeSize(T) / 8;
const GRState* St = GetState(Pred); const GRState* St = GetState(Pred);
St = SetSVal(St, U, NonLoc::MakeVal(getBasicVals(), size, U->getType())); St = BindExpr(St, U, NonLoc::MakeVal(getBasicVals(), size, U->getType()));
MakeNode(Dst, U, Pred, St); MakeNode(Dst, U, Pred, St);
return; return;
@ -1969,7 +1969,7 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, NodeTy* Pred,
// Propagate unknown and undefined values. // Propagate unknown and undefined values.
if (V2.isUnknownOrUndef()) { if (V2.isUnknownOrUndef()) {
MakeNode(Dst, U, *I2, SetSVal(St, U, V2)); MakeNode(Dst, U, *I2, BindExpr(St, U, V2));
continue; continue;
} }
@ -1979,7 +1979,7 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, NodeTy* Pred,
: BinaryOperator::Sub; : BinaryOperator::Sub;
SVal Result = EvalBinOp(Op, V2, MakeConstantVal(1U, U)); SVal Result = EvalBinOp(Op, V2, MakeConstantVal(1U, U));
St = SetSVal(St, U, U->isPostfix() ? V2 : Result); St = BindExpr(St, U, U->isPostfix() ? V2 : Result);
// Perform the store. // Perform the store.
EvalStore(Dst, U, *I2, St, V1, Result); EvalStore(Dst, U, *I2, St, V1, Result);
@ -2031,7 +2031,7 @@ void GRExprEngine::VisitAsmStmtHelperInputs(AsmStmt* A,
assert (!isa<NonLoc>(X)); // Should be an Lval, or unknown, undef. assert (!isa<NonLoc>(X)); // Should be an Lval, or unknown, undef.
if (isa<Loc>(X)) if (isa<Loc>(X))
St = SetSVal(St, cast<Loc>(X), UnknownVal()); St = BindLoc(St, cast<Loc>(X), UnknownVal());
} }
MakeNode(Dst, A, Pred, St); MakeNode(Dst, A, Pred, St);
@ -2214,7 +2214,7 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B,
// Simulate the effects of a "store": bind the value of the RHS // Simulate the effects of a "store": bind the value of the RHS
// to the L-Value represented by the LHS. // to the L-Value represented by the LHS.
EvalStore(Dst, B, LHS, *I2, SetSVal(St, B, RightV), LeftV, RightV); EvalStore(Dst, B, LHS, *I2, BindExpr(St, B, RightV), LeftV, RightV);
continue; continue;
} }
@ -2265,7 +2265,7 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B,
// Otherwise, create a new node. // Otherwise, create a new node.
MakeNode(Dst, B, *I2, SetSVal(St, B, Result)); MakeNode(Dst, B, *I2, BindExpr(St, B, Result));
continue; continue;
} }
} }
@ -2305,13 +2305,13 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B,
// Propagate undefined values (left-side). // Propagate undefined values (left-side).
if (V.isUndef()) { if (V.isUndef()) {
EvalStore(Dst, B, LHS, *I3, SetSVal(St, B, V), location, V); EvalStore(Dst, B, LHS, *I3, BindExpr(St, B, V), location, V);
continue; continue;
} }
// Propagate unknown values (left and right-side). // Propagate unknown values (left and right-side).
if (RightV.isUnknown() || V.isUnknown()) { if (RightV.isUnknown() || V.isUnknown()) {
EvalStore(Dst, B, LHS, *I3, SetSVal(St, B, UnknownVal()), location, EvalStore(Dst, B, LHS, *I3, BindExpr(St, B, UnknownVal()), location,
UnknownVal()); UnknownVal());
continue; continue;
} }
@ -2331,7 +2331,7 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B,
// Evaluate operands and promote to result type. // Evaluate operands and promote to result type.
if (RightV.isUndef()) { if (RightV.isUndef()) {
// Propagate undefined values (right-side). // Propagate undefined values (right-side).
EvalStore(Dst, B, LHS, *I3, SetSVal(St, B, RightV), location, RightV); EvalStore(Dst,B, LHS, *I3, BindExpr(St, B, RightV), location, RightV);
continue; continue;
} }
@ -2364,7 +2364,7 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B,
: cast<SVal>(nonloc::SymbolVal(Sym)); : cast<SVal>(nonloc::SymbolVal(Sym));
} }
EvalStore(Dst, B, LHS, *I3, SetSVal(St, B, Result), location, Result); EvalStore(Dst, B, LHS, *I3, BindExpr(St, B, Result), location, Result);
} }
} }
} }

View File

@ -370,9 +370,9 @@ void GRSimpleVals::EvalCall(ExplodedNodeSet<GRState>& Dst,
SVal V = StateMgr.GetSVal(St, *I); SVal V = StateMgr.GetSVal(St, *I);
if (isa<loc::MemRegionVal>(V)) if (isa<loc::MemRegionVal>(V))
St = StateMgr.SetSVal(St, cast<Loc>(V), UnknownVal()); St = StateMgr.BindLoc(St, cast<Loc>(V), UnknownVal());
else if (isa<nonloc::LocAsInteger>(V)) else if (isa<nonloc::LocAsInteger>(V))
St = StateMgr.SetSVal(St, cast<nonloc::LocAsInteger>(V).getLoc(), St = StateMgr.BindLoc(St, cast<nonloc::LocAsInteger>(V).getLoc(),
UnknownVal()); UnknownVal());
} }
@ -389,7 +389,7 @@ void GRSimpleVals::EvalCall(ExplodedNodeSet<GRState>& Dst,
? cast<SVal>(loc::SymbolVal(Sym)) ? cast<SVal>(loc::SymbolVal(Sym))
: cast<SVal>(nonloc::SymbolVal(Sym)); : cast<SVal>(nonloc::SymbolVal(Sym));
St = StateMgr.SetSVal(St, CE, X, Eng.getCFG().isBlkExpr(CE), false); St = StateMgr.BindExpr(St, CE, X, Eng.getCFG().isBlkExpr(CE), false);
} }
Builder.MakeNode(Dst, CE, Pred, St); Builder.MakeNode(Dst, CE, Pred, St);
@ -418,7 +418,7 @@ void GRSimpleVals::EvalObjCMessageExpr(ExplodedNodeSet<GRState>& Dst,
SVal V = StateMgr.GetSVal(St, *I); SVal V = StateMgr.GetSVal(St, *I);
if (isa<Loc>(V)) if (isa<Loc>(V))
St = StateMgr.SetSVal(St, cast<Loc>(V), UnknownVal()); St = StateMgr.BindLoc(St, cast<Loc>(V), UnknownVal());
} }
Builder.MakeNode(Dst, ME, Pred, St); Builder.MakeNode(Dst, ME, Pred, St);

View File

@ -59,8 +59,7 @@ GRStateManager::RemoveDeadBindings(const GRState* St, Stmt* Loc,
LSymbols, DSymbols); LSymbols, DSymbols);
} }
const GRState* GRStateManager::SetSVal(const GRState* St, Loc LV, const GRState* GRStateManager::BindLoc(const GRState* St, Loc LV, SVal V) {
SVal V) {
Store OldStore = St->getStore(); Store OldStore = St->getStore();
Store NewStore = StoreMgr->Bind(OldStore, LV, V); Store NewStore = StoreMgr->Bind(OldStore, LV, V);

View File

@ -35,7 +35,7 @@ void GRTransferFuncs::EvalStore(ExplodedNodeSet<GRState>& Dst,
Builder.MakeNode(Dst, E, Pred, St); Builder.MakeNode(Dst, E, Pred, St);
else else
Builder.MakeNode(Dst, E, Pred, Builder.MakeNode(Dst, E, Pred,
Eng.getStateManager().SetSVal(St, cast<Loc>(TargetLV), Val)); Eng.getStateManager().BindLoc(St, cast<Loc>(TargetLV), Val));
} }
void GRTransferFuncs::EvalBinOpNN(GRStateSet& OStates, void GRTransferFuncs::EvalBinOpNN(GRStateSet& OStates,
@ -44,5 +44,5 @@ void GRTransferFuncs::EvalBinOpNN(GRStateSet& OStates,
BinaryOperator::Opcode Op, BinaryOperator::Opcode Op,
NonLoc L, NonLoc R) { NonLoc L, NonLoc R) {
OStates.Add(StateMgr.SetSVal(St, Ex, DetermEvalBinOpNN(StateMgr, Op, L, R))); OStates.Add(StateMgr.BindExpr(St, Ex, DetermEvalBinOpNN(StateMgr, Op, L, R)));
} }