summaryrefslogtreecommitdiffstats
path: root/clang/AST/CFG.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Make a major restructuring of the clang tree: introduce a top-levelChris Lattner2008-03-151-1509/+0
| | | | | | | | | | lib dir and move all the libraries into it. This follows the main llvm tree, and allows the libraries to be built in parallel. The top level now enforces that all the libs are built before Driver, but we don't care what order the libs are built in. This speeds up parallel builds, particularly incremental ones. llvm-svn: 48402
* Small bug fix in CFG construction: the active block for LabelStmts comes Ted Kremenek2008-03-151-2/+3
| | | | | | from "Block", not the CFGBlock* returned from visiting its subexpression. llvm-svn: 48392
* Added bandaid support in CFG construction for ObjCForEachStmt and ObjCAtTryStmt:Ted Kremenek2008-03-131-0/+21
| | | | | | | | | | we gracefully back out and return NULL for the CFG, allowing clients to skip analyzing functions with these CFGs. We will add support later. Modified base ASTConsumer "CFGVisitor" to detect when a CFG is not constructed and to emit a warning. llvm-svn: 48322
* Add some missing #includes for GCC mainline, patch by Shantonu Sen!Chris Lattner2008-03-101-1/+1
| | | | llvm-svn: 48153
* CallExprs are now no longer block-level expressions in the CFG by construction.Ted Kremenek2008-03-041-12/+0
| | | | llvm-svn: 47913
* Minor CFG optimization: don't create separate block-level expressions for ↵Ted Kremenek2008-02-291-1/+14
| | | | | | DeclStmt initializers when the initializer is a literal. llvm-svn: 47771
* Fixed edge-case in CFG construction where goto jumps would not always getTed Kremenek2008-02-271-1/+4
| | | | | | properly back-patched. llvm-svn: 47675
* Bug fix in CFG construction: Properly register the loop head as the implicitTed Kremenek2008-02-271-3/+4
| | | | | | successor of blocks created above it. llvm-svn: 47666
* Fixed CFG construction bug that occurred when a condition for a loop spannedTed Kremenek2008-02-271-3/+4
| | | | | | | | multiple basic blocks (which can happen when they contain '&&', '||', '?'). The bug was that the loop backedge when to the last block in the loop condition, not the first. llvm-svn: 47649
* Do include ParenExpr in the CFG; only include their subexpression.Ted Kremenek2008-02-261-0/+3
| | | | llvm-svn: 47588
* Fixed bug in CFG construction when a CompoundStmt ended with a NullStmt.Ted Kremenek2008-02-261-10/+6
| | | | | | This caused the whole body to get dropped from the CFG. llvm-svn: 47579
* When creating the CFGBlocks for a switch statement, we now have the "default"Ted Kremenek2008-02-131-18/+41
| | | | | | | | | | | | | | | | | | | | | | branch ALWAYS be the last successor for a switch-terminated block. This allows clients to distinguish cases like the following: switch(...) case XXX: switch(...) { case YYY: ... } case ZZZ: .. } In this case, the block with "case ZZZ:" is the default block for the inner switch statement, but that case is associated with the outer switch statement, and not the inner one. Clients can test for this behavior by checking if a successor block is the last one (and thus just assume that this is the "default" case). llvm-svn: 47088
* Fixed bug in CFG construction when processing switch statements that contain noTed Kremenek2008-02-131-0/+16
| | | | | | | | "default" case. In such cases, we now correctly add the CFGBlock representing the code after the switch statement as a successor to the block terminated by the switch statement. llvm-svn: 47087
* Added method "printTerminator" to CFGBlock so that external clients canTed Kremenek2008-01-301-12/+14
| | | | | | | | | | pretty-print a block's terminator. When building CFGs, for IfStmts ('if'), we no longer add the ParenExpr that is the subexpression of the IfStmt to the CFG; instead we add its first descendant subexpression that is not a ParenExpr. llvm-svn: 46580
* Added back logic in patch r46361 ↵Ted Kremenek2008-01-261-8/+40
| | | | | | | | | | | | (http://llvm.org/viewvc/llvm-project?rev=46361&view=rev) with the addition of some previously missing NULL pointer checks. Modified the UninitializedValues analysis to not expect that every Expr* at the block-level is a block-level expression (we probably need to change the name of such expressions to something truer to their meaning). llvm-svn: 46380
* Reverting r46361 (http://llvm.org/viewvc/llvm-project?rev=46361&view=rev) untilTed Kremenek2008-01-251-35/+8
| | | | | | I diagnose the source of the failures it causes in the test suite. llvm-svn: 46376
* When adding assignment expressions to the set of block-level expressions, onlyTed Kremenek2008-01-251-8/+35
| | | | | | | include the assignment expressions whose result (as in the value of the expression) is used by other expressions. llvm-svn: 46361
* Modified the notion of "Block-level expressions" in CFGs to include Stmt*. ThisTed Kremenek2008-01-171-11/+15
| | | | | | | | | | | | | | | | | | | | | | | | is because GNU-style Statement-expressions cause the last statement in the statement-expression to act like an expression. We now have two notions: block-level statements and block-level expressions. The former are all Stmt* that appear in the list of statements in CFGBlocks. The latter is the subset of the former; these block-level statements are used as subexpressions somewhere in the AST. CFG::isBlockExpr() returns true for the latter, not the former (previously isBlockExpr() always returned true for non-Expr Stmt*). Modified the LiveVariables analysis to also track liveness state for block-level expressions (using the updated definition of block-level expressions). Modified the dataflow solver so that when it records values for block-level statements, it records the dataflow value *before* the transfer function for a Stmt* is evaluated (not after). This is more in sync in what clients will want. Modified CFGStmtVisitor to record the current block-level statement. llvm-svn: 46143
* Renamed ProgramEdge to ProgramPoint and changed subclasses of ProgramEdgeTed Kremenek2008-01-111-0/+15
| | | | | | | to have a much simpler, cleaner interpretation of what is a "location" in a function (as encoded by a CFG). llvm-svn: 45846
* Added VISIBILITY_HIDDEN to classes/structs in anonymous namespace.Ted Kremenek2008-01-081-6/+7
| | | | llvm-svn: 45749
* Don't attribute in file headers anymore. See llvmdev for theChris Lattner2007-12-291-2/+2
| | | | | | discussion of this change. llvm-svn: 45410
* Fixed successor order for CFG basic blocks when handling: x && y. The bugTed Kremenek2007-12-211-3/+12
| | | | | | | | | | | | | | | | | | is best explained by illustration: [ B2 ] 1: x T: [B2.1] && ... Predecessors (1): B4 Successors (2): B3 B1 Block "B3" should be the block where we evaluate "y" when "x" evaluates to true. Previously we had the successor list reversed. Now this behavior matches with how we handle other conditional branches. Thanks to Nuno Lopes for reporting this problem. llvm-svn: 45288
* Removed CFG.cpp's dependence on #including iostream.Ted Kremenek2007-12-171-3/+3
| | | | llvm-svn: 45116
* CFG bug fix: for sizeof(expressions), don't expand the control-flowTed Kremenek2007-12-131-6/+21
| | | | | | of "expressions", since they are not really evaluated. llvm-svn: 45015
* Fixed bug in CFG::PopulateBlkExprMap where the orderingTed Kremenek2007-12-101-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | between fetching the size of the expression map (for use as the next integer id for an Expr*) and the creation of the entry in the map could be non-deterministic. This could cause the size of the map to be incremented prior to the index being determine. On Linux the map entry would be created first, causing the map to the "size" to be incremented prior to it being queried. On Mac OS X we had the reverse behavior. Now the size is always queried prior to the new id being inserted into the map. This was the real cause of the bit-overrun triggered in PR 1847: http://llvm.org/bugs/show_bug.cgi?id=1847 Also reverted the change in patch 44813, which was a bogus fix to this problem: http://llvm.org/viewvc/llvm-project?rev=44813&view=rev llvm-svn: 44822
* Fixed bug in CFG construction where we did not properly handle the GCCTed Kremenek2007-11-261-5/+34
| | | | | | | | | | | | extension "?:" for the ternary operator, e.g.: x ?: y; This expression is represented in the clang ASTs as a ConditionalOperator whose LHS expression is NULL. Now we handle this special case, causing the block containing the condition to be a predecessor to the block that "merges" the values of the ternary operator. Thanks to Nuno Lopes for identifying and diagnosing this bug! llvm-svn: 44327
* Fixed bug in WalkaST_VisitDeclSubExprs where we failed to properly check ifTed Kremenek2007-11-181-3/+4
| | | | | | | | | | the StmtIterator referring to the initializers of a chain of Decls was equal to the "end" iterator. The particular bug manifested when an iterator was created on a chain of decls with no initializers. Thanks to Nuno Lopes for reporting this bug and providing a patch. llvm-svn: 44220
* Refactored CFG construction code that processes DeclStmts to use StmtIterator.Ted Kremenek2007-10-301-23/+21
| | | | | | | Now CFG construction transparently supports Variable Length Array declarations with expressions for their sizes, and typedefs that include VLAs. llvm-svn: 43520
* Modified CFG pretty-printing to directly use the (reverse) bodyTed Kremenek2007-10-291-1/+1
| | | | | | iterator of a CompountStmt instead of relying on StmtIterators. llvm-svn: 43469
* remove dead #includeChris Lattner2007-10-181-1/+0
| | | | llvm-svn: 43149
* Migrated LiveVariables and UninitializedVariables to now use theTed Kremenek2007-10-011-0/+2
| | | | | | tracked BlkExpr information now maintained by the CFG class. llvm-svn: 42498
* CFG objects now internally store a (lazily created) map from block-levelTed Kremenek2007-10-011-1/+49
| | | | | | | | expressions to IDs. This is used by various dataflow analyses, but is also useful for anyone querying a CFG to determine where an expression is evaluated. llvm-svn: 42495
* Removed "hasImplicitControlFlow" from class CFG, and moved it to class StmtTed Kremenek2007-10-011-24/+0
| | | | | | | | as a member function. This function is no longer needed within the CFG class, and logically belongs to the Stmt class as a predicate for a Stmt instance. llvm-svn: 42489
* Fix some use of uninit variables issues, reported by Anton.Chris Lattner2007-09-271-1/+1
| | | | llvm-svn: 42396
* Fixed two bugs in CFG construction:Ted Kremenek2007-09-261-14/+11
| | | | | | | | | | | | | | | | | | BUG 1) CFG failed to build for empty functions, or functions containing only NullStmts or empty compound statements. We now handle such cases, although now we cannot test for CFG construction failure by asserting that the last block constructed is not NULL (since it now may be). BUG 2) CFG construction segfaulted on some cases when walking the AST and not taking into account that some children of a statement may be NULL. llvm-svn: 42370
* When building CFGs we now (unconditionally) add an empty CFGBlock to the CFGTed Kremenek2007-09-171-6/+6
| | | | | | | | to serve as the entry block. An empty entry block (just as with an empty exit block, which we already have) simplifies building analyses on top of CFGs with very little extra overhead. llvm-svn: 42031
* Fixed unterminated string issue.Hartmut Kaiser2007-09-171-1/+1
| | | | llvm-svn: 42022
* make var in anon namespace static. Use \n instead of std::endl.Chris Lattner2007-09-171-4/+2
| | | | llvm-svn: 42020
* fix warning.Chris Lattner2007-09-161-1/+1
| | | | llvm-svn: 42006
* Fixed a problem VC++ revealed in release mode. Please verify.Hartmut Kaiser2007-09-161-1/+1
| | | | llvm-svn: 41996
* Fixed two problems VC++ revealed in release mode. Please verify.Hartmut Kaiser2007-09-161-0/+4
| | | | llvm-svn: 41995
* Added static method "CFG::hasImplicitControlFlow".Ted Kremenek2007-09-111-0/+24
| | | | | | | | | | | | | | | | | | | | | This method is used to determine if an expression contains implicit control-flow, and thus appears in a distinct statement slot in the CFG. For example: (1) x = ... ? ... ? ... logically becomes: (1) ... ? ... : ... (a unique statement slot for the ternary ?) (2) x = [E1] (where E1 is actually the ConditionalOperator*) A client of the CFG, when walking the statement at (2), will encounter E1. In this case, hasImplicitControlFlow(E1) == true, and the client will know that the expression E1 is explicitly placed into its own statement slot to capture the implicit control-flow it has. llvm-svn: 41868
* Fixed bug where ternary expressions and GCC-style conditional expressions Ted Kremenek2007-09-111-1/+18
| | | | | | | | | | where not reversing the order of their subexpression blocks. Added feature where CallExprs are placed in their own statement slot in a CFGBlock. Thus we have a designated "return site" within a CFGBlock when reasoning about function calls. llvm-svn: 41866
* Moved tracking of CFG block IDs into the CFG class.Ted Kremenek2007-09-051-6/+4
| | | | | | Added CFG::getNumBlockIDs() to query the number of distinct block ids created. llvm-svn: 41724
* Fixed missing '(' and ')' characters in (CFG) pretty-printing ofTed Kremenek2007-08-311-2/+2
| | | | | | statement expressions. llvm-svn: 41659
* Added better pretty printing in CFGs for __builtin_choose_exprTed Kremenek2007-08-311-0/+6
| | | | llvm-svn: 41658
* Further cleanups in CFG printing for comma expressions, statement ↵Ted Kremenek2007-08-311-10/+48
| | | | | | expressions, and indirect gotos. llvm-svn: 41657
* Cleanups for printing the terminators of CFGBlocks for "?", "||", and "&&" ↵Ted Kremenek2007-08-311-2/+28
| | | | | | operators. llvm-svn: 41654
* Added "PrinterHelper" interface (include/AST/PrinterHelper) that canTed Kremenek2007-08-311-80/+171
| | | | | | | | | | | | | | | | be passed as an (optional) argument to StmtPrinter to customize printing of AST nodes. Used new PrinterHelper interface to enhance printing and visualization of CFGs. The CFGs now illustrate the semantic connectives between statements and terminators, wheras in the previous printing certain expressions would (visible) be printed multiple times to reflect which expressions used the results of other expressions. The end result is that the CFG is easier to read for flow of expression values (following principles similar to the LLVM IR). llvm-svn: 41651
* Added support for __builtin_choose_expr (ChooseExpr) in CFGs.Ted Kremenek2007-08-311-0/+22
| | | | llvm-svn: 41646
OpenPOWER on IntegriCloud