summaryrefslogtreecommitdiffstats
path: root/clang/AST/CFG.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Minor cleanups to pretty-printing for loops in CFGs.Ted Kremenek2007-08-301-4/+4
| | | | llvm-svn: 41623
* Fixed a bug in constructing CFG blocks for case statement fall-throughTed Kremenek2007-08-301-3/+5
| | | | | | | | | | introduced by moving "CaseStmt" pointers out of the list of statements and into the explicit "label" associated with a CFGBlock. --This line, and those below, will be ignored-- M AST/CFG.cpp llvm-svn: 41622
* Fixed bug in CFG construction where we failed to handle loop bodies withTed Kremenek2007-08-301-9/+18
| | | | | | no statements (or just full of ';' statements). llvm-svn: 41620
* Fixed bug in CFG construction involving use of labels and "empty"Ted Kremenek2007-08-301-2/+4
| | | | | | | | blocks involving only ';' statements. We now correctly handle the following: void empty_label() { l1: ; } llvm-svn: 41619
* Fixed bug where the CFG would fail to build when an 'if' statement hadTed Kremenek2007-08-301-7/+14
| | | | | | | | | | | | | an empty then or else block (or contained only ';' statements). For example, we now handle the following: int empty_else() { if (0) { int a; } else ; } int empty_then() { if (0) ; else { int a; } } Thanks to Nico Weber for spotting this problem. llvm-svn: 41617
* Added an (optional) explicit "Label" statement to CFGBlock. If aTed Kremenek2007-08-291-47/+60
| | | | | | | | | | | | block begins with a label or case statement, CFGBlock::getLabel() will return the corresponding LabelStmt/CaseStmt/DefaultStmt. LabelStmts and SwitchCases no longer appear within the "executable" statements of a CFGBlock. More cleanups on visualization/pretty-printing of CFGs (less verbose). llvm-svn: 41585
* Added GraphTraits to source-level CFGs (CFG and CFGBlock) to allowTed Kremenek2007-08-291-32/+70
| | | | | | | | | | | | | | | | | | | | (LLVM-provided) graph algorithms such as DFS and graph visualization to work effortless on source-level CFGs. Further cleanup on pretty printing of CFGs. CFGBlock::dump and CFGBlock::print now take the parent CFG as an argument. This allows CFGBlocks to print their own appropriate label indicating whether or not they are the Entry/Exit/IndirectGotoBlock without the CFG::print routine doing it instead. Added Graphviz visualization for CFGs: CFG::viewCFG. This employs the GraphTraits just implemented. Added "-view-cfg" mode the to clang driver. This is identical to "-dump-cfg" except that it calls Graphviz to visualize the CFGs instead of dumping them to the terminal. llvm-svn: 41580
* Added support for indirect-gotos (GCC extension) in source-level CFGs.Ted Kremenek2007-08-281-4/+63
| | | | | | | | | | This involves the construction of a specialized "dispatch" block that all basic blocks containing indirect gotos unconditionally transfer control-flow to. The successors of the dispatch block has as its successors all of the blocks containing labels whose address was taken somewhere in the function. llvm-svn: 41554
* Added support for GCC-style statement expressions in source-level CFGs.Ted Kremenek2007-08-281-0/+11
| | | | llvm-svn: 41549
* Added support for comma expressions and DeclStmts which may haveTed Kremenek2007-08-281-4/+34
| | | | | | arbitrarily complex control-flow in their subexpressions. llvm-svn: 41547
* Removed special-casing in CFG construction for ParenExprs.Ted Kremenek2007-08-281-10/+1
| | | | llvm-svn: 41540
* Added support for short-circuit '&&' and '||' operators in source-level CFGs.Ted Kremenek2007-08-271-6/+35
| | | | llvm-svn: 41520
* Implemented support for ternary "?" operators in source-level CFGs.Ted Kremenek2007-08-271-3/+77
| | | | llvm-svn: 41514
* Changes to CFGBuilder:Ted Kremenek2007-08-271-87/+120
| | | | | | | | | | | | | | | | | | | | | | + 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). llvm-svn: 41508
* No functionality change. Moved visitor methods for CFGBuilder out-of-lineTed Kremenek2007-08-231-515/+540
| | | | | | | from the class declaration. This enables a nice view of what visitor methods have been implemented. llvm-svn: 41337
* moved CFGBuilder into an anonymous namespaceTed Kremenek2007-08-231-12/+11
| | | | llvm-svn: 41334
* Added support for switch, default, and case statements in source-level CFGs.Ted Kremenek2007-08-231-2/+73
| | | | llvm-svn: 41332
* For gotos, breaks, and continues where we cannot find a target successorTed Kremenek2007-08-231-9/+10
| | | | | | | | 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. llvm-svn: 41327
* Added support for do..while loops in CFG construction.Ted Kremenek2007-08-231-0/+67
| | | | llvm-svn: 41325
* Renamed "CFG::BuildCFG" to "CFG::buildCFG" to have more consistent ↵Ted Kremenek2007-08-231-33/+52
| | | | | | | | | | | | | | capitalization. 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. llvm-svn: 41323
* Fixed bugs in source-level CFG construction for "for" and "while" loopsTed Kremenek2007-08-221-36/+54
| | | | | | | | 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. llvm-svn: 41302
* Added support for "break" statements in source-level ASTs.Ted Kremenek2007-08-221-4/+31
| | | | | | Some comment cleanups. llvm-svn: 41299
* Added support for "continue" statements in source-level CFGsTed Kremenek2007-08-221-14/+50
| | | | | | | Cleaned up some code for "for" and "while" loops by making their implementations more symmetrical (and added a few comments). llvm-svn: 41298
* Added preliminary support for while loops within source-level CFGs.Ted Kremenek2007-08-221-6/+61
| | | | | | | 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. llvm-svn: 41294
* Added CFG support for: for loopsTed Kremenek2007-08-221-32/+126
| | | | | | | | | | | | | 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. llvm-svn: 41281
* Changed data structure recording the CFG blocks that need to be backpatchedTed Kremenek2007-08-221-1/+1
| | | | | | to labeled blocks from a list to a vector. llvm-svn: 41274
* Added CFG support for gotos and labels.Ted Kremenek2007-08-211-19/+86
| | | | | | | Modified CFG so that getEntry(), getExit(), front() and back() return CFGBlock& instead of CFGBlock*. llvm-svn: 41258
* Converted CFGBuilder to use StmtVisitor instead of doing a switchTed Kremenek2007-08-211-156/+117
| | | | | | dispatch to walk the AST. llvm-svn: 41254
* Added CFG infrastructure (CFG.cpp and CFG.h) for clang ASTs.Ted Kremenek2007-08-211-0/+351
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. llvm-svn: 41252
OpenPOWER on IntegriCloud