[cfe-commits] r92101 - /cfe/trunk/lib/Analysis/CFG.cpp
Ted Kremenek
kremenek at apple.com
Wed Dec 23 16:39:26 PST 2009
Author: kremenek
Date: Wed Dec 23 18:39:26 2009
New Revision: 92101
URL: http://llvm.org/viewvc/llvm-project?rev=92101&view=rev
Log:
Add CFG support for the initializer of the condition variable of a SwitchStmt.
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=92101&r1=92100&r2=92101&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Wed Dec 23 18:39:26 2009
@@ -1425,8 +1425,19 @@
SwitchTerminatedBlock->setTerminator(Terminator);
assert (Terminator->getCond() && "switch condition must be non-NULL");
Block = SwitchTerminatedBlock;
-
- return addStmt(Terminator->getCond());
+ Block = addStmt(Terminator->getCond());
+
+ // Finally, if the SwitchStmt contains a condition variable, add both the
+ // SwitchStmt and the condition variable initialization to the CFG.
+ if (VarDecl *VD = Terminator->getConditionVariable()) {
+ if (Expr *Init = VD->getInit()) {
+ autoCreateBlock();
+ AppendStmt(Block, Terminator, AddStmtChoice::AlwaysAdd);
+ addStmt(Init);
+ }
+ }
+
+ return Block;
}
CFGBlock* CFGBuilder::VisitCaseStmt(CaseStmt* CS) {
More information about the cfe-commits
mailing list