summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateDeduction.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* PR9023: A template template parameter whose template parameter list contains anRichard Smith2012-09-071-1/+1
| | | | | | | | | | | | | unexpanded parameter pack is a pack expansion. Thus, as with a non-type template parameter which is a pack expansion, it needs to be expanded early into a fixed list of template parameters. Since the expanded list of template parameters is not itself a parameter pack, it is permitted to appear before the end of the template parameter list, so also remove that restriction (for both template template parameter pack expansions and non-type template parameter pack expansions). llvm-svn: 163369
* Fix a bunch of -Wdocumentation warnings.Dmitri Gribenko2012-08-231-2/+0
| | | | llvm-svn: 162452
* Fix undefined behavior: member function calls where 'this' is a null pointer.Richard Smith2012-08-231-1/+5
| | | | llvm-svn: 162430
* When performing the deduced/actual argument type check for C++Douglas Gregor2012-07-181-0/+10
| | | | | | | | [temp.deduct.call]p4 under Objective-C++ ARC, make sure to adjust the qualifiers to introduce the implicit strong lifetime when needed. Fixes <rdar://problem/11825671>. llvm-svn: 160412
* PR13365: Fix code which was trying to treat an array of DeducedTemplateArgumentRichard Smith2012-07-161-5/+10
| | | | | | | | as an array of its base class TemplateArgument. Switch the const TemplateArgument* parameters of InstantiatingTemplate's constructors to ArrayRef<TemplateArgument> to prevent this from happening again in the future. llvm-svn: 160245
* PR13136:Richard Smith2012-07-091-3/+11
| | | | | | | | | | | | | | | * When substituting a reference to a non-type template parameter pack where the corresponding argument is a pack expansion, transform into an expression which contains an unexpanded parameter pack rather than into an expression which contains a pack expansion. This causes the SubstNonTypeTemplateParmExpr to be inside the PackExpansionExpr, rather than outside, so the expression still looks like a pack expansion and can be deduced. * Teach MarkUsedTemplateParameters that we can deduce a reference to a template parameter if it's wrapped in a SubstNonTypeTemplateParmExpr (such nodes are added during alias template substitution). llvm-svn: 159922
* PR13243: When deducing a non-type template parameter which is specified as anRichard Smith2012-07-081-2/+11
| | | | | | | | expression, skip over any SubstNonTypeTemplateParmExprs which alias templates may have inserted before checking for a DeclRefExpr referring to a non-type template parameter declaration. llvm-svn: 159909
* PR13293: Defer deduction of an auto type with a dependent declarator, such ↵Richard Smith2012-07-081-4/+39
| | | | | | as "auto (*f)(T t)". llvm-svn: 159908
* Documentation cleanup: making \param docs match the code.James Dennett2012-06-221-2/+2
| | | | llvm-svn: 158982
* Diagnostics cleanup: Fixing \params to match the code.James Dennett2012-06-221-3/+3
| | | | llvm-svn: 158981
* Still more Doxygen documentation fixes:James Dennett2012-06-141-2/+2
| | | | | | | | * Escape #, < and @ symbols where Doxygen would try to interpret them; * Fix several function param documentation where names had got out of sync; * Delete param documentation referring to parameters that no longer exist. llvm-svn: 158472
* Plug a long standing memory leak in TemplateArgument.Benjamin Kramer2012-06-071-5/+6
| | | | | | | | | | | | | | | The integral APSInt value is now stored in a decomposed form and the backing store for large values is allocated via the ASTContext. This way its not leaked as TemplateArguments are never destructed when they are allocated in the ASTContext. Since the integral data is immutable it is now shared between instances, making copying TemplateArguments a trivial operation. Currently getting the integral data out of a TemplateArgument requires creating a new APSInt object. This is cheap when the value is small but can be expensive if it's not. If this turns out to be an issue a more efficient accessor could be added. llvm-svn: 158150
* 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
OpenPOWER on IntegriCloud