diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-02-21 22:11:26 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-02-21 22:11:26 +0000 |
commit | 6b12da9f89b7863e6fc995312355b94197b75657 (patch) | |
tree | b784dd1ae92d24be678456af2323b19dfd4e9ebd /lib/Analysis/CFG.cpp | |
parent | 935f0f01c1ed3c2052b797ac035d57a85b78adc4 (diff) |
Fix a CFGBuilder bug exposed on convoluted control-flow in the Linux kernel.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126149 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/CFG.cpp')
-rw-r--r-- | lib/Analysis/CFG.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp index a0ec5febbe..0957875fd2 100644 --- a/lib/Analysis/CFG.cpp +++ b/lib/Analysis/CFG.cpp @@ -928,11 +928,13 @@ CFGBlock *CFGBuilder::VisitStmt(Stmt *S, AddStmtChoice asc) { /// VisitChildren - Visit the children of a Stmt. CFGBlock *CFGBuilder::VisitChildren(Stmt* Terminator) { - CFGBlock *B = Block; - for (Stmt::child_range I = Terminator->children(); I; ++I) { - if (*I) B = Visit(*I); - } - return B; + CFGBlock *lastBlock = Block; + for (Stmt::child_range I = Terminator->children(); I; ++I) + if (Stmt *child = *I) + if (CFGBlock *b = Visit(child)) + lastBlock = b; + + return lastBlock; } CFGBlock *CFGBuilder::VisitAddrLabelExpr(AddrLabelExpr *A, @@ -1819,6 +1821,7 @@ CFGBlock* CFGBuilder::VisitWhileStmt(WhileStmt* W) { if (badCFG) return 0; LoopSuccessor = Block; + Block = 0; } else LoopSuccessor = Succ; |