forked from OSchip/llvm-project
Add CFG support for the initializer of the condition variable of a SwitchStmt.
llvm-svn: 92101
This commit is contained in:
parent
ee7553de62
commit
8b5dc12e52
|
@ -1425,8 +1425,19 @@ CFGBlock* CFGBuilder::VisitSwitchStmt(SwitchStmt* Terminator) {
|
||||||
SwitchTerminatedBlock->setTerminator(Terminator);
|
SwitchTerminatedBlock->setTerminator(Terminator);
|
||||||
assert (Terminator->getCond() && "switch condition must be non-NULL");
|
assert (Terminator->getCond() && "switch condition must be non-NULL");
|
||||||
Block = SwitchTerminatedBlock;
|
Block = SwitchTerminatedBlock;
|
||||||
|
Block = addStmt(Terminator->getCond());
|
||||||
return 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) {
|
CFGBlock* CFGBuilder::VisitCaseStmt(CaseStmt* CS) {
|
||||||
|
|
Loading…
Reference in New Issue