From 58b87feeaedce7ef09c2931a39d82e5aea189f41 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Thu, 24 Dec 2009 01:49:06 +0000 Subject: [PATCH] Add CFG support for the initializer of the condition variable of a ForStmt. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92113 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/CFG.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp index a317e0452c..eab7da7e83 100644 --- a/lib/Analysis/CFG.cpp +++ b/lib/Analysis/CFG.cpp @@ -888,6 +888,19 @@ CFGBlock* CFGBuilder::VisitForStmt(ForStmt* F) { if (Stmt* C = F->getCond()) { Block = ExitConditionBlock; EntryConditionBlock = addStmt(C); + assert(Block == EntryConditionBlock); + + // If this block contains a condition variable, add both the condition + // variable and initializer to the CFG. + if (VarDecl *VD = F->getConditionVariable()) { + if (Expr *Init = VD->getInit()) { + autoCreateBlock(); + AppendStmt(Block, F, AddStmtChoice::AlwaysAdd); + EntryConditionBlock = addStmt(Init); + assert(Block == EntryConditionBlock); + } + } + if (Block) { if (!FinishBlock(EntryConditionBlock)) return 0; -- 2.50.1