[cfe-commits] r92105 - /cfe/trunk/lib/Analysis/CFG.cpp

Ted Kremenek kremenek at apple.com
Wed Dec 23 16:54:37 PST 2009


Author: kremenek
Date: Wed Dec 23 18:54:37 2009
New Revision: 92105

URL: http://llvm.org/viewvc/llvm-project?rev=92105&view=rev
Log:
Add CFG support for the initializer of the condition variable of a WhileStmt.

Modified:
    cfe/trunk/lib/Analysis/CFG.cpp

Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=92105&r1=92104&r2=92105&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Wed Dec 23 18:54:37 2009
@@ -1188,8 +1188,21 @@
   // to this block.  NULL out Block to force lazy creation of another block.
   Block = NULL;
 
-  // Return the condition block, which is the dominating block for the loop.
+  // Set Succ to be the condition block, which is the dominating block
+  // for the loop.
   Succ = EntryConditionBlock;
+  
+  // Finally, if the WhileStmt contains a condition variable, add both the 
+  // WhileStmt and the condition variable initialization to the CFG.
+  if (VarDecl *VD = W->getConditionVariable()) {
+    if (Expr *Init = VD->getInit()) {
+      autoCreateBlock();
+      AppendStmt(Block, W, AddStmtChoice::AlwaysAdd);
+      Succ = addStmt(Init);
+      return Succ;
+    }
+  }
+  
   return EntryConditionBlock;
 }
 





More information about the cfe-commits mailing list