summaryrefslogtreecommitdiffstats
path: root/clang/AST
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix a comment.Steve Naroff2007-08-301-3/+2
| | | | llvm-svn: 41618
* 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
* Polish yesterday's Array/ConstantArray/VariableArray rewrite, removing a ↵Steve Naroff2007-08-302-24/+19
| | | | | | | | | couple FIXME's. Refactored Array/VariableArray, moving SizeModifier/IndexTypeQuals back up to Array. These attributes are not specific to VLA's. Most of them are specific to array parameter types. llvm-svn: 41616
* implement pretty printing of offsetofChris Lattner2007-08-301-0/+28
| | | | llvm-svn: 41615
* implement initial sema support for __builtin_offsetofChris Lattner2007-08-301-0/+1
| | | | llvm-svn: 41613
* Fixed bug for CaseStmt where the child_begin/child_end methods were notTed Kremenek2007-08-301-3/+7
| | | | | | | | | | | including the expressions in the case statement itself (not the body of the case). This required moving SubStmt out of SwitchCase into CaseStmt and DefaultStmt respectively. getSubStmt() now is a virtual call for SwitchCase, but is a direct (static) call for CaseStmt and DefaultStmt. llvm-svn: 41609
* fix a bug that is causing CodeGen/complex.c to be grumpy.Chris Lattner2007-08-301-1/+1
| | | | llvm-svn: 41603
* Teach the stmtdumper to dump location/range info when a SourceMgr is available.Chris Lattner2007-08-301-6/+64
| | | | | | | | | | | | | | | | | | | | | For example, -parse-ast-dump now prints: static inline int __inline_isinff(float __x) (CompoundStmt 0x2409a20 (ReturnStmt 0x2409a10 (BinaryOperator 0x24099f0 'int' <///usr/include/architecture/i386/math.h:183:63, col:102> '==' (CallExpr 0x24098f0 'float' <col:63, col:82> (ImplicitCastExpr 0x24098e0 'float (*)(float)' <col:63> (DeclRefExpr 0x2409880 'float (float)' <col:63> Decl='__builtin_fabsf' 0x2409840)) (DeclRefExpr 0x24098a0 'float' <col:79> Decl='__x' 0x2409810)) (CallExpr 0x24099c0 'float' <col:87, col:102> (ImplicitCastExpr 0x2409870 'float (*)(void)' <col:87> (DeclRefExpr 0x2409980 'float (void)' <col:87> Decl='__builtin_inff' 0x2409940)))))) where it only prints filename/line# if it changes from the previous value. We really need loc info on stmts though, like we have on exprs. llvm-svn: 41602
* Fix the following redefinition errors submitted by Keith Bauer...Steve Naroff2007-08-302-33/+62
| | | | | | | | | | | | | | | | | | | | | | | | [dylan:~/llvm/tools/clang] admin% cat tentative_decls.c // incorrectly generates redefinition error extern int array[3]; int array[3]; // incorrectly generates a redefinition error extern void nup(int a[3]); void nup(int a[3]) {} It turns out that this exposed a fairly major flaw in the type system, array types were never getting uniqued! This is because all array types contained an expression, which aren't unique. To solve this, we now have 2 array types, ConstantArrayType and VariableArrayType. ConstantArrayType's are unique, VAT's aren't. This is a fairly extensive set of fundamental changes. Fortunately, all the tests pass. Nevertheless, there may be some collateral damage:-) If so, let me know! llvm-svn: 41592
* Previous commit should have been:Chris Lattner2007-08-301-102/+30
| | | | | | | | | | | | Use Ted's child walking interface to allow the dumper to walk the tree in one place and only have node-specific callbacks worry about formatting the nodes (instead of formatting the nodes plus walking the tree). This commit eliminates now default cases by letting them fall through with the normal visitor stuff. llvm-svn: 41591
* elimiante some virtual calls.Chris Lattner2007-08-302-157/+33
| | | | llvm-svn: 41589
* Allow a SourceManager to optionally be passed into Stmt::dumpChris Lattner2007-08-301-4/+21
| | | | llvm-svn: 41588
* 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
* Teach Type::is[un]SignedIntegerType about enum decls. This allows the code ↵Chris Lattner2007-08-291-0/+18
| | | | | | | | | generator to emit signed comparisons when needed for enum decl references. This implements test/CodeGen/enum.c. I think enums should be good now. llvm-svn: 41572
* Re-teach Expr::isNullPointerConstant() about ImplicitCastExpr:-)Steve Naroff2007-08-291-7/+2
| | | | | | | | | | This fixes the following bug submitted by Neil... const char *f (void) { return 0; } ...which would incorrectly warn with -pedantic enabled. llvm-svn: 41559
* Teach Expr::isNullPointerConstant() about ImplicitCastExpr's.Steve Naroff2007-08-281-0/+8
| | | | | | | | | | | | | | | | This fixes the following (recent) regression noticed by Keith Bauer (thanks!). void func(void *a); main() { void *p; p = 0; func(0); } ...which now works as you would expect. llvm-svn: 41557
* 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
* Change EnumDecl to store its corresponding integer type Chris Lattner2007-08-281-18/+1
| | | | | | | directly in it. Remove TargetInfo::getEnumPolicy, as there is only one policy that we support right now. llvm-svn: 41548
* 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
* Fixed bug in child_begin/child_end for CallExpr where we incorrectly ↵Ted Kremenek2007-08-271-2/+2
| | | | | | | | calculated a Stmt** pointer based on an offset within SubExprs. llvm-svn: 41512
* Fixed bug in child_begin/child_end for ReturnStmt where the iteratorTed Kremenek2007-08-271-3/+7
| | | | | | would be invalid when RetValExp == NULL. llvm-svn: 41511
* 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
* constify some stuffChris Lattner2007-08-271-2/+2
| | | | llvm-svn: 41503
* implement sizeof(enum x), patch inspired by Keith Bauer.Chris Lattner2007-08-271-7/+26
| | | | llvm-svn: 41500
* Replaced ASTContext::maxFloatingType() with ASTContext::compareFloatingType().Steve Naroff2007-08-271-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Changed Sema::UsualArithmeticConversions to use the new API. This fixes the following case... _Complex double X; double y; void foo() { X = X + y; } [dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang complex.c -parse-ast-dump Read top-level variable decl: 'X' Read top-level variable decl: 'y' void foo() (CompoundStmt 0x2605cc0 (BinaryOperator 0x2605ca0 '_Complex double' '=' (DeclRefExpr 0x2605c10 '_Complex double' Decl='X' 0x2605ab0) (BinaryOperator 0x2605c80 '_Complex double' '+' (DeclRefExpr 0x2605c30 '_Complex double' Decl='X' 0x2605ab0) (ImplicitCastExpr 0x2605c70 '_Complex double' (DeclRefExpr 0x2605c50 'double' Decl='y' 0x2605ae0))))) llvm-svn: 41483
* Add Type::getAsBuiltinType() and Type::builtinTypesAreCompatible().Steve Naroff2007-08-271-1/+19
| | | | | | | | | | | | | | | | Modified Type::typesAreCompatible() to use the above. This fixes the following bug submitted by Keith Bauer (thanks!). int equal(char *a, const char *b) { return a == b; } Also tweaked Sema::CheckCompareOperands() to ignore the qualifiers when comparing two pointer types (though it doesn't relate directly to this bug). llvm-svn: 41476
* Tweak a comment and assert.Steve Naroff2007-08-271-5/+6
| | | | llvm-svn: 41475
* Replaced ASTContext::maxComplexType() with ↵Steve Naroff2007-08-271-21/+21
| | | | | | | | | ASTContext::getFloatingTypeOfSizeWithinDomain(). Changed Sema::UsualArithmeticConversions to correctly implement complex/float conversions, using maxFloatingType() with getFloatingTypeOfSizeWithinDomain(). llvm-svn: 41474
* null pointers don't get an extra newline.Chris Lattner2007-08-261-1/+1
| | | | llvm-svn: 41415
* add a new ImaginaryLiteral AST node that is used toChris Lattner2007-08-263-33/+37
| | | | | | | | | | | | | | | | | | represent imaginary literals: float _Complex A; void foo() { A = 1.0iF; } generates: (BinaryOperator 0x2305ec0 '_Complex float' '=' (DeclRefExpr 0x2305e60 '_Complex float' Decl='A' 0x2305cf0) (ImaginaryLiteral 0x2305f40 '_Complex float' (FloatingLiteral 0x2305ea0 'float' 1.000000)))) llvm-svn: 41413
* Surpress the UsualUnaryConversions for compound assignment operators. This ↵Steve Naroff2007-08-251-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | change eliminates the possibility that the left hand expression is an ImplicitCastExpr. As a result, I removed the check for ImplicitCastExpr in Expr::isLvalue(). This results in the following AST's... [dylan:~/llvm/tools/clang] admin% cat fix.c short x; void test4(char c) { x += c; x = x + c; } [dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang fix.c -parse-ast-dump Read top-level variable decl: 'x' void test4(char c) (CompoundStmt 0x2605d30 (CompoundAssignOperator 0x2605c40 'short' '+=' (DeclRefExpr 0x2605c00 'short' Decl='x' 0x2605a80) (DeclRefExpr 0x2605c20 'char' Decl='c' 0x2605bc0)) (BinaryOperator 0x2605d10 'short' '=' (DeclRefExpr 0x2605c60 'short' Decl='x' 0x2605a80) (ImplicitCastExpr 0x2605d00 'short' (BinaryOperator 0x2605ce0 'int' '+' (ImplicitCastExpr 0x2605cc0 'int' (DeclRefExpr 0x2605c80 'short' Decl='x' 0x2605a80)) (ImplicitCastExpr 0x2605cd0 'int' (DeclRefExpr 0x2605ca0 'char' Decl='c' 0x2605bc0)))))) llvm-svn: 41404
* Change Expr::isLvalue() to properly deal with ImplicitCastExpr's.Steve Naroff2007-08-251-0/+2
| | | | | | | | | | | This fixes the following bug... t.c:1:31: error: expression is not assignable short x; void foo(char c) { x += c; } This case, among others are now captured in implicit-casts.c. llvm-svn: 41402
* Split the ASTNode out for compound assignments out from binary operators. NowChris Lattner2007-08-253-6/+17
| | | | | | they show up in dumps etc. llvm-svn: 41393
* fix off-by-one errorChris Lattner2007-08-252-3/+5
| | | | llvm-svn: 41392
* rename sNames -> StmtClassInfo. Make lookups constant time.Chris Lattner2007-08-251-24/+33
| | | | llvm-svn: 41390
* Added child_begin/child_end to all subclasses of Stmt in Stmt.h. All Ted Kremenek2007-08-241-0/+70
| | | | | | | concrete subclasses of Stmt are now required to implement child_begin/child_end. llvm-svn: 41374
* Implementation of child_begin/child_end for C++ expressions.Ted Kremenek2007-08-241-0/+33
| | | | llvm-svn: 41369
* Finished adding child_begin/child_end to all subclasses of Stmt in Expr.h.Ted Kremenek2007-08-241-18/+117
| | | | llvm-svn: 41366
* Began implementing "child iterator" interface for Stmts and Exprs. EachTed Kremenek2007-08-241-3/+76
| | | | | | | | | | | | | | | | | | | | | subclass of Stmt will implement child_begin() and child_end(), which will be used to iterate over all the children (subexpressions/substatements) of a Stmt object. This will provide for easy traversal over the AST, which is useful for a variety of purposes. None of the interfaces to subclasses of Stmt will be changed (other than adding the child_begin and child_end methods). The only caveat is that the implementation of subclasses of Stmt will require colocating all substatements (subexpressions) in an array. This is because we define child_iterator as Stmt**. All accessor methods to subexpressions will need to be altered to reflect this new implementation. This patch includes the typedefs for child_iterator, as well the implementation for child_begin/child_end for the primary expressions and some postfix expressions. llvm-svn: 41363
* print the computation type for compound assignment operators in dumps.Chris Lattner2007-08-241-1/+6
| | | | llvm-svn: 41361
* Pretty print as:Chris Lattner2007-08-231-1/+14
| | | | | | | | "case sizeof x:" instead of: "case sizeofx:" llvm-svn: 41339
* sizeof(x) doesn't require x to be an i-c-e for sizeof to be an i-c-e. ↵Chris Lattner2007-08-231-2/+2
| | | | | | Thanks to Neil for pointing this out. llvm-svn: 41338
* 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
OpenPOWER on IntegriCloud