Teach GRExprEngine to handle the initialization of the condition variable of a WhileStmt.

llvm-svn: 92106
This commit is contained in:
Ted Kremenek 2009-12-24 00:54:56 +00:00
parent 1f07b4c439
commit 09bc3b7df6
2 changed files with 21 additions and 0 deletions

View File

@ -751,6 +751,12 @@ void GRExprEngine::Visit(Stmt* S, ExplodedNode* Pred, ExplodedNodeSet& Dst) {
VisitUnaryOperator(U, Pred, Dst, false);
break;
}
case Stmt::WhileStmtClass:
// This case isn't for branch processing, but for handling the
// initialization of a condition variable.
VisitCondInit(cast<WhileStmt>(S)->getConditionVariable(), S, Pred, Dst);
break;
}
}

View File

@ -59,3 +59,18 @@ int test_init_in_condition_switch() {
}
return 0;
}
int test_init_in_condition_while() {
int y = 1;
while (int x = test_init_in_condition_aux()) { // no-warning
if (!x) {
y = 0;
break;
}
}
if (!y) {
int *p = 0;
*p = 0xDEADBEEF; // no-warning
}
return 0;
}