summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateDeduction.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Switch a lot of call-sites over to using the new value-kind calculations.John McCall2010-11-241-1/+1
| | | | llvm-svn: 120084
* Implement C++0x [temp.func.order]p3 (aka DR532) properly. InDouglas Gregor2010-11-151-5/+33
| | | | | | | | | | | | | particular, we only add the implement object parameter type if only one of the function templates is a non-static member function template. Moreover, since this DR differs from existing practice in C++98/03, this commit implements the existing practice (which ignores the first parameter of the function template that is not the non-static member function template) in C++98/03 mode. llvm-svn: 119145
* Implement C++ [over.match.funcs]p4 as it concerns partial ordering ofDouglas Gregor2010-11-121-4/+40
| | | | | | function templates. Fixes PR8130. llvm-svn: 118944
* Remove broken support for variadic templates, along with the variousDouglas Gregor2010-11-071-25/+26
| | | | | | | | | | | | | abstractions (e.g., TemplateArgumentListBuilder) that were designed to support variadic templates. Only a few remnants of variadic templates remain, in the parser (parsing template type parameter packs), AST (template type parameter pack bits and TemplateArgument::Pack), and Sema; these are expected to be used in a future implementation of variadic templates. But don't get too excited about that happening now. llvm-svn: 118385
* When determining which template partial specialization is more specialized,Argyrios Kyrtzidis2010-11-051-2/+8
| | | | | | make sure to setup the instantiation stack. Fixes rdar://8620775 & http://llvm.org/PR8234 llvm-svn: 118314
* When performing template argument deduction against a template-id,Douglas Gregor2010-11-021-2/+9
| | | | | | | only keep deduction results for successful deductions, so that they can be compared against each other. Fixes PR8462, from Richard Smith! llvm-svn: 117983
* No really, we don't have a retain/release system for statements/expressionsJohn McCall2010-10-261-1/+1
| | | | | | anymore. llvm-svn: 117357
* Introduce support for emitting diagnostics (warnings + their notes)Douglas Gregor2010-10-121-4/+18
| | | | | | | | | | | | | | | that are suppressed during template argument deduction. This change queues diagnostics computed during template argument deduction. Then, if the resulting function template specialization or partial specialization is chosen by overload resolution or partial ordering (respectively), we will emit the queued diagnostics at that point. This addresses most of PR6784. However, the check for unnamed/local template arguments (which existed before this change) is still only skin-deep, and needs to be extended to look deeper into types. It must be improved to finish PR6784. llvm-svn: 116373
* Enter the context of the declared function template when performingJohn McCall2010-10-121-2/+6
| | | | | | | deduction and the final substitution, but not while substituting the explicit template arguments. Fixes rdar://problem/8537391 llvm-svn: 116332
* When finalizing a function template specialization following templateDouglas Gregor2010-10-121-7/+4
| | | | | | | | | | argument deduction, make sure to check the correctness of deduced template type arguments (which we had previously skipped) along with other kinds of template arguments. This fixes part of PR6784, but we're still swallowing the extension warning about unnamed/local template arguments. llvm-svn: 116327
* When performing template argument deduction of a function templateDouglas Gregor2010-09-291-4/+14
| | | | | | | | against a function type, be sure to check the type of the resulting function template specialization against the desired function type after substituting the deduced/defaulted template arguments. Fixes PR8196. llvm-svn: 115086
* Perform the function-to-pointer adjustment during template argumentDouglas Gregor2010-08-301-31/+43
| | | | | | | | | deduction where the parameter is a function reference, function pointer, or member function pointer and the argument is an overloaded function. Fixes <rdar://problem/8360106>, a template argument deduction issue found by Boost.Filesystem. llvm-svn: 112523
* When perform exact-qualifier-match template argument deduction,John McCall2010-08-281-1/+24
| | | | | | | properly account for the possibility that certain opaque types might be more qualified than they appear. Fixes PR7708. llvm-svn: 112390
* Propagate whether an id-expression is the immediate argument ofJohn McCall2010-08-271-8/+17
| | | | | | | | | | | | | | | | | | | an '&' expression from the second caller of ActOnIdExpression. Teach template argument deduction that an overloaded id-expression doesn't give a valid type for deduction purposes to a non-static member function unless the expression has the correct syntactic form. Teach ActOnIdExpression that it shouldn't try to create implicit member expressions for '&function', because this isn't a permitted form of use for member functions. Teach CheckAddressOfOperand to diagnose these more carefully. Some of these cases aren't reachable right now because earlier diagnostics interrupt them. llvm-svn: 112258
* Move more stuff out of Sema.h.John McCall2010-08-251-18/+21
| | | | llvm-svn: 112026
* Struggle mightily against header inclusion in Sema.h.John McCall2010-08-241-0/+2
| | | | llvm-svn: 111904
* Another step in the process of making the parser depend on Sema:John McCall2010-08-201-1/+1
| | | | | | | | | - move DeclSpec &c into the Sema library - move ParseAST into the Parse library Reflect this change in a thousand different includes. Reflect this change in the link orders. llvm-svn: 111667
* When deducing the element type of an array, ignore qualifiers ifJohn McCall2010-08-191-3/+7
| | | | | | the context allows us to ignore qualifiers on the array type itself. llvm-svn: 111486
* Move Sema's headers into include/clang/Sema, renaming a few along the way.Douglas Gregor2010-08-121-1/+1
| | | | llvm-svn: 110945
* Remove some incorrect assertions when deduction template arguments inDouglas Gregor2010-08-061-2/+0
| | | | | | | | a template-argument-list. When template template parameters are involved, we won't already have checked the template-argument-list (it may not be known yet!). Fixes PR7807. llvm-svn: 110444
* TDK_InconsistentQuals is really totally different from TDK_Inconsistent.John McCall2010-08-051-2/+2
| | | | | | | Rename it to TDK_Underqualified to avoid this sort of confusion and give it its own diagnostic. llvm-svn: 110318
* Permit template argument deduction to add qualifiers within ObjC objectJohn McCall2010-08-051-1/+2
| | | | | | pointers like it can with normal and member pointers. llvm-svn: 110313
* Preserve calling convention etc. across template instantiations. Eli Friedman2010-08-051-1/+2
| | | | llvm-svn: 110304
* Split DependentNameType into two types. DependentNameType represents theJohn McCall2010-06-111-0/+12
| | | | | | | | | | | | | | case of an elaborated-type-specifier like 'typename A<T>::foo', and DependentTemplateSpecializationType represents the case of an elaborated-type-specifier like 'typename A<T>::template B<T>'. The TypeLoc representation of a DependentTST conveniently exactly matches that of an ElaboratedType wrapping a TST. Kill off the explicit rebuild methods for RebuildInCurrentInstantiation; the standard implementations work fine because the nested name specifier is computable in the newly-entered context. llvm-svn: 105801
* Substantially alter the design of the Objective C type AST by introducingJohn McCall2010-05-151-0/+1
| | | | | | | | | | | | | | | | | | | | | ObjCObjectType, which is basically just a pair of one of {primitive-id, primitive-Class, user-defined @class} with a list of protocols. An ObjCObjectPointerType is therefore just a pointer which always points to one of these types (possibly sugared). ObjCInterfaceType is now just a kind of ObjCObjectType which happens to not carry any protocols. Alter a rather large number of use sites to use ObjCObjectType instead of ObjCInterfaceType. Store an ObjCInterfaceType as a pointer on the decl rather than hashing them in a FoldingSet. Remove some number of methods that are no longer used, at least after this patch. By simplifying ObjCObjectPointerType, we are now able to easily remove and apply pointers to Objective-C types, which is crucial for a certain kind of ObjC++ metaprogramming common in WebKit. llvm-svn: 103870
* When performing template argument deduction, match Objective C pointersJohn McCall2010-05-131-3/+9
| | | | | | against pointer patterns. llvm-svn: 103706
* Be more careful about picking a template parameter when we fail to ↵Douglas Gregor2010-05-091-2/+4
| | | | | | substitute explicit template arguments into a function template llvm-svn: 103369
* When printing an overload candidate that failed due to SFINAE, print aDouglas Gregor2010-05-081-4/+9
| | | | | | | | | | | specific message that includes the template arguments, e.g., test/SemaTemplate/overload-candidates.cpp:27:20: note: candidate template ignored: substitution failure [with T = int *] typename T::type get_type(const T&); // expected-note{{candidate ... ^ llvm-svn: 103348
* Improve overload-candidate diagnostic for a function template thatDouglas Gregor2010-05-081-1/+4
| | | | | | | | | | | | | | | | | | | | failed because the explicitly-specified template arguments did not match its template parameters, e.g., test/SemaTemplate/overload-candidates.cpp:18:8: note: candidate template ignored: invalid explicitly-specified argument for template parameter 'I' void get(const T&); ^ test/SemaTemplate/overload-candidates.cpp:20:8: note: candidate template ignored: invalid explicitly-specified argument for 1st template parameter void get(const T&); ^ llvm-svn: 103344
* When performing partial ordering of class template partialDouglas Gregor2010-04-291-1/+9
| | | | | | | | | specializations, substitute the deduced template arguments and check the resulting substitution before concluding that template argument deduction succeeds. This marvelous little fix makes a bunch of Boost.Spirit tests start working. llvm-svn: 102601
* For template argument deduction from class template partialDouglas Gregor2010-04-291-51/+73
| | | | | | | specializations, separate out the deduction part from the checking and substitution of the deduced arguments. llvm-svn: 102600
* Access-check during template argument deduction from the context of theJohn McCall2010-04-291-3/+3
| | | | | | template decl itself, not its context. Testcase to follow; fixes selfhost. llvm-svn: 102578
* Properly switch into the declaring scope of a template when performingJohn McCall2010-04-291-0/+6
| | | | | | | | | | template argument deduction or (more importantly) the final substitution required by such deduction. Makes access control magically work in these cases. Fixes PR6967. llvm-svn: 102572
* When instantiating a function template specialization followingDouglas Gregor2010-04-281-2/+4
| | | | | | | | template argument deduction, use the lexical declaration context as the owner for friend function templates. Fixes 2 failures in Boost.Graph. llvm-svn: 102489
* Make the InjectedClassNameType the canonical type of the current instantiationJohn McCall2010-04-271-5/+13
| | | | | | | | | | | | | | | | of a class template or class template partial specialization. That is to say, in template <class T> class A { ... }; or template <class T> class B<const T*> { ... }; make 'A<T>' and 'B<const T*>' sugar for the corresponding InjectedClassNameType when written inside the appropriate context. This allows us to track the current instantiation appropriately even inside AST routines. It also allows us to compute a DeclContext for a type much more efficiently, at some extra cost every time we write a template specialization (which can be optimized, but I've left it simple in this patch). llvm-svn: 102407
* Rename TypenameType to DependentNameType in anticipation of someDouglas Gregor2010-03-311-3/+3
| | | | | | refactoring work in this area. llvm-svn: 100019
* After performing template argument deduction for a function template,Douglas Gregor2010-03-281-28/+162
| | | | | | | | | | | | | | | | | | | | check deduced non-type template arguments and template template arguments against the template parameters for which they were deduced, performing conversions as appropriate so that deduced template arguments get the same treatment as explicitly-specified template arguments. This is the bulk of PR6723. Also keep track of whether deduction of a non-type template argument came from an array bound (vs. anywhere else). With this information, we enforce C++ [temp.deduct.type]p17, which requires exact type matches when deduction deduces a non-type template argument from something that is not an array bound. Finally, when in a SFINAE context, translate the "zero sized arrays are an extension" extension diagnostic into a hard error (for better standard conformance), which was a minor part of PR6723. llvm-svn: 99734
* When deducing an integral template argument for a non-type templateDouglas Gregor2010-03-261-32/+35
| | | | | | | | | | parameter, keep the integral value exactly as it was in the source code rather than trying to convert it to the type of the non-type template parameter (which may still be dependent!). The value will then be converted to the appropriate type once we check the resulting template arguments. Fixes PR6707. llvm-svn: 99611
* Improve our handling of local instantiation scopes in two related ways:Douglas Gregor2010-03-251-7/+5
| | | | | | | | | | | | | | | - When substituting template arguments as part of template argument deduction, introduce a new local instantiation scope. - When substituting into a function prototype type, introduce a new "temporary" local instantiation scope that merges with its outer scope but also keeps track of any additions it makes, removing them when we exit that scope. Fixes PR6700, where we were getting too much mixing of local instantiation scopes due to template argument deduction that substituted results into function types. llvm-svn: 99509
* Create a new InjectedClassNameType to represent bare-word references to the John McCall2010-03-101-0/+9
| | | | | | | | | | | | | injected class name of a class template or class template partial specialization. This is a non-canonical type; the canonical type is still a template specialization type. This becomes the TypeForDecl of the pattern declaration, which cleans up some amount of code (and complicates some other parts, but whatever). Fixes PR6326 and probably a few others, primarily by re-establishing a few invariants about TypeLoc sizes. llvm-svn: 98134
* Split out types that are non-canonical unless dependent as their ownJohn McCall2010-03-011-0/+21
| | | | | | | | | | | category. Use this in a few places to eliminate unnecessary TST cases and do some future-proofing. Provide terrible manglings for typeof. Mangle decltype with some hope of accuracy. Our manglings for some of the cases covered in the testcase are different from gcc's, which I've raised as an issue with the ABI list. llvm-svn: 97523
* Thread a source location into the template-argument deduction routines. ThereJohn McCall2010-02-081-11/+12
| | | | | | | may be some other places that could take advantage of this new information, but I haven't really looked yet. llvm-svn: 95600
* Require a complete type before examining base classes during template argumentChandler Carruth2010-02-071-72/+80
| | | | | | | | | | deduction. This requires refactoring the deduction to have access to the Sema object instead of merely the ASTContext. Still leaves something to be desired due to poor source location. Fixes PR6257 and half of PR6259. llvm-svn: 95528
* Extract a common base class between UnresolvedLookupExpr andJohn McCall2010-02-021-23/+8
| | | | | | UnresolvedMemberExpr and employ it in a few places where it's useful. llvm-svn: 95072
* Implement C++ [temp.deduct.call]p6, template argument deduction for overloadedJohn McCall2010-02-021-31/+111
| | | | | | | | | | arguments. Fix a bug where incomplete explicit specializations were being passed through as legitimate. Fix a bug where the absence of an explicit specialization in an overload set was causing overall deduction to fail. Fixes PR6191. llvm-svn: 95052
* Implement access control for overloaded functions. Suppress access controlJohn McCall2010-01-271-37/+32
| | | | | | | diagnostics in "early" lookups, such as during typename checks and when building unresolved lookup expressions. llvm-svn: 94647
* After dyn_cast'ing, it generally makes sense to check the *output* ofDouglas Gregor2010-01-141-1/+1
| | | | | | the dyn_cast against NULL rather than the *input*. Fixes PR6025. llvm-svn: 93435
* When resolving a single function template specialization to aDouglas Gregor2010-01-111-1/+4
| | | | | | | function, be sure to adjust the resulting argument type to a pointer (if necessary). Fixes PR5910 and PR5949. llvm-svn: 93178
* Implement name lookup for conversion function template specializationsDouglas Gregor2010-01-111-10/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | (C++ [temp.mem]p5-6), which involves template argument deduction based on the type named, e.g., given struct X { template<typename T> operator T*(); } x; when we call x.operator int*(); we perform template argument deduction to determine that T=int. This template argument deduction is needed for template specialization and explicit instantiation, e.g., template<> X::operator float*() { /* ... */ } and when calling or otherwise naming a conversion function (as in the first example). This fixes PR5742 and PR5762, although there's some remaining ugliness that's causing out-of-line definitions of conversion function templates to fail. I'll look into that separately. llvm-svn: 93162
* Make sure to use ASTContext::getAs*ArrayType() when decomposing arrayDouglas Gregor2010-01-041-2/+2
| | | | | | types. Fixes APFloat.cpp compilation failure. llvm-svn: 92523
OpenPOWER on IntegriCloud