diff options
| author | Ted Kremenek <kremenek@apple.com> | 2009-12-24 00:39:26 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2009-12-24 00:39:26 +0000 |
| commit | 8b5dc12e52f1d8e8a422f034760fad24b825ad00 (patch) | |
| tree | cb9f2c7be94986745835d5b5af2d371403dc14d4 /clang/lib/Analysis | |
| parent | ee7553de6288f87a8cfbbe9699b87df42a739e0d (diff) | |
| download | bcm5719-llvm-8b5dc12e52f1d8e8a422f034760fad24b825ad00.tar.gz bcm5719-llvm-8b5dc12e52f1d8e8a422f034760fad24b825ad00.zip | |
Add CFG support for the initializer of the condition variable of a SwitchStmt.
llvm-svn: 92101
Diffstat (limited to 'clang/lib/Analysis')
| -rw-r--r-- | clang/lib/Analysis/CFG.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp index 023ac2b7e6e..cfdee4927bb 100644 --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/lib/Analysis/CFG.cpp @@ -1425,8 +1425,19 @@ CFGBlock* CFGBuilder::VisitSwitchStmt(SwitchStmt* Terminator) { 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) { |

