summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/TreeTransform.h
Commit message (Collapse)AuthorAgeFilesLines
* Start refactoring code for capturing variables and 'this' so that it is ↵Eli Friedman2012-01-111-4/+1
| | | | | | shared between lambda expressions and block literals. llvm-svn: 147917
* Unlike in C++03, a constant-expression is not an unevaluated operand in C++11.Richard Smith2011-12-201-14/+14
| | | | | | | | | | | | | | | | | | | | | | Split out a new ExpressionEvaluationContext flag for this case, and don't treat it as unevaluated in C++11. This fixes some crash-on-invalids where we would allow references to class members in potentially-evaluated constant expressions in static member functions, and also fixes half of PR10177. The fix to PR10177 exposed a case where template instantiation failed to provide a source location for a diagnostic, so TreeTransform has been tweaked to supply source locations when transforming a type. The source location is still not very good, but MarkDeclarationsReferencedInType would need to operate on a TypeLoc to improve it further. Also fix MarkDeclarationReferenced in C++98 mode to trigger instantiation for static data members of class templates which are used in constant expressions. This fixes a link-time problem, but we still incorrectly treat the member as non-constant. The rest of the fix for that issue is blocked on PCH support for early-instantiated static data members, which will be added in a subsequent patch. llvm-svn: 146955
* When we manage to re-use an expression during tree transformation (=Douglas Gregor2011-12-101-8/+8
| | | | | | | | template instantiation), and that expression might produce a temporary, invoke MaybeBindToTemporary. Otherwise, we forget to destroy objects, release objects, etc. Fixes <rdar://problem/10531073>. llvm-svn: 146301
* If block literal return type is not specified, return type of the block is Fariborz Jahanian2011-12-031-0/+2
| | | | | | | inferred from return types. All the return statements have to agree about the type. // rdar://10466373 llvm-svn: 145774
* Fix the instantiation of pseudo-object expressions. This is aJohn McCall2011-11-301-2/+8
| | | | | | | | | really bad way to go about this, but I'm not sure there's a better choice without substantial changes to TreeTransform --- most notably, preserving implicit semantic nodes instead of discarding and rebuilding them. llvm-svn: 145480
* Don't crash when transforming an ill-formed pseudo-destructorDouglas Gregor2011-11-091-1/+1
| | | | | | expression. Fixes PR11339. llvm-svn: 144159
* Change the AST representation of operations on Objective-CJohn McCall2011-11-061-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | property references to use a new PseudoObjectExpr expression which pairs a syntactic form of the expression with a set of semantic expressions implementing it. This should significantly reduce the complexity required elsewhere in the compiler to deal with these kinds of expressions (e.g. IR generation's special l-value kind, the static analyzer's Message abstraction), at the lower cost of specifically dealing with the odd AST structure of these expressions. It should also greatly simplify efforts to implement similar language features in the future, most notably Managed C++'s properties and indexed properties. Most of the effort here is in dealing with the various clients of the AST. I've gone ahead and simplified the ObjC rewriter's use of properties; other clients, like IR-gen and the static analyzer, have all the old complexity *and* all the new complexity, at least temporarily. Many thanks to Ted for writing and advising on the necessary changes to the static analyzer. I've xfailed a small diagnostics regression in the static analyzer at Ted's request. llvm-svn: 143867
* Pull out conversion on LHS of -> and . into its own function. This happensRichard Smith2011-10-261-35/+15
| | | | | | | implicitly in LookupMemberExpr and explicitly in cases where template instantiation doesn't redo the lookup. llvm-svn: 143046
* Fix crash due to missing array-to-pointer decay when instantiating an unresolvedRichard Smith2011-10-261-3/+8
| | | | | | member expression. Refactoring to follow. llvm-svn: 143017
* UnresolvedMemberExprs need lvalue-to-rvalue conversions during templateRichard Smith2011-10-261-0/+7
| | | | | | instantiations too. llvm-svn: 143016
* Restore r142914 and r142915, now with missing file and apparentJohn McCall2011-10-251-3/+3
| | | | | | GCC compiler workaround. llvm-svn: 142931
* Revert r142914 and r142915, due to possibly missing file.NAKAMURA Takumi2011-10-251-3/+3
| | | | | | r142914: "Introduce a placeholder type for "pseudo object"" r142915: "Pull the pseudo-object stuff into its own file." llvm-svn: 142921
* Introduce a placeholder type for "pseudo object"John McCall2011-10-251-3/+3
| | | | | | | | | | | | | | | expressions: expressions which refer to a logical rather than a physical l-value, where the logical object is actually accessed via custom getter/setter code. A subsequent patch will generalize the AST for these so that arbitrary "implementing" sub-expressions can be provided. Right now the only client is ObjC properties, but this should be generalizable to similar language features, e.g. Managed C++'s __property methods. llvm-svn: 142914
* Don't forget the lvalue-to-rvalue conversion on the LHS when instantiating aRichard Smith2011-10-251-0/+5
| | | | | | | dependent ->, where the member being referred to is an anonymous struct or union. This path was missed by the fix in r142890. llvm-svn: 142910
* Check for unexpanded parameter packs in the name that guards aDouglas Gregor2011-10-251-0/+3
| | | | | | | | | Microsoft __if_exists/__if_not_exists statement. Also note that we weren't traversing DeclarationNameInfo *at all* within the RecursiveASTVisitor, which would be rather fatal for variadic templates. llvm-svn: 142906
* Implement support for dependent Microsoft __if_exists/__if_not_existsDouglas Gregor2011-10-251-1/+80
| | | | | | | | | | statements. As noted in the documentation for the AST node, the semantics of __if_exists/__if_not_exists are somewhat different from the way Visual C++ implements them, because our parsed-template representation can't accommodate VC++ semantics without serious contortions. Hopefully this implementation is "good enough". llvm-svn: 142901
* Don't forget the lvalue-to-rvalue conversion on the LHS of an -> when rebuildingRichard Smith2011-10-251-0/+5
| | | | | | it during template instantiation, for a known RHS decl. llvm-svn: 142890
* Add -Wc++98-compat warning for enumerations in nested name specifiers.Richard Smith2011-10-201-0/+3
| | | | llvm-svn: 142568
* When transforming the arguments for a C++ "new" expression, make sureDouglas Gregor2011-10-181-8/+9
| | | | | | | to drop the implicitly-generated value initialization expression used for initializing scalars. Fixes <rdar://problem/10283928>. llvm-svn: 142330
* Add template instantiation support for AtomicExpr.Eli Friedman2011-10-141-3/+34
| | | | llvm-svn: 142012
* Initial implementation of __atomic_* (everything except __atomic_is_lock_free).Eli Friedman2011-10-111-0/+7
| | | | llvm-svn: 141632
* When substituting into a sizeof parameter pack expression in a contextDouglas Gregor2011-10-101-5/+19
| | | | | | | where we can't expand (i.e., multi-level substitution), be sure to substitute the pack with its level-reduced pack. Fixes PR10230. llvm-svn: 141568
* Support for C1x _Atomic specifier (see testcase). This is primarily being ↵Eli Friedman2011-10-061-0/+35
| | | | | | | | committed at the moment to help support C++0x <atomic>, but it should be a solid base for implementing the full specification of C1x _Atomic. Thanks to Jeffrey Yasskin for the thorough review! llvm-svn: 141330
* Added a flag to identify resolved overloaded function references.Abramo Bagnara2011-10-051-6/+9
| | | | llvm-svn: 141171
* Allow getting all source locations of selector identifiers in a ObjCMessageExpr.Argyrios Kyrtzidis2011-10-031-6/+10
| | | | | | | | | | | | | Instead of always storing all source locations for the selector identifiers we check whether all the identifiers are in a "standard" position; "standard" position is -Immediately before the arguments: [foo first:1 second:2] -With a space between the arguments: [foo first: 1 second: 2] -For nullary selectors, immediately before ']': [foo release] In such cases we infer the locations instead of storing them. llvm-svn: 140987
* Removing a bunch of dead returns/breaks after llvm_unreachables.David Blaikie2011-09-231-3/+0
| | | | llvm-svn: 140407
* Switch assert(0/false) llvm_unreachable.David Blaikie2011-09-231-3/+3
| | | | llvm-svn: 140367
* ArrayRef-ifying the UnexpandedParameterPacks passed to ↵David Blaikie2011-09-221-11/+7
| | | | | | Sema::CheckParameterPacksForExpansion llvm-svn: 140290
* ArrayRef-ifying Function/BlockDecl's setParamsDavid Blaikie2011-09-211-1/+1
| | | | llvm-svn: 140268
* The lock operand to an @synchronized statement is also John McCall2011-07-271-4/+16
| | | | | | | supposed to be a full-expression; make it so. In ARC, make sure we retain the lock for the entire protected block. llvm-svn: 136271
* Clean up the analysis of the collection operand to ObjCJohn McCall2011-07-271-1/+14
| | | | | | | | | | | for-in statements; specifically, make sure to close over any temporaries or cleanups it might require. In ARC, this has implications for the lifetime of the collection, so emit it with a retain and release it upon exit from the loop. rdar://problem/9817306 llvm-svn: 136204
* When we decide not to rebuild an instantiated C++ 'new' expressionDouglas Gregor2011-07-261-0/+13
| | | | | | | | that allocates an array of objects with a non-trivial destructor, be sure to mark the destructor is "used". Fixes PR10480 / <rdar://problem/9834317>. llvm-svn: 136081
* now that we have a centralized place to do so, add some using declarations forChris Lattner2011-07-201-21/+21
| | | | | | | some common llvm types: stringref and smallvector. This cleans up the codebase quite a bit. llvm-svn: 135576
* Store bracket locations for array subscript expressions, from Erik Verbruggen!Douglas Gregor2011-07-151-5/+18
| | | | llvm-svn: 135275
* Create a new expression node, SubstNonTypeTemplateParmExpr,John McCall2011-07-151-0/+8
| | | | | | | | to represent a fully-substituted non-type template parameter. This should improve source fidelity, as well as being generically useful for diagnostics and such. llvm-svn: 135243
* Properly implement the scope restriction on the NRVO forDouglas Gregor2011-07-061-3/+5
| | | | | | | | | | | | throw-expressions, such that we don't consider the NRVO when the non-volatile automatic object comes from outside the innermost try scope (C++0x [class.copymove]p13). In C++98/03, our ASTs were incorrect but it didn't matter because IR generation doesn't actually apply the NRVO here. In C++0x, however, we were moving from an object when in fact we should have copied from it. Fixes PR10142 / <rdar://problem/9714312>. llvm-svn: 134548
* When tree-transforming an expression sequence, always flag expandedJohn McCall2011-07-061-5/+7
| | | | | | | | | | variadic argument pack expansions as having changed, rather than doing it for each changed expansion, which leaves out zero-argument packs with catastrophic consequences. Fixes PR10260. llvm-svn: 134483
* When instantiating a C++ "new" expression, don't fake source locationsDouglas Gregor2011-06-271-2/+6
| | | | | | | | for the '(' and ')' around the initializer unless we actually have an initializer. Fixes PR10197, an issue where we were value-initializing rather than default-initializing. llvm-svn: 133913
* Rename objc_lifetime -> objc_ownership, and modify diagnostics to talk about ↵Argyrios Kyrtzidis2011-06-241-1/+1
| | | | | | | | 'ownership', not 'lifetime'. rdar://9477613. llvm-svn: 133779
* Introduce a new AST node describing reference binding to temporaries.Douglas Gregor2011-06-211-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | MaterializeTemporaryExpr captures a reference binding to a temporary value, making explicit that the temporary value (a prvalue) needs to be materialized into memory so that its address can be used. The intended AST invariant here is that a reference will always bind to a glvalue, and MaterializeTemporaryExpr will be used to convert prvalues into glvalues for that binding to happen. For example, given const int& r = 1.0; The initializer of "r" will be a MaterializeTemporaryExpr whose subexpression is an implicit conversion from the double literal "1.0" to an integer value. IR generation benefits most from this new node, since it was previously guessing (badly) when to materialize temporaries for the purposes of reference binding. There are likely more refactoring and cleanups we could perform there, but the introduction of MaterializeTemporaryExpr fixes PR9565, a case where IR generation would effectively bind a const reference directly to a bitfield in a struct. Addresses <rdar://problem/9552231>. llvm-svn: 133521
* Objective-C++ ARC: eliminate the utterly unjustified loophole thatDouglas Gregor2011-06-171-4/+7
| | | | | | | | | | | silently dropped ownership qualifiers that were being applied to ownership-qualified, substituted type that was *not* a substituted template type parameter. We now provide a diagnostic in such cases, and recover by dropping the added qualifiers. Document this behavior in the ARC specification. llvm-svn: 133309
* Objective-ARC++: infer template type arguments ofDouglas Gregor2011-06-171-6/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | ownership-unqualified retainable object type as __strong. This allows us to write, e.g., std::vector<id> and we'll infer that the vector's element types have __strong ownership semantics, which is far nicer than requiring: std::vector<__strong id> Note that we allow one to override the ownership qualifier of a substituted template type parameter, e.g., given template<typename T> struct X { typedef __weak T type; }; X<id> is treated the same as X<__strong id>. At instantiation type, the __weak in "__weak T" overrides the (inferred or specified) __strong on the template argument type, so that we can still provide metaprogramming transformations. This is part of <rdar://problem/9595486>. llvm-svn: 133303
* Automatic Reference Counting.John McCall2011-06-151-1/+83
| | | | | | | | | | Language-design credit goes to a lot of people, but I particularly want to single out Blaine Garst and Patrick Beard for their contributions. Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself, in no particular order. llvm-svn: 133103
* Implement support for C++11 in-class initialization of non-static data members.Richard Smith2011-06-111-2/+6
| | | | llvm-svn: 132878
* Made changes to how 'struct'/'class' mismatches are handled in ↵Richard Trieu2011-06-101-1/+2
| | | | | | | | | | | | | | | | | -Wmismatched-tags. - Removed fix-it hints from template instaniations since changes to the templates are rarely helpful. - Changed the caret in template instaniations from the class/struct name to the class/struct keyword, matching the other warnings. - Do not offer fix-it hints when multiple declarations disagree. Warnings are still given. - Once a definition is found, offer a fix-it hint to all previous declarations with wrong tag. - Declarations that disagree with a previous definition will get a fix-it hint to change the declaration. llvm-svn: 132831
* Add support for builtin astype:Tanya Lattner2011-06-041-0/+7
| | | | | | | __builtin_astype(): Used to reinterpreted as another data type of the same size using for both scalar and vector data types. Added test case. llvm-svn: 132612
* Ensure we enter an unevaluated context when instantiating a noexceptAlexis Hunt2011-05-311-0/+1
| | | | | | expression. Fixes bug raised by hhinnant to cfe-dev llvm-svn: 132350
* Fix a regression in the source locations for unary trait expressions.Chandler Carruth2011-05-291-1/+1
| | | | | | | | | | | I tried to use an assert to prove that I could remove each of the arguments I did, but ended up writing my assert with inverted logic. Doh! Reported by Xi Wang on cfe-dev. I have manually verified the source locations and ranges for these using -ast-dump. I tried writing a test case that would catch these, but these expressions aren't exposed in the c-index-test's token annotation utility. llvm-svn: 132284
* Add a convenience interface for checking expression arguments to unaryChandler Carruth2011-05-261-1/+1
| | | | | | | | | | | | | traits which uses the information embedded in the expression. Use this to simplify several interfaces which repeated information embedded in the expression through explicit arguments. I added an assertion that the only extra piece of data to come in from the parser matches what is stored in the expression. No functionality change intended here. Also cleaned up the doxygen comments for some of these methods and some formatting oddities. llvm-svn: 132115
* Implement a new type node, UnaryTransformType, designed to represent aAlexis Hunt2011-05-241-0/+35
| | | | | | | | type that turns one type into another. This is used as the basis to implement __underlying_type properly - with TypeSourceInfo and proper behavior in the face of templates. llvm-svn: 132017
OpenPOWER on IntegriCloud