]> granicus.if.org Git - clang/commitdiff
Teach GRExprEngine to handle the initialization of the condition variable of a WhileStmt.
authorTed Kremenek <kremenek@apple.com>
Thu, 24 Dec 2009 00:54:56 +0000 (00:54 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 24 Dec 2009 00:54:56 +0000 (00:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92106 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/GRExprEngine.cpp
test/Analysis/misc-ps-region-store.cpp

index d7486f85134c98f1b9f5c3a7cd2d54ace6bc8516..06621af19ec8319d247978739c95121041342c5c 100644 (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;      
   }
 }
 
index e9d6d938710fc72b65fbd84de744b8a7456003e7..fcef0516ec0ef431cc47067284bfcc79e9765b8f 100644 (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;
+}