Remove Store::bindDecl() and Store::bindDeclWithNoInit(), and

all forwarding methods.

This functionality is already covered by bindLoc().

llvm-svn: 162346
This commit is contained in:
Ted Kremenek 2012-08-22 06:00:18 +00:00
parent 2cd56c4c6e
commit 1afcb7442f
6 changed files with 26 additions and 57 deletions

View File

@ -229,11 +229,9 @@ public:
const LocationContext *LCtx, const LocationContext *LCtx,
SVal location, SVal V) const; SVal location, SVal V) const;
ProgramStateRef bindDecl(const VarRegion *VR, SVal V) const; ProgramStateRef bindLoc(Loc location,
SVal V,
ProgramStateRef bindDeclWithNoInit(const VarRegion *VR) const; bool notifyChanges = true) const;
ProgramStateRef bindLoc(Loc location, SVal V) const;
ProgramStateRef bindLoc(SVal location, SVal V) const; ProgramStateRef bindLoc(SVal location, SVal V) const;

View File

@ -148,10 +148,6 @@ public:
virtual StoreRef removeDeadBindings(Store store, const StackFrameContext *LCtx, virtual StoreRef removeDeadBindings(Store store, const StackFrameContext *LCtx,
SymbolReaper& SymReaper) = 0; SymbolReaper& SymReaper) = 0;
virtual StoreRef BindDecl(Store store, const VarRegion *VR, SVal initVal) = 0;
virtual StoreRef BindDeclWithNoInit(Store store, const VarRegion *VR) = 0;
virtual bool includedInBindings(Store store, virtual bool includedInBindings(Store store,
const MemRegion *region) const = 0; const MemRegion *region) const = 0;

View File

@ -1540,7 +1540,8 @@ void ExprEngine::VisitMemberExpr(const MemberExpr *M, ExplodedNode *Pred,
/// This method is used by evalStore and (soon) VisitDeclStmt, and others. /// This method is used by evalStore and (soon) VisitDeclStmt, and others.
void ExprEngine::evalBind(ExplodedNodeSet &Dst, const Stmt *StoreE, void ExprEngine::evalBind(ExplodedNodeSet &Dst, const Stmt *StoreE,
ExplodedNode *Pred, ExplodedNode *Pred,
SVal location, SVal Val, bool atDeclInit) { SVal location, SVal Val,
bool atDeclInit) {
// Do a previsit of the bind. // Do a previsit of the bind.
ExplodedNodeSet CheckedSet; ExplodedNodeSet CheckedSet;
@ -1548,6 +1549,13 @@ void ExprEngine::evalBind(ExplodedNodeSet &Dst, const Stmt *StoreE,
StoreE, *this, StoreE, *this,
ProgramPoint::PostStmtKind); ProgramPoint::PostStmtKind);
// If the location is not a 'Loc', it will already be handled by
// the checkers. There is nothing left to do.
if (!isa<Loc>(location)) {
Dst = CheckedSet;
return;
}
ExplodedNodeSet TmpDst; ExplodedNodeSet TmpDst;
StmtNodeBuilder Bldr(CheckedSet, TmpDst, *currentBuilderContext); StmtNodeBuilder Bldr(CheckedSet, TmpDst, *currentBuilderContext);
@ -1557,23 +1565,19 @@ void ExprEngine::evalBind(ExplodedNodeSet &Dst, const Stmt *StoreE,
ExplodedNode *PredI = *I; ExplodedNode *PredI = *I;
ProgramStateRef state = PredI->getState(); ProgramStateRef state = PredI->getState();
if (atDeclInit) { // When binding the value, pass on the hint that this is a initialization.
const VarRegion *VR = // For initializations, we do not need to inform clients of region
cast<VarRegion>(cast<loc::MemRegionVal>(location).getRegion()); // changes.
state = state->bindLoc(cast<Loc>(location),
state = state->bindDecl(VR, Val); Val, /* notifyChanges = */ !atDeclInit);
} else {
state = state->bindLoc(location, Val);
}
const MemRegion *LocReg = 0; const MemRegion *LocReg = 0;
if (loc::MemRegionVal *LocRegVal = dyn_cast<loc::MemRegionVal>(&location)) if (loc::MemRegionVal *LocRegVal = dyn_cast<loc::MemRegionVal>(&location)) {
LocReg = LocRegVal->getRegion(); LocReg = LocRegVal->getRegion();
}
const ProgramPoint L = PostStore(StoreE, LC, LocReg, 0); const ProgramPoint L = PostStore(StoreE, LC, LocReg, 0);
Bldr.generateNode(L, state, PredI); Bldr.generateNode(L, state, PredI);
} }
Dst.insert(TmpDst); Dst.insert(TmpDst);
} }

View File

@ -487,7 +487,7 @@ void ExprEngine::VisitDeclStmt(const DeclStmt *DS, ExplodedNode *Pred,
} }
} }
else { else {
B.generateNode(DS, N,state->bindDeclWithNoInit(state->getRegion(VD, LC))); B.generateNode(DS, N, state);
} }
} }
} }

View File

@ -133,24 +133,12 @@ ProgramStateRef ProgramState::bindCompoundLiteral(const CompoundLiteralExpr *CL,
return makeWithStore(newStore); return makeWithStore(newStore);
} }
ProgramStateRef ProgramState::bindDecl(const VarRegion* VR, SVal IVal) const { ProgramStateRef ProgramState::bindLoc(Loc LV, SVal V, bool notifyChanges) const {
const StoreRef &newStore =
getStateManager().StoreMgr->BindDecl(getStore(), VR, IVal);
return makeWithStore(newStore);
}
ProgramStateRef ProgramState::bindDeclWithNoInit(const VarRegion* VR) const {
const StoreRef &newStore =
getStateManager().StoreMgr->BindDeclWithNoInit(getStore(), VR);
return makeWithStore(newStore);
}
ProgramStateRef ProgramState::bindLoc(Loc LV, SVal V) const {
ProgramStateManager &Mgr = getStateManager(); ProgramStateManager &Mgr = getStateManager();
ProgramStateRef newState = makeWithStore(Mgr.StoreMgr->Bind(getStore(), ProgramStateRef newState = makeWithStore(Mgr.StoreMgr->Bind(getStore(),
LV, V)); LV, V));
const MemRegion *MR = LV.getAsRegion(); const MemRegion *MR = LV.getAsRegion();
if (MR && Mgr.getOwningEngine()) if (MR && Mgr.getOwningEngine() && notifyChanges)
return Mgr.getOwningEngine()->processRegionChange(newState, MR); return Mgr.getOwningEngine()->processRegionChange(newState, MR);
return newState; return newState;

View File

@ -280,12 +280,6 @@ public: // Part of public interface to class.
const CompoundLiteralExpr *CL, const CompoundLiteralExpr *CL,
const LocationContext *LC, SVal V); const LocationContext *LC, SVal V);
StoreRef BindDecl(Store store, const VarRegion *VR, SVal InitVal);
StoreRef BindDeclWithNoInit(Store store, const VarRegion *) {
return StoreRef(store, *this);
}
/// BindStruct - Bind a compound value to a structure. /// BindStruct - Bind a compound value to a structure.
StoreRef BindStruct(Store store, const TypedValueRegion* R, SVal V); StoreRef BindStruct(Store store, const TypedValueRegion* R, SVal V);
@ -1567,6 +1561,8 @@ StoreRef RegionStoreManager::Bind(Store store, Loc L, SVal V) {
// Check if the region is a struct region. // Check if the region is a struct region.
if (const TypedValueRegion* TR = dyn_cast<TypedValueRegion>(R)) { if (const TypedValueRegion* TR = dyn_cast<TypedValueRegion>(R)) {
QualType Ty = TR->getValueType(); QualType Ty = TR->getValueType();
if (Ty->isArrayType())
return BindArray(store, TR, V);
if (Ty->isStructureOrClassType()) if (Ty->isStructureOrClassType())
return BindStruct(store, TR, V); return BindStruct(store, TR, V);
if (Ty->isVectorType()) if (Ty->isVectorType())
@ -1596,19 +1592,6 @@ StoreRef RegionStoreManager::Bind(Store store, Loc L, SVal V) {
return StoreRef(addBinding(B, Key, V).getRootWithoutRetain(), *this); return StoreRef(addBinding(B, Key, V).getRootWithoutRetain(), *this);
} }
StoreRef RegionStoreManager::BindDecl(Store store, const VarRegion *VR,
SVal InitVal) {
QualType T = VR->getDecl()->getType();
if (T->isArrayType())
return BindArray(store, VR, InitVal);
if (T->isStructureOrClassType())
return BindStruct(store, VR, InitVal);
return Bind(store, svalBuilder.makeLoc(VR), InitVal);
}
// FIXME: this method should be merged into Bind(). // FIXME: this method should be merged into Bind().
StoreRef RegionStoreManager::bindCompoundLiteral(Store ST, StoreRef RegionStoreManager::bindCompoundLiteral(Store ST,
const CompoundLiteralExpr *CL, const CompoundLiteralExpr *CL,