aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/GRExprEngine.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-02-14 01:54:57 +0000
committerTed Kremenek <kremenek@apple.com>2009-02-14 01:54:57 +0000
commit5b8d9019e317e3e0abc4ad1d89066908413339aa (patch)
tree249130cd0e04a53f529b7919365ca2fab9369ff8 /lib/Analysis/GRExprEngine.cpp
parent370ab3f1373841d70582feac9e35c3c6b3489f63 (diff)
Use GRTransferFuncs::EvalBind when processing variable initializations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64527 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/GRExprEngine.cpp')
-rw-r--r--lib/Analysis/GRExprEngine.cpp60
1 files changed, 34 insertions, 26 deletions
diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp
index f0e93de219..9b02af44e1 100644
--- a/lib/Analysis/GRExprEngine.cpp
+++ b/lib/Analysis/GRExprEngine.cpp
@@ -1794,28 +1794,6 @@ void GRExprEngine::VisitDeclStmt(DeclStmt* DS, NodeTy* Pred, NodeSet& Dst) {
const GRState* state = GetState(*I);
unsigned Count = Builder->getCurrentBlockCount();
- // Decls without InitExpr are not initialized explicitly.
- if (InitEx) {
- SVal InitVal = GetSVal(state, InitEx);
- QualType T = VD->getType();
-
- // Recover some path-sensitivity if a scalar value evaluated to
- // UnknownVal.
- if (InitVal.isUnknown()) {
- if (Loc::IsLocType(T)) {
- SymbolRef Sym = SymMgr.getConjuredSymbol(InitEx, Count);
- InitVal = loc::SymbolVal(Sym);
- }
- else if (T->isIntegerType() && T->isScalarType()) {
- SymbolRef Sym = SymMgr.getConjuredSymbol(InitEx, Count);
- InitVal = nonloc::SymbolVal(Sym);
- }
- }
-
- state = StateMgr.BindDecl(state, VD, InitVal);
- } else
- state = StateMgr.BindDeclWithNoInit(state, VD);
-
// Check if 'VD' is a VLA and if so check if has a non-zero size.
QualType T = getContext().getCanonicalType(VD->getType());
if (VariableArrayType* VLA = dyn_cast<VariableArrayType>(T)) {
@@ -1831,10 +1809,10 @@ void GRExprEngine::VisitDeclStmt(DeclStmt* DS, NodeTy* Pred, NodeSet& Dst) {
}
continue;
}
-
+
bool isFeasibleZero = false;
const GRState* ZeroSt = Assume(state, Size, false, isFeasibleZero);
-
+
bool isFeasibleNotZero = false;
state = Assume(state, Size, true, isFeasibleNotZero);
@@ -1849,8 +1827,38 @@ void GRExprEngine::VisitDeclStmt(DeclStmt* DS, NodeTy* Pred, NodeSet& Dst) {
if (!isFeasibleNotZero)
continue;
}
-
- MakeNode(Dst, DS, *I, state);
+
+ // Decls without InitExpr are not initialized explicitly.
+ if (InitEx) {
+ SVal InitVal = GetSVal(state, InitEx);
+ QualType T = VD->getType();
+
+ // Recover some path-sensitivity if a scalar value evaluated to
+ // UnknownVal.
+ if (InitVal.isUnknown()) {
+ if (Loc::IsLocType(T)) {
+ SymbolRef Sym = SymMgr.getConjuredSymbol(InitEx, Count);
+ InitVal = loc::SymbolVal(Sym);
+ }
+ else if (T->isIntegerType() && T->isScalarType()) {
+ SymbolRef Sym = SymMgr.getConjuredSymbol(InitEx, Count);
+ InitVal = nonloc::SymbolVal(Sym);
+ }
+ }
+
+ state = StateMgr.BindDecl(state, VD, InitVal);
+
+ // The next thing to do is check if the GRTransferFuncs object wants to
+ // update the state based on the new binding. If the GRTransferFunc
+ // object doesn't do anything, just auto-propagate the current state.
+ GRStmtNodeBuilderRef BuilderRef(Dst, *Builder, *this, *I, state, DS,true);
+ getTF().EvalBind(BuilderRef, loc::MemRegionVal(StateMgr.getRegion(VD)),
+ InitVal);
+ }
+ else {
+ state = StateMgr.BindDeclWithNoInit(state, VD);
+ MakeNode(Dst, DS, *I, state);
+ }
}
}