summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateDeduction.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Move Sema::RequireCompleteType() and Sema::RequireCompleteExprType()Douglas Gregor2012-05-041-3/+1
| | | | | | | | | | | off PartialDiagnostic. PartialDiagnostic is rather heavyweight for something that is in the critical path and is rarely used. So, switch over to an abstract-class-based callback mechanism that delays most of the work until a diagnostic is actually produced. Good for ~11k code size reduction in the compiler and 1% speedup in -fsyntax-only on the code in <rdar://problem/11004361>. llvm-svn: 156176
* Implement C++11 [expr.prim.general]p3, which permits the use of 'this'Douglas Gregor2012-04-161-15/+34
| | | | | | | | | | | | | | | | | | | | | | | 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
* Implement support for null non-type template arguments for non-typeDouglas Gregor2012-04-061-6/+4
| | | | | | | template parameters of pointer, pointer-to-member, or nullptr_t type in C++11. Fixes PR9700 / <rdar://problem/11193097>. llvm-svn: 154219
* When performing template argument deduction for an initializer list,Douglas Gregor2012-04-041-8/+14
| | | | | | | | | | | | | | | | | be sure to perform the argument type adjustments in [temp.deduct.call]p2, e.g., array decay. And, when performing these deductions in the context of 'auto', make sure that we're deducing the P' in std::initializer_list<P'> rather than the whole initializer list. Together, this makes code like for( auto s : {"Deferred", "New", "Open", "Review"}) { } work properly. llvm-svn: 153998
* Support deducing template arguments from nested initializer lists. PR12119.Sebastian Redl2012-03-151-3/+37
| | | | llvm-svn: 152848
* C++11 [temp.deduct.call]p6 tweak: when given a set of overlaodedDouglas Gregor2012-03-121-18/+30
| | | | | | | | | functions that includes an explicit template argument list, perform an inner deduction against each of the function templates in that list and, if successful, use the result of that deduction for the outer template argument deduction. Fixes PR11713. llvm-svn: 152575
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-111-6/+6
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
* When template argument deduction is ignoring qualifiers, perform deepDouglas Gregor2012-03-111-15/+28
| | | | | | | | structural comparison of non-dependent types. Otherwise, we end up rejecting cases where the non-dependent types don't match due to qualifiers in, e.g., a pointee type. Fixes PR12132. llvm-svn: 152529
* ArrayRef'ize various functions in the AST/Parser/Sema.Ahmed Charles2012-02-251-5/+5
| | | | llvm-svn: 151447
* More ArrayRef-ification of methods.Bill Wendling2012-02-221-1/+1
| | | | llvm-svn: 151152
* ArrayRef-icize the function arguments.Bill Wendling2012-02-221-1/+1
| | | | llvm-svn: 151151
* Introduce support for template instantiation of lambdaDouglas Gregor2012-02-131-0/+5
| | | | | | | | | | | | | | | | | | 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
* Track whether a function type has a trailing return type as type sugar. Use thisRichard Smith2012-02-101-17/+29
| | | | | | | | | | | 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
* Make sure template argument deduction is consistently performed in an ↵Eli Friedman2012-02-081-9/+14
| | | | | | unevaluated context. llvm-svn: 150049
* SmallBitVectorize the deduced parameter set.Benjamin Kramer2012-01-301-22/+16
| | | | llvm-svn: 149253
* Minor fixups for auto deduction of initializer lists.Sebastian Redl2012-01-231-12/+10
| | | | | | | | Fix some review comments. Add a test for deduction when std::initializer_list isn't available yet. Fix redundant error messages. This fixes and outstanding FIXME too. llvm-svn: 148735
* More dead code removal (using -Wunreachable-code)David Blaikie2012-01-201-7/+5
| | | | llvm-svn: 148577
* Replace a dubious use of SmallVectorImpl with a proper copy.Benjamin Kramer2012-01-201-3/+4
| | | | llvm-svn: 148549
* Auto deduction support for std::initializer_list, including for-range ↵Sebastian Redl2012-01-171-6/+34
| | | | | | | | support. This means you can now write: for (int i : {1, 4, 512, 23, 251}) {} llvm-svn: 148353
* Template argument deduction for std::initializer_list arguments from ↵Sebastian Redl2012-01-171-10/+50
| | | | | | initializer lists. llvm-svn: 148352
* Rename the first of 11 DeduceTemplateArguments overloads.Sebastian Redl2012-01-171-114/+117
| | | | | | | | | | | | | | | There are 5 functions of this name in Sema, and 6 more static helpers in SemaTemplateDeduction.cpp. The Sema functions have jobs like "deduce for function call", "deduce for taking the address", etc. The static helpers have jobs like "deduce by comparing two types", "deduce by comparing two lists of types", "deduce by comparing two template arguments", etc. The fact that they all are called the same and only differ in two of their 6 or more arguments makes the code using them very hard to read. Here I rename the one function that concerns me most at the moment, but as a matter of cleanup, the others will eventually be renamed as well. llvm-svn: 148351
* Introduce a static Sema::MarkDeducedTemplateParameters() that only dependsArgyrios Kyrtzidis2012-01-171-51/+53
| | | | | | | | on an ASTContext. This is a step towards making clang_getCursorCompletionString not depend on Sema. llvm-svn: 148277
* Add feature to diagnostics that will provide more information on functionRichard Trieu2011-11-231-4/+10
| | | | | | | | | | pointer mismatch. Cases covered are: initialization, assignment, and function arguments. Additional text will give the extra information about the nature of the mismatch: different classes for member functions, wrong number of parameters, different parameter type, different return type, and function qualifier mismatch. llvm-svn: 145114
* Resolve placeholder expressions before trying to deduceJohn McCall2011-11-151-1/+7
| | | | | | | 'auto'. Introduce a convenience method to make this a bit easier, and use it elsewhere. llvm-svn: 144605
* When we determine that a function template specialization produced asDouglas Gregor2011-10-121-9/+9
| | | | | | | | | | | | | | | part of template argument deduction is ill-formed, we mark it as invalid and treat it as a deduction failure. If we happen to find that specialization again, treat it as a deduction failure rather than silently building a call to the declaration. Fixes PR11117, a marvelous bug where deduction failed after creating an invalid specialization, causing overload resolution to pick a different candidate. Then we performed a similar overload resolution later, and happily picked the invalid specialization to call... resulting in a silent link failure. llvm-svn: 141809
* Per the note in C++0x [temp.deduct.call]p4, don't attempt templateDouglas Gregor2011-10-091-6/+9
| | | | | | | argument deduction against a function parameter that has no deducible template parameters in it. Fixes PR8598. llvm-svn: 141517
* Support for C1x _Atomic specifier (see testcase). This is primarily being ↵Eli Friedman2011-10-061-1/+18
| | | | | | | | 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
* Removing a bunch of dead returns/breaks after llvm_unreachables.David Blaikie2011-09-231-2/+0
| | | | llvm-svn: 140407
* Switch assert(0/false) llvm_unreachable.David Blaikie2011-09-231-2/+2
| | | | llvm-svn: 140367
* Don't allow template argument deduction to deduce a placeholder type,Douglas Gregor2011-09-221-0/+4
| | | | | | ever. Fixes PR10939. llvm-svn: 140304
* Fix a typo when determining whether to strip cv-qualifiers during template ↵Douglas Gregor2011-08-301-1/+1
| | | | | | argument deduction llvm-svn: 138787
* Objective-C++ ARC: When performing template argument deduction for aDouglas Gregor2011-07-261-0/+11
| | | | | | | lifetime-qualified template parameter, ensure that the deduced template argument is a lifetime type. Fixes <rdar://problem/9828157>. llvm-svn: 136078
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-79/+79
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* Accept no-return stripping conversions for pointer type arguments afterChandler Carruth2011-06-181-1/+8
| | | | | | | | | | | | | | | | | | | deducing template parameter types. Recently Clang began enforcing the more strict checking that the argument type and the deduced function parameter type (after substitution) match, but that only consideres qualification conversions. One problem with this patch is that we check noreturn conversions and qualification conversions independently. If a valid conversion would require *both*, perhaps interleaved with each other, it will be rejected. If this actually occurs (I'm not yet sure it does) and is in fact a problem (I'm not yet sure it is), there is a FIXME to implement more intelligent conversion checking. However, this step at least allows Clang to resume accepting valid code we're seeing in the wild. llvm-svn: 133327
* Objective-ARC++: infer template type arguments ofDouglas Gregor2011-06-171-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix refactoro, silencing an MSVC warning. Thanks, Francois.Douglas Gregor2011-06-171-1/+1
| | | | llvm-svn: 133257
* Extend the deduced/actual argument type checking of C++Douglas Gregor2011-06-171-1/+12
| | | | | | | [temp.deduct.call]p4 to the deduction performed for 'auto', finishing the fix for PR9233. llvm-svn: 133239
* Factor the checking of the deduced argument type against the actualDouglas Gregor2011-06-171-73/+84
| | | | | | | argument type for C++ [temp.deduct.call]p4 out of Sema::FinishTemplateArgumentDeduction(). No functionality change. llvm-svn: 133237
* Implement the consistency checking for C++ [temp.deduct.call]p3, whichDouglas Gregor2011-06-161-13/+139
| | | | | | | | | | | | | | | checks that the deduced argument type for a function call matches the actual argument type provided. The only place we've found where the consistency checking should actually cause template argument deduction failure is due to qualifier differences that don't fall into the realm of qualification conversions (which are *not* checked when we initially perform deduction). However, we're performing the full checking as specified in the standard to ensure that no other cases exist. Fixes PR9233 / <rdar://problem/9039590>. llvm-svn: 133163
* Automatic Reference Counting.John McCall2011-06-151-0/+7
| | | | | | | | | | 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
* Eliminate a 'default' case in template argument deduction, where weDouglas Gregor2011-06-151-4/+124
| | | | | | | | | | | | | | | | | | were just punting on template argument deduction for a number of type nodes. Most of them, obviously, didn't matter. As a consequence of this, make extended vector types (via the ext_vector_type attribute) actually work properly for several important cases: - If the attribute appears in a type-id (i.e, not attached to a typedef), actually build a proper vector type - Build ExtVectorType whenever the size is constant; previously, we were building DependentSizedExtVectorType when the size was constant but the type was dependent, which makes no sense at all. - Teach template argument deduction to handle ExtVectorType/DependentSizedExtVectorType. llvm-svn: 133060
* Eliminate an unnecessary include. FIXMEs -=1 Douglas Gregor2011-06-151-1/+0
| | | | llvm-svn: 133056
* When performing template argument deduction given a function argumentDouglas Gregor2011-06-031-0/+6
| | | | | | | | | of incomplete array type, attempt to complete the array type. This was made much easier by Chandler's addition of RequireCompleteExprType(), which I've tweaked (slightly) to improve the consistency of the DeclRefExpr. Fixes PR7985. llvm-svn: 132530
* When checking the instantiation of a default template argument againstDouglas Gregor2011-06-031-1/+1
| | | | | | | | | | | | | | | the template parameter, perform the checking as a "specified" template argument rather than a "deduced" template argument; the latter implies stricter type checking that is not permitted for default template arguments. Also, cleanup our handling of substitution of explicit template arguments for a function template. We were actually performing some substitution of default arguments at this point! Fixes PR10069. llvm-svn: 132529
* Implement a new type node, UnaryTransformType, designed to represent aAlexis Hunt2011-05-241-0/+7
| | | | | | | | 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
* It's considered poor form to create references to the overloadedDouglas Gregor2011-05-211-1/+3
| | | | | | | function type. Educate template argument deduction thusly, fixing PR9974 / <rdar://problem/9479155>. llvm-svn: 131811
* Re-applies the patch first applied way back in r106099, withChandler Carruth2011-05-011-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | accompanying fixes to make it work today. The core of this patch is to provide a link from a TemplateTypeParmType back to the TemplateTypeParmDecl node which declared it. This in turn provides much more precise information about the type, where it came from, and how it functions for AST consumers. To make the patch work almost a year after its first attempt, it needed serialization support, and it now retains the old getName() interface. Finally, it requires us to not attempt to instantiate the type in an unsupported friend decl -- specifically those coming from template friend decls but which refer to a specific type through a dependent name. A cleaner representation of the last item would be to build FriendTemplateDecl nodes for these, storing their template parameters etc, and to perform proper instantation of them like any other template declaration. They can still be flagged as unsupported for the purpose of access checking, etc. This passed an asserts-enabled bootstrap for me, and the reduced test case mentioned in the original review thread no longer causes issues, likely fixed at somewhere amidst the 24k revisions that have elapsed. llvm-svn: 130628
* When comparing parameters of reference-to-qualified type duringDouglas Gregor2011-04-301-2/+5
| | | | | | | | | partial ordering of function templates, use a simple superset relationship rather than the convertibility-implying isMoreQualifiedThan/compatibilyIncludes relationship. Fixes partial ordering between references and address-space-qualified references. llvm-svn: 130612
* More cleanup of template argument deduction and its handling ofDouglas Gregor2011-04-281-4/+41
| | | | | | | non-CVR qualifiers. We can now properly match address-space--qualified references during template argument deduction. llvm-svn: 130365
* Clean up the handling of non-CVR qualifiers in template argumentDouglas Gregor2011-04-271-5/+3
| | | | | | | deduction. The good news is that address spaces are a lot less broken in this regard than I'd expected. llvm-svn: 130346
OpenPOWER on IntegriCloud