diff --git a/clang/lib/Analysis/GRExprEngine.cpp b/clang/lib/Analysis/GRExprEngine.cpp index d7486f85134c..06621af19ec8 100644 --- a/clang/lib/Analysis/GRExprEngine.cpp +++ b/clang/lib/Analysis/GRExprEngine.cpp @@ -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(S)->getConditionVariable(), S, Pred, Dst); + break; } } diff --git a/clang/test/Analysis/misc-ps-region-store.cpp b/clang/test/Analysis/misc-ps-region-store.cpp index e9d6d938710f..fcef0516ec0e 100644 --- a/clang/test/Analysis/misc-ps-region-store.cpp +++ b/clang/test/Analysis/misc-ps-region-store.cpp @@ -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; +}