summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/TreeTransform.h
Commit message (Collapse)AuthorAgeFilesLines
* PR12917: Remove incorrect assumption that lambda mangling information cannotRichard Smith2012-07-221-6/+2
| | | | | | | | | | change once it's been assigned. It can change in two ways: 1) In a template instantiation, the context declaration should be the instantiated declaration, not the declaration in the template. 2) If a lambda appears in the pattern of a variadic pack expansion, the mangling number will depend on the pack length. llvm-svn: 160614
* Inline storage of attributes in AttributedStmt.Alexander Kornienko2012-07-091-1/+2
| | | | llvm-svn: 159925
* objective-c: Refactor parse/sema portion ofFariborz Jahanian2012-07-031-18/+7
| | | | | | | objective-c's fast enumeration statement, for more work to come. llvm-svn: 159689
* Documentation cleanup:James Dennett2012-06-151-11/+8
| | | | | | | | | * Removed \param comments for parameters that no longer exist; * Fixed a "\para" typo to "\param"; * Escaped @, # and \ symbols as needed in Doxygen comments; * Added use of \brief to output short summaries. llvm-svn: 158498
* Etch out the code path for MS-style inline assembly.Chad Rosier2012-06-111-0/+18
| | | | llvm-svn: 158325
* PR12798: Don't drop part of the nested name specifier when instantiating aRichard Smith2012-05-151-1/+5
| | | | | | | pseudo-destructor expression. This can affect whether virtual dispatch for the destructor call is bypassed. llvm-svn: 156806
* Implements boxed expressions for Objective-C. <rdar://problem/10194391>Patrick Beard2012-04-191-2/+18
| | | | llvm-svn: 155082
* Implement DR1330 in C++11 mode, to support libstdc++4.7 which uses it.Richard Smith2012-04-171-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We have a new flavor of exception specification, EST_Uninstantiated. A function type with this exception specification carries a pointer to a FunctionDecl, and the exception specification for that FunctionDecl is instantiated (if needed) and used in the place of the function type's exception specification. When a function template declaration with a non-trivial exception specification is instantiated, the specialization's exception specification is set to this new 'uninstantiated' kind rather than being instantiated immediately. Expr::CanThrow has migrated onto Sema, so it can instantiate exception specs on-demand. Also, any odr-use of a function triggers the instantiation of its exception specification (the exception specification could be needed by IRGen). In passing, fix two places where a DeclRefExpr was created but the corresponding function was not actually marked odr-used. We used to get away with this, but don't any more. Also fix a bug where instantiating an exception specification which refers to function parameters resulted in a crash. We still have the same bug in default arguments, which I'll be looking into next. This, plus a tiny patch to fix libstdc++'s common_type, is enough for clang to parse (and, in very limited testing, support) all of libstdc++4.7's standard headers. llvm-svn: 154886
* Implement C++11 [expr.prim.general]p3, which permits the use of 'this'Douglas Gregor2012-04-161-3/+27
| | | | | | | | | | | | | | | | | | | | | | | in the declaration of a non-static member function after the (optional) cv-qualifier-seq, which in practice means in the exception specification and late-specified return type. The new scheme here used to manage 'this' outside of a member function scope is more general than the Scope-based mechanism previously used for non-static data member initializers and late-parsesd attributes, because it can also handle the cv-qualifiers on the member function. Note, however, that a separate pass is required for static member functions to determine whether 'this' was used, because we might not know that we have a static function until after declaration matching. Finally, this introduces name mangling for 'this' and for the implicit 'this', which is intended to match GCC's mangling. Independent verification for the new mangling test case would be appreciated. Fixes PR10036 and PR12450. llvm-svn: 154799
* Add an AttributedStmt type to represent a statement with C++11 attributesRichard Smith2012-04-141-2/+27
| | | | | | | | | attached. Since we do not support any attributes which appertain to a statement (yet), testing of this is necessarily quite minimal. Patch by Alexander Kornienko! llvm-svn: 154723
* Fix a Sema invariant bug that I recently introduced involvingJohn McCall2012-04-061-2/+8
| | | | | | | | | the template instantiation of statement-expressions. I think it was jyasskin who had a crashing testcase in this area; hopefully this fixes it and he can find his testcase and check it in. llvm-svn: 154189
* Move the computation of the lambda mangling information (manglingDouglas Gregor2012-04-041-9/+8
| | | | | | | | | | number + context) to the point where we initially start defining the lambda, so that the linkage won't change when that information is made available. Fixes the assertion in <rdar://problem/11182962>. Plus, actually mangle the context of lambdas properly. llvm-svn: 154029
* ObjCBoolLiterals (__objc_yes/__objc_no) behave like C++ booleans ↵Jordy Rose2012-03-121-1/+1
| | | | | | (true/false). They are NOT objects. llvm-svn: 152564
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-111-1/+1
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
* Remove BlockDeclRefExpr and introduce a bit on DeclRefExpr toJohn McCall2012-03-101-24/+2
| | | | | | | | track whether the referenced declaration comes from an enclosing local context. I'm amenable to suggestions about the exact meaning of this bit. llvm-svn: 152491
* AST representation for user-defined literals, plus just enough of semanticRichard Smith2012-03-071-0/+6
| | | | | | | | | | | | | | | | | | | | | analysis to make the AST representation testable. They are represented by a new UserDefinedLiteral AST node, which is a sugared CallExpr. All semantic properties, including full CodeGen support, are achieved for free by this representation. UserDefinedLiterals can never be dependent, so no custom instantiation behavior is required. They are mangled as if they were direct calls to the underlying literal operator. This matches g++'s apparent behavior (but not its actual mangling, which is broken for literal-operator-ids). User-defined *string* literals are now fully-operational, but the semantic analysis is quite hacky and needs more work. No other forms of user-defined literal are created yet, but the AST support for them is present. This patch committed after midnight because we had already hit the quota for new kinds of literal yesterday. llvm-svn: 152211
* Add clang support for new Objective-C literal syntax for NSDictionary, NSArray,Ted Kremenek2012-03-061-2/+206
| | | | | | | | | | | | | NSNumber, and boolean literals. This includes both Sema and Codegen support. Included is also support for new Objective-C container subscripting. My apologies for the large patch. It was very difficult to break apart. The patch introduces changes to the driver as well to cause clang to link in additional runtime support when needed to support the new language features. Docs are forthcoming to document the implementation and behavior of these features. llvm-svn: 152137
* A couple minor bug-fixes for template instantiation for expressions which ↵Eli Friedman2012-02-291-12/+13
| | | | | | are sometimes potentially evaluated. llvm-svn: 151707
* Make the odr-use logic work correctly for constant-expressions. PR12006.Eli Friedman2012-02-291-0/+7
| | | | llvm-svn: 151699
* Two minor, related fixes for template instantiation with blocks:Douglas Gregor2012-02-241-2/+6
| | | | | | | | | | | | - Make sure that the block expression is instantiation-dependent if the block is in a dependent context - Make sure that the C++ 'this' expression gets captured even if we don't rebuild the AST node during template instantiation. This would also have manifested as a bug for lambdas. Fixes <rdar://problem/10832617>. llvm-svn: 151372
* Implement a new type trait __is_trivially_constructible(T, Args...)Douglas Gregor2012-02-241-0/+133
| | | | | | | | | | | | | | | | that provides the behavior of the C++11 library trait std::is_trivially_constructible<T, Args...>, which can't be implemented purely as a library. Since __is_trivially_constructible can have zero or more arguments, I needed to add Yet Another Type Trait Expression Class, this one handling arbitrary arguments. The next step will be to migrate UnaryTypeTrait and BinaryTypeTrait over to this new, more general TypeTrait class. Fixes the Clang side of <rdar://problem/10895483> / PR12038. llvm-svn: 151352
* Implement C++11 [expr.call]p11: If the operand to a decltype-specifier is aRichard Smith2012-02-221-1/+6
| | | | | | | | | | | | | | | | | | function call (or a comma expression with a function call on its right-hand side), possibly parenthesized, then the return type is not required to be complete and a temporary is not bound. Other subexpressions inside a decltype expression do not get this treatment. This is implemented by deferring the relevant checks for all calls immediately within a decltype expression, then, when the expression is fully-parsed, checking the relevant constraints and stripping off any top-level temporary binding. Deferring the completion of the return type exposed a bug in overload resolution where completion of the argument types was not attempted, which is also fixed by this change. llvm-svn: 151117
* Implement name mangling for lambda expressions that occur within theDouglas Gregor2012-02-211-1/+5
| | | | | | | | | | | | | | | | default arguments of function parameters. This simple-sounding task is complicated greatly by two issues: (1) Default arguments aren't actually a real context, so we need to maintain extra state within lambda expressions to track when a lambda was actually in a default argument. (2) At the time that we parse a default argument, the FunctionDecl doesn't exist yet, so lambda closure types end up in the enclosing context. It's not clear that we ever want to change that, so instead we introduce the notion of the "effective" context of a declaration for the purposes of name mangling. llvm-svn: 151011
* Basic support for name mangling of C++11 lambda expressions. BecauseDouglas Gregor2012-02-201-1/+2
| | | | | | | | | | | | | | | name mangling in the Itanium C++ ABI for lambda expressions is so dependent on context, we encode the number used to encode each lambda as part of the lambda closure type, and maintain this value within Sema. Note that there are a several pieces still missing: - We still get the linkage of lambda expressions wrong - We aren't properly numbering or mangling lambda expressions that occur in default function arguments or in data member initializers. - We aren't (de-)serializing the lambda numbering tables llvm-svn: 150982
* Remove dead code.Ahmed Charles2012-02-191-8/+0
| | | | llvm-svn: 150919
* Rewrite variable capture within lambda expressions and blocks,Douglas Gregor2012-02-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | eliminating a bunch of redundant code and properly modeling how the captures of outside blocks/lambdas affect the types seen by inner captures. This new scheme makes two passes over the capturing scope stack. The first pass goes up the stack (from innermost to outermost), assessing whether the capture looks feasible and stopping when it either hits the scope where the variable is declared or when it finds an existing capture. The second pass then walks down the stack (from outermost to innermost), capturing the variable at each step and updating the captured type and the type that an expression referring to that captured variable would see. It also checks type-specific restrictions, such as the inability to capture an array within a block. Note that only the first odr-use of each variable needs to do the full walk; subsequent uses will find the capture immediately, so multiple walks need not occur. The same routine that builds the captures can also compute the type of the captures without signaling errors and without actually performing the capture. This functionality is used to determine the type of declaration references as well as implementing the weird decltype((x)) rule within lambda expressions. The capture code now explicitly takes sides in the debate over C++ core issue 1249, which concerns the type of captures within nested lambdas. We opt to use the more permissive, more useful definition implemented by GCC rather than the one implemented by EDG. llvm-svn: 150875
* Revert "Revert "Make CXXNewExpr contain only a single initialier, and not ↵Sebastian Redl2012-02-161-38/+20
| | | | | | | | hold the used constructor itself."" This reintroduces commit r150682 with a fix for the Bullet benchmark crash. llvm-svn: 150685
* Revert "Make CXXNewExpr contain only a single initialier, and not hold the ↵Sebastian Redl2012-02-161-20/+38
| | | | | | | | | | used constructor itself." It leads to a compiler crash in the Bullet benchmark. This reverts commit r12014. llvm-svn: 150684
* Make CXXNewExpr contain only a single initialier, and not hold the used ↵Sebastian Redl2012-02-161-38/+20
| | | | | | | | | | constructor itself. Holding the constructor directly makes no sense when list-initialized arrays come into play. The constructor is now held in a CXXConstructExpr, if construction is what is done. The new design can also distinguish properly between list-initialization and direct-initialization, as well as implicit default-initialization constructors and explicit value-initialization constructors. Finally, doing it this way removes redundance from the AST because CXXNewExpr doesn't try to handle both the allocation and the initialization responsibilities. This breaks the static analysis of new expressions. I've filed PR12014 to track this. llvm-svn: 150682
* Implement C++ core issue 974, which permits default arguments forDouglas Gregor2012-02-141-13/+12
| | | | | | | | lambda expressions. Because these issue was pulled back from Ready status at the Kona meeting, we still emit an ExtWarn when using default arguments for lambda expressions. llvm-svn: 150519
* Generalize -Wempty-body: warn when statement body is empty (closes: PR11329)Dmitri Gribenko2012-02-141-0/+2
| | | | | | | | | | | | | | * if, switch, range-based for: warn if semicolon is on the same line. * for, while: warn if semicolon is on the same line and either next statement is compound statement or next statement has more indentation. Replacing the semicolon with {} or moving the semicolon to the next line will always silence the warning. Tests from SemaCXX/if-empty-body.cpp merged into SemaCXX/warn-empty-body.cpp. llvm-svn: 150515
* Implement support for lambda capture pack expansions, e.g.,Douglas Gregor2012-02-141-6/+45
| | | | | | [&values...] { print(values...); } llvm-svn: 150497
* Link together the call operator produced from transforming a lambdaDouglas Gregor2012-02-141-11/+13
| | | | | | | | expression with the original call operator, so that we don't try to separately instantiate the call operator. Test and tweak a few more bits for template instantiation of lambda expressions. llvm-svn: 150440
* Introduce support for template instantiation of lambdaDouglas Gregor2012-02-131-4/+136
| | | | | | | | | | | | | | | | | | expressions. This is mostly a simple refact, splitting the main "start a lambda expression" function into smaller chunks that are driven either from the parser (Sema::ActOnLambdaExpr) or during AST transformation (TreeTransform::TransformLambdaExpr). A few minor interesting points: - Added new entry points for TreeTransform, so that we can explicitly establish the link between the lambda closure type in the template and the lambda closure type in the instantiation. - Added a bit into LambdaExpr specifying whether it had an explicit result type or not. We should have had this anyway. This code is 'lightly' tested. llvm-svn: 150417
* Represent C++ direct initializers as ParenListExprs before semantic analysisSebastian Redl2012-02-111-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | instead of having a special-purpose function. - ActOnCXXDirectInitializer, which was mostly duplication of AddInitializerToDecl (leading e.g. to PR10620, which Eli fixed a few days ago), is dropped completely. - MultiInitializer, which was an ugly hack I added, is dropped again. - We now have the infrastructure in place to distinguish between int x = {1}; int x({1}); int x{1}; -- VarDecl now has getInitStyle(), which indicates which of the above was used. -- CXXConstructExpr now has a flag to indicate that it represents list- initialization, although this is not yet used. - InstantiateInitializer was renamed to SubstInitializer and simplified. - ActOnParenOrParenListExpr has been replaced by ActOnParenListExpr, which always produces a ParenListExpr. Placed that so far failed to convert that back to a ParenExpr containing comma operators have been fixed. I'm pretty sure I could have made a crashing test case before this. The end result is a (I hope) considerably cleaner design of initializers. More importantly, the fact that I can now distinguish between the various initialization kinds means that I can get the tricky generalized initializer test cases Johannes Schaub supplied to work. (This is not yet done.) This commit passed self-host, with the resulting compiler passing the tests. I hope it doesn't break more complicated code. It's a pretty big change, but one that I feel is necessary. llvm-svn: 150318
* Track whether a function type has a trailing return type as type sugar. Use thisRichard Smith2012-02-101-3/+6
| | | | | | | | | | | to pretty-print such function types better, and to fix a case where we were not instantiating templates in lexical order. In passing, move the Variadic bit from Type's bitfields to FunctionProtoType to get the Type bitfields down to 32 bits. Also ensure that we always substitute the return type of a function when substituting explicitly-specified arguments, since that can cause us to bail out with a SFINAE error before we hit a hard error in parameter substitution. llvm-svn: 150241
* Introduce basic ASTs for lambda expressions. This covers:Douglas Gregor2012-02-071-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | - Capturing variables by-reference and by-copy within a lambda - The representation of lambda captures - The creation of the non-static data members in the lambda class that store the captured variables - The initialization of the non-static data members from the captured variables - Pretty-printing lambda expressions There are a number of FIXMEs, both explicit and implied, including: - Creating a field for a capture of 'this' - Improved diagnostics for initialization failures when capturing variables by copy - Dealing with temporaries created during said initialization - Template instantiation - AST (de-)serialization - Binding and returning the lambda expression; turning it into a proper temporary - Lots and lots of semantic constraints - Parameter pack captures llvm-svn: 149977
* Added source location for the template keyword in ↵Abramo Bagnara2012-02-061-3/+6
| | | | | | | | | | DependentTemplateSpecializationTypeLoc nodes (DTSTLoc). The new info is propagated to TSTLoc on template instantiation, getting rid of 3 FIXMEs in TreeTransform.h and another one Parser.cpp. Simplified code in TypeSpecLocFiller visitor methods for DTSTLoc and DependentNameTypeLoc by removing what now seems to be dead code (adding corresponding assertions). llvm-svn: 149923
* Removed redundant location info from ElaboratedTypeLoc / DependentNameLoc / ↵Abramo Bagnara2012-02-061-6/+6
| | | | | | DependentTSTLoc. Uniformed names referencing elaborated keyword. No intended functionality changes. llvm-svn: 149889
* Added location for template keyword in TemplateSpecializationTypeLoc. In the ↵Abramo Bagnara2012-02-061-15/+18
| | | | | | process removed some naming ambiguities. llvm-svn: 149870
* Fixed instantiation of DependentScopeDeclRefExpr.Abramo Bagnara2012-02-061-8/+8
| | | | llvm-svn: 149868
* Split Sema::MarkDeclarationReferenced into multiple functions; the ↵Eli Friedman2012-02-021-12/+13
| | | | | | additional entry points are needed to implement C++11 odr-use marking correctly. No functional change in this patch; I'll actually make the change which fixes the odr-use marking in a followup patch. llvm-svn: 149586
* Make sure we call MaybeCreateExprWithCleanups for the sub-expression of an ↵Eli Friedman2012-01-311-0/+1
| | | | | | indirect goto. llvm-svn: 149441
* A couple minor fixes to template instantiation for for-range loops.Eli Friedman2012-01-311-0/+8
| | | | llvm-svn: 149440
* Added source location for the template keyword in AST template-id expressions.Abramo Bagnara2012-01-271-24/+51
| | | | llvm-svn: 149127
* Refactor to share code for handling return statements between lambda ↵Eli Friedman2012-01-261-21/+10
| | | | | | expressions and block literals. As it turns out, almost all the logic can be shared. llvm-svn: 149031
* Don't stack-allocate an IntegerLiteral which can be referred to after the ↵Eli Friedman2012-01-251-3/+6
| | | | | | current method returns. PR11744, part 2. llvm-svn: 148995
* Fix a crash involving a multi-dimensional dependent VLA. PR11744.Eli Friedman2012-01-251-2/+6
| | | | llvm-svn: 148989
* When we're substituting into a function parameter pack and expect toDouglas Gregor2012-01-251-6/+13
| | | | | | | get a function parameter pack (but don't due to weird substitutions), complain. Fixes the last bit of PR11848. llvm-svn: 148960
* In TreeTransform<Derived>::TransformBlockExpr, call ActOnBlockError for errors,Argyrios Kyrtzidis2012-01-251-2/+7
| | | | | | patch by Dmitri Gribenko. llvm-svn: 148915
OpenPOWER on IntegriCloud