summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/StmtPrinter.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Create a new TypeNodes.def file that enumerates all of the types,Douglas Gregor2009-02-261-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | giving them rough classifications (normal types, never-canonical types, always-dependent types, abstract type representations) and making it far easier to make sure that we've hit all of the cases when decoding types. Switched some switch() statements on the type class over to using this mechanism, and filtering out those things we don't care about. For example, CodeGen should never see always-dependent or non-canonical types, while debug info generation should never see always-dependent types. More switch() statements on the type class need to be moved over to using this approach, so that we'll get warnings when we add a new type then fail to account for it somewhere in the compiler. As part of this, some types have been renamed: TypeOfExpr -> TypeOfExprType FunctionTypeProto -> FunctionProtoType FunctionTypeNoProto -> FunctionNoProtoType There shouldn't be any functionality change... llvm-svn: 65591
* rip out __builtin_overloadChris Lattner2009-02-181-9/+0
| | | | llvm-svn: 64961
* Add private extern to pretty printer(s).Mike Stump2009-02-101-5/+6
| | | | llvm-svn: 64258
* Fixup -ast-print so that:Mike Stump2009-02-101-11/+26
| | | | | | | | | | | | | | We handle indentation of decls better. We Indent extern "C" { } stuff better. We print out structure contents more often. We handle pass indentation information into the statement printer, so that nested things come out more indented. We print out FieldDecls. We print out Vars. We print out namespaces. We indent functions better. llvm-svn: 64232
* Fix pretty-printing of if conditions. Patch by Ben Lickly.Sebastian Redl2009-02-071-1/+2
| | | | llvm-svn: 64027
* Fix our semantic analysis ofDouglas Gregor2009-02-041-2/+2
| | | | | | | | | | | | | | | | | | | | | unqualified-id '(' in C++. The unqualified-id might not refer to any declaration in our current scope, but declarations by that name might be found via argument-dependent lookup. We now do so properly. As part of this change, CXXDependentNameExpr, which was previously designed to express the unqualified-id in the above constructor within templates, has become UnresolvedFunctionNameExpr, which does effectively the same thing but will work for both templates and non-templates. Additionally, we cope with all unqualified-ids, since ADL also applies in cases like operator+(x, y) llvm-svn: 63733
* Introduce a new expression node, ImplicitValueInitExpr, thatDouglas Gregor2009-01-291-0/+4
| | | | | | | | | | | | | represents an implicit value-initialization of a subobject of a particular type. This replaces the (ab)use of CXXZeroValueInitExpr within initializer lists for the "holes" that occur due to the use of C99 designated initializers. The new test case is currently XFAIL'd, because CodeGen's ConstExprEmitter (in lib/CodeGen/CGExprConstant.cpp) needs to be taught to value-initialize when it sees ImplicitValueInitExprs. llvm-svn: 63317
* Code generation support for C99 designated initializers.Douglas Gregor2009-01-281-3/+30
| | | | | | | | | | | | | | | | | | | | The approach I've taken in this patch is relatively straightforward, although the code itself is non-trivial. Essentially, as we process an initializer list we build up a fully-explicit representation of the initializer list, where each of the subobject initializations occurs in order. Designators serve to "fill in" subobject initializations in a non-linear way. The fully-explicit representation makes initializer lists (both with and without designators) easy to grok for codegen and later semantic analyses. We keep the syntactic form of the initializer list linked into the AST for those clients interested in exactly what the user wrote. Known limitations: - Designating a member of a union that isn't the first member may result in bogus initialization (we warn about this) - GNU array-range designators are not supported (we warn about this) llvm-svn: 63242
* Initial implementation of semantic analysis and ASTs for C99Douglas Gregor2009-01-221-0/+4
| | | | | | | | | | | | | | | | | | designated initializers. This implementation should cover all of the constraints in C99 6.7.8, including long, complex designations and computing the size of incomplete array types initialized with a designated initializer. Please see the new test-case and holler if you find cases where this doesn't work. There are still some wrinkles with GNU's anonymous structs and anonymous unions (it isn't clear how these should work; we'll just follow GCC's lead) and with designated initializers for the members of a union. I'll tackle those very soon. CodeGen is still nonexistent, and there's some leftover code in the parser's representation of designators that I'll also need to clean up. llvm-svn: 62737
* Remove ScopedDecl, collapsing all of its functionality into Decl, soDouglas Gregor2009-01-201-7/+3
| | | | | | | | | | | | | | | | that every declaration lives inside a DeclContext. Moved several things that don't have names but were ScopedDecls (and, therefore, NamedDecls) to inherit from Decl rather than NamedDecl, including ObjCImplementationDecl and LinkageSpecDecl. Now, we don't store empty DeclarationNames for these things, nor do we try to insert them into DeclContext's lookup structure. The serialization tests are temporarily disabled. We'll re-enable them once we've sorted out the remaining ownership/serialiazation issues between DeclContexts and TranslationUnion, DeclGroups, etc. llvm-svn: 62562
* make ast-print handle random non-printable characters correctly with octal ↵Chris Lattner2009-01-161-3/+13
| | | | | | escapes. llvm-svn: 62337
* Part one of handling C++ functional casts. This handles semanticDouglas Gregor2009-01-161-0/+13
| | | | | | | | analysis and AST-building for the cases where we have N != 1 arguments. For N == 1 arguments, we need to finish the C++ implementation of explicit type casts (C++ [expr.cast]). llvm-svn: 62329
* Revert my previous, failed attempt to pretty-print anonymous struct/union ↵Douglas Gregor2009-01-081-4/+5
| | | | | | accesses well. Added a FIXME so we know to revisit this later llvm-svn: 61951
* Fix printing of member references to avoid displaying implicitly-generated ↵Douglas Gregor2009-01-071-2/+4
| | | | | | member references, e.g., for anonymous struct/unions or implicit 'this' in member functions llvm-svn: 61885
* Add QualifiedDeclRefExpr, which retains additional source-locationDouglas Gregor2009-01-061-0/+30
| | | | | | | | | | | | | | | | | | | information for declarations that were referenced via a qualified-id, e.g., N::C::value. We keep track of the location of the start of the nested-name-specifier. Note that the difference between QualifiedDeclRefExpr and DeclRefExpr does have an effect on the semantics of function calls in two ways: 1) The use of a qualified-id instead of an unqualified-id suppresses argument-dependent lookup 2) If the name refers to a virtual function, the qualified-id version will call the function determined statically while the unqualified-id version will call the function determined dynamically (by looking up the appropriate function in the vtable). Neither of these features is implemented yet, but we do print out qualified names for QualifiedDeclRefExprs as part of the AST printing. llvm-svn: 61789
* PODness and Type TraitsSebastian Redl2009-01-051-0/+26
| | | | | | | | | | | | | | | Make C++ classes track the POD property (C++ [class]p4) Track the existence of a copy assignment operator. Implicitly declare the copy assignment operator if none is provided. Implement most of the parsing job for the G++ type traits extension. Fully implement the low-hanging fruit of the type traits: __is_pod: Whether a type is a POD. __is_class: Whether a type is a (non-union) class. __is_union: Whether a type is a union. __is_enum: Whether a type is an enum. __is_polymorphic: Whether a type is polymorphic (C++ [class.virtual]p1). llvm-svn: 61746
* Full AST support and better Sema support for C++ try-catch.Sebastian Redl2008-12-221-2/+18
| | | | llvm-svn: 61346
* Partial AST and Sema support for C++ try-catch.Sebastian Redl2008-12-221-0/+11
| | | | llvm-svn: 61337
* Add support for calls to overloaded member functions. Things to note:Douglas Gregor2008-12-221-0/+4
| | | | | | | | | | | | - Overloading has to cope with having both static and non-static member functions in the overload set. - The call may or may not have an implicit object argument, depending on the syntax (x.f() vs. f()) and the context (static vs. non-static member function). - We now generate MemberExprs for implicit member access expression. - We now cope with mutable whenever we're building MemberExprs. llvm-svn: 61329
* Add support for member references (E1.E2, E1->E2) with C++ semantics,Douglas Gregor2008-12-201-4/+1
| | | | | | | | | | which can refer to static data members, enumerators, and member functions as well as to non-static data members. Implement correct lvalue computation for member references in C++. Compute the result type of non-static data members of reference type properly. llvm-svn: 61294
* Add support for calls to dependent names within templates, e.g.,Douglas Gregor2008-12-061-0/+4
| | | | | | | | | | | | | | | | | | template<typename T> void f(T x) { g(x); // g is a dependent name, so don't even bother to look it up g(); // error: g is not a dependent name } Note that when we see "g(", we build a CXXDependentNameExpr. However, if none of the call arguments are type-dependent, we will force the resolution of the name "g" and replace the CXXDependentNameExpr with its result. GCC actually produces a nice error message when you make this mistake, and even offers to compile your code with -fpermissive. I'll do the former next, but I don't plan to do the latter. llvm-svn: 60618
* Several things...Steve Naroff2008-12-041-1/+1
| | | | | | | | | | | - Implement RewritePropertySetter(). While the routine is simple, there were some tricky changes to RewriteFunctionBodyOrGlobalInitializer(), the main rewriter loop. It also required some additional instance data to distinguish setters from getters, as well as some changes to RewritePropertyGetter(). - Implement FIXME: for pretty printing ObjCPropertyRefExpr's. - Changed ObjCPropertyRefExpr::getSourceRange() to point to the end of the property name (not the beginning). Also made a minor name change from "Loc"->"IdLoc" (to make it clear the Loc does not point to the "."). llvm-svn: 60540
* Correct pretty printing of array new expressions.Sebastian Redl2008-12-021-4/+9
| | | | llvm-svn: 60444
* Handle new by passing the Declaration to the Action, not a processed type.Sebastian Redl2008-12-021-0/+3
| | | | llvm-svn: 60413
* Implement the GNU __null extensionDouglas Gregor2008-11-291-0/+4
| | | | llvm-svn: 60235
* Migrate some stuff from NamedDecl::getName() to Chris Lattner2008-11-241-12/+12
| | | | | | NamedDecl::getNameAsString() to make it more explicit. llvm-svn: 59937
* Rename Selector::getName() to Selector::getAsString(), and addChris Lattner2008-11-241-1/+1
| | | | | | | | | | | | | a new NamedDecl::getAsString() method. Change uses of Selector::getName() to just pass in a Selector where possible (e.g. to diagnostics) instead of going through an std::string. This also adds new formatters for objcinstance and objcclass as described in the dox. llvm-svn: 59933
* New AST node to access "implicit" setter/getter using property dor syntax.Fariborz Jahanian2008-11-221-0/+8
| | | | | | | Issuing diagnostics when assigning to read-only properties. This is work in progress. llvm-svn: 59874
* Implementation of new and delete parsing and sema.Sebastian Redl2008-11-211-0/+43
| | | | | | This version uses VLAs to represent arrays. I'll try an alternative way next, but I want this safe first. llvm-svn: 59835
* Add a new expression node, CXXOperatorCallExpr, which expresses aDouglas Gregor2008-11-141-0/+43
| | | | | | | | | | | | | | | | | | | function call created in response to the use of operator syntax that resolves to an overloaded operator in C++, e.g., "str1 + str2" that resolves to std::operator+(str1, str2)". We now build a CXXOperatorCallExpr in C++ when we pick an overloaded operator. (But only for binary operators, where we actually implement overloading) I decided *not* to refactor the current CallExpr to make it abstract (with FunctionCallExpr and CXXOperatorCallExpr as derived classes). Doing so would allow us to make CXXOperatorCallExpr a little bit smaller, at the cost of making the argument and callee accessors virtual. We won't know if this is going to be a win until we can parse lots of C++ code to determine how much memory we'll save by making this change vs. the performance penalty due to the extra virtual calls. llvm-svn: 59306
* Don't require us to manually number the statements and expressions in ↵Douglas Gregor2008-11-141-1/+1
| | | | | | StmtNodes.def. We don't need stable numbers yet, renumbering is a pain, and LAST_STMT had the wrong value anyway. llvm-svn: 59300
* Introduce a single AST node SizeOfAlignOfExpr for all sizeof and alignof ↵Sebastian Redl2008-11-111-6/+9
| | | | | | expressions, both of values and types. llvm-svn: 59057
* Implement C++ 'typeid' parsing and sema.Sebastian Redl2008-11-111-0/+10
| | | | llvm-svn: 59042
* Add a new expression class, ObjCSuperExpr, to handle the Objective-C ↵Douglas Gregor2008-11-041-3/+4
| | | | | | 'super'. Remove ObjCThis from PredefinedExpr llvm-svn: 58698
* Create a new expression class, CXXThisExpr, to handle the C++ 'this' primary ↵Douglas Gregor2008-11-041-0/+4
| | | | | | expression. Remove CXXThis from PredefinedExpr llvm-svn: 58695
* Rename ExplicitCCastExpr to CStyleCastExprDouglas Gregor2008-10-281-1/+1
| | | | llvm-svn: 58331
* Refactor the expression class hierarchy for casts. Most importantly:Douglas Gregor2008-10-271-4/+23
| | | | | | | | | | | | | | | | | | | | | | - CastExpr is the root of all casts - ImplicitCastExpr is (still) used for all explicit casts - ExplicitCastExpr is now the root of all *explicit* casts - ExplicitCCastExpr (new name needed!?) is a C-style cast in C or C++ - CXXFunctionalCastExpr inherits from ExplicitCastExpr - CXXNamedCastExpr inherits from ExplicitCastExpr and is the root of all of the C++ named cast expression types (static_cast, dynamic_cast, etc.) - Added classes CXXStaticCastExpr, CXXDynamicCastExpr, CXXReinterpretCastExpr, and CXXConstCastExpr to Also, fixed returned-stack-addr.cpp, which broke once when we fixed reinterpret_cast to diagnose double->int* conversions and again when we eliminated implicit conversions to reference types. The fix is in both testcase and SemaChecking.cpp. Most of this patch is simply support for the renaming. There's very little actual change in semantics. llvm-svn: 58264
* - Add BlockDecl AST node.Steve Naroff2008-10-081-6/+7
| | | | | | | | | | - Modify BlockExpr to reference the BlockDecl. This is "cleanup" necessary to improve our lookup semantics for blocks (to fix <rdar://problem/6272905> clang block rewriter: parameter to function not imported into block?). Still some follow-up work to finish this (forthcoming). llvm-svn: 57298
* Added PrintRawDeclStmt; use this method to print out DeclStmt instead of ↵Ted Kremenek2008-10-061-5/+19
| | | | | | using PrintRawDecl (which falsely assumes DeclStmts have only one Decl). llvm-svn: 57191
* Remove BlockStmtExpr. Steve Naroff2008-09-171-6/+1
| | | | | | | | Block literals are now represented by the concrete BlockExpr class. This is cleanup (removes a FIXME). No functionality change. llvm-svn: 56288
* Remove support for BlockExprExpr. For example...Steve Naroff2008-09-161-5/+0
| | | | | | | | ^(expression) or ^(int arg1, float arg2)(expression) ...is no longer supported. All block literals now require a compound statement. llvm-svn: 56257
* Patch by Csaba Hruska!Ted Kremenek2008-09-131-6/+7
| | | | | | | "Here is a patch what replaces std::ostream with llvm::raw_ostream. This patch covers the AST library, but ignores Analysis lib." llvm-svn: 56185
* Add new 'CXXConditionDeclExpr' expression node used for a 'condition' ↵Argyrios Kyrtzidis2008-09-091-0/+5
| | | | | | | | declaration, e.g: "if (int x=0) {...}". It is a subclass of DeclRefExpr and the main difference is that CXXConditionDeclExpr owns the declaration that it references. llvm-svn: 56033
* Add semantic analysis for "blocks". Steve Naroff2008-09-031-0/+40
| | | | | | | | | | | | | | | Highlights... - 4 new AST nodes, BlockExpr, BlockStmtExpr, BlockExprExpr, BlockDeclRefExpr. - Sema::ActOnBlockStart(), ActOnBlockError(), ActOnBlockStmtExpr(), ActOnBlockExprExpr(), ActOnBlockReturnStmt(). Next steps... - hack Sema::ActOnIdentifierExpr() to deal with block decl refs. - add attribute handler for byref decls. - add test cases. llvm-svn: 55710
* Add support for C++'s "type-specifier ( expression-list )" expression:Argyrios Kyrtzidis2008-08-221-0/+11
| | | | | | | | | | -The Parser calls a new "ActOnCXXTypeConstructExpr" action. -Sema, depending on the type and expressions number: -If the type is a class, it will treat it as a class constructor. [TODO] -If there's only one expression (i.e. "int(0.5)" ), creates a new "CXXFunctionalCastExpr" Expr node -If there are no expressions (i.e "int()" ), creates a new "CXXZeroInitValueExpr" Expr node. llvm-svn: 55177
* Add ExplicitCastExpr to replace the current CastExpr, and have ↵Argyrios Kyrtzidis2008-08-181-1/+4
| | | | | | | | | | | ImplicitCastExpr and ExplicitCastExpr derive from a common base class (CastExpr): Expr -> CastExpr -> ExplicitCastExpr -> ImplicitCastExpr llvm-svn: 54955
* More #include cleaningDaniel Dunbar2008-08-111-5/+0
| | | | | | | | | | | - Kill unnecessary #includes in .cpp files. This is an automatic sweep so some things removed are actually used, but happen to be included by a previous header. I tried to get rid of the obvious examples and this was the easiest way to trim the #includes in one fell swoop. - We now return to regularly scheduled development. llvm-svn: 54632
* Cleanup ObjCSuperRefExpr (remove last usage and AST node:-).Steve Naroff2008-08-101-4/+0
| | | | llvm-svn: 54617
* rename PreDefinedExpr -> PredefinedExprChris Lattner2008-08-101-5/+5
| | | | llvm-svn: 54605
* change more instances of QualType::getCanonicalType to callChris Lattner2008-07-261-1/+1
| | | | | | ASTContext::getCanonicalType instead (PR2189) llvm-svn: 54105
OpenPOWER on IntegriCloud