+ Added the creation of an empty Entry block at the end of CFG
construction if the Entry block in the CFG contains multiple
predecessors (which can happen with labels and do loops).
+ Fixed bug in the creation of an empty Exit block with functions where not
all paths end in a return statement (but some do). Basic blocks with
return statements were jumping to a (sometimes) non-empty block.
+ FinishBlock no longer checks for labels at the beginning of a basic
block before reversing the statements in the block. This is because
the recursion invariants of the builder methods have been cleaned up,
and blocks are only passed to FinishBlock at most once.
+ Modified handling of "if", "for", "while", "do", and "switch" to allow
condition expressions that can span multiple basic blocks. This allows
such conditions to contain short-circuit expressions (which span multiple
blocks in the CFG).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41508 91177308-0d34-0410-b5e6-96231b3b80d8
from the class declaration. This enables a nice view of what visitor methods
have been implemented.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41337 91177308-0d34-0410-b5e6-96231b3b80d8
block (because we are creating a CFG from an incomplete AST) we now
(gracefully) have a block ending with such statements not have any successors
instead of firing an assertion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41327 91177308-0d34-0410-b5e6-96231b3b80d8
Added explicit "Exit" CFGBlock pointer to the source-level CFG.
Changed the construction of blocks with "return" statements to have the
return statement appear both as a statement in the list of statements for
a CFGBlock as well as appear as a control-flow terminator. Also removed
the implicit linearization of "return" so that the return value and the
return statement did not appear as separate statements in the block.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41323 91177308-0d34-0410-b5e6-96231b3b80d8
where break targets weren't being set and restored properly. Also
cleaned up CFGBuilder code for "for" and "while" to use less reliance
on globals and to have clearer semantics.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41302 91177308-0d34-0410-b5e6-96231b3b80d8
Cleaned up some code for "for" and "while" loops by making their
implementations more symmetrical (and added a few comments).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41298 91177308-0d34-0410-b5e6-96231b3b80d8
Adjusted printing of source-level CFGs to account that the entry block
may not be the first block in the list of blocks a CFG object maintains.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41294 91177308-0d34-0410-b5e6-96231b3b80d8
In CFG dumper, refactored the code to print block terminators into a
StmtVisitor.
Added the method "FinishBlock" to CFGBuilder to do the reversal of statements
in a block instead of calling "reverseStmts" for a block directly. This
was necessary to fix a bug in how blocks with labels were being processed
(some cases would cause the statements to be reversed twice). FinishBlock
detects blocks that start with labels and doesn't do a second reversal.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41281 91177308-0d34-0410-b5e6-96231b3b80d8
Modified CFG so that getEntry(), getExit(), front() and back() return
CFGBlock& instead of CFGBlock*.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41258 91177308-0d34-0410-b5e6-96231b3b80d8
Added builder code to translate ASTs to CFGs. This currently supports
if, return, and non-control flow statements.
Added pretty-printer to debug CFGs.
Added a "-dump-cfg" option to the clang driver to dump CFGs for code
sent through the frontend.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41252 91177308-0d34-0410-b5e6-96231b3b80d8