summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateDeduction.cpp
Commit message (Collapse)AuthorAgeFilesLines
* FIXME fix: improving diagnostics for template arguments deduction of class ↵Larisse Voufo2013-07-191-15/+10
| | | | | | | | templates and explicit specializations This patch essentially removes all the FIXMEs following calls to DeduceTemplateArguments() that want to keep track of deduction failure info. llvm-svn: 186730
* Revert "Use function overloading instead of template specialization for ↵Larisse Voufo2013-07-191-10/+15
| | | | | | | | diagnosis of bad template argument deductions." This reverts commit a730f548325756d050d4caaa28fcbffdae8dfe95. llvm-svn: 186729
* Use function overloading instead of template specialization for diagnosis of ↵Larisse Voufo2013-07-191-15/+10
| | | | | | bad template argument deductions. llvm-svn: 186727
* Introduce a typedef for the type of NewlyDeducedPacks to avoid repeating the ↵Craig Topper2013-07-081-20/+19
| | | | | | small size of the inner SmallVector. llvm-svn: 185789
* Remove 'else' after 'return'Craig Topper2013-07-081-1/+1
| | | | llvm-svn: 185787
* Function argument formatting fixes. No functional change.Craig Topper2013-07-081-6/+6
| | | | llvm-svn: 185786
* Function argument formatting fixes.Craig Topper2013-07-081-17/+19
| | | | llvm-svn: 185785
* Add typedefs for Densemaps containing SmallVectors to avoid repeating the ↵Craig Topper2013-07-051-1/+1
| | | | | | SmallVector size when creating iterators for the DenseMap. llvm-svn: 185682
* Part of PR15673: If a function template has a default argument in whichRichard Smith2013-07-041-2/+5
| | | | | | | | | substitution failed, report that as a substitution failure rather than pretending that there was no default argument. The test cases in PR15673 have exposed some pre-existing poor diagnostics here. llvm-svn: 185604
* Implement most of N3638 (return type deduction for normal functions).Richard Smith2013-05-041-15/+63
| | | | | | | Missing (somewhat ironically) is support for the new deduction rules in lambda functions, plus PCH support for return type patching. llvm-svn: 181108
* Simplify slightly.Richard Smith2013-05-041-4/+4
| | | | llvm-svn: 181092
* When deducing an 'auto' type, don't modify the type-as-written.Richard Smith2013-04-301-24/+23
| | | | llvm-svn: 180808
* Don't treat a non-deduced 'auto' type as being type-dependent. Instead, thereRichard Smith2013-04-301-39/+13
| | | | | | | | are now two distinct canonical 'AutoType's: one is the undeduced 'auto' placeholder type, and the other is a deduced-but-dependent type. All deduced-to-a-non-dependent-type cases are still non-canonical. llvm-svn: 180789
* Implement C++1y decltype(auto).Richard Smith2013-04-261-2/+22
| | | | llvm-svn: 180610
* Fix PR15291: noreturn adjustment in overload resolution for function ↵Douglas Gregor2013-04-171-16/+71
| | | | | | templates, from Alexander Zinenko! llvm-svn: 179680
* Sema: Preserve attributes on parameters in instantiated function templates.Jordan Rose2013-03-081-5/+1
| | | | | | | | | | | | | | | | | | This was causing correctness issues for ARC and the static analyzer when a function template has "consumed" Objective-C object parameters (i.e. parameters that will be released by the function before returning). The fix is threefold: (1) Actually copy over the attributes from old ParmVarDecls to new ones. (2) Have Sema::BuildFunctionType only work for building FunctionProtoTypes, which it was doing anyway. This allows us to pass an ExtProtoInfo instead of a plain ExtInfo and several flags. (3) Drop param attributes as part of StripImplicitInstantiation, which is used when an implicit instantiation is followed by an explicit one. <rdar://problem/12685622> llvm-svn: 176728
* ArrayRef-ize ASTContext::getFunctionType and Sema::BuildFunctionType.Jordan Rose2013-03-081-2/+1
| | | | | | No (intended) functionality change. llvm-svn: 176726
* Improve 'failed template argument deduction' diagnostic for the case where weRichard Smith2013-01-311-8/+14
| | | | | | | | have a direct mismatch between some component of the template and some component of the argument. The diagnostic now says what the mismatch was, but doesn't yet say which part of the template doesn't match. llvm-svn: 174039
* Replace "failed template argument deduction" diagnostic with something usefulRichard Smith2013-01-311-5/+8
| | | | | | in the one case where we've already factored out a reason code. llvm-svn: 174036
* Use 'const Decl *' throughout code completion in SemaDmitri Gribenko2013-01-231-1/+1
| | | | llvm-svn: 173277
* Once we've collected the template arguments for aDouglas Gregor2013-01-181-3/+7
| | | | | | | | partially-substituted parameter pack in a template, forget about the partially-substituted parameter pack: it is now completed. Fixes <rdar://problem/12176336>. llvm-svn: 172859
* s/CPlusPlus0x/CPlusPlus11/gRichard Smith2013-01-021-6/+6
| | | | llvm-svn: 171367
* Fix http://stackoverflow.com/questions/13521163Richard Smith2012-12-061-13/+4
| | | | | | | | | | | Don't require that, during template deduction, a template specialization type as a function parameter has at least as many template arguments as one used in a function argument (not even if the argument has been resolved to an exact type); the additional parameters might be provided by default template arguments in the template. We don't need this check, since we now implement [temp.deduct.call]p4 with an additional check after deduction. llvm-svn: 169475
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-5/+5
| | | | | | | | | | | | | uncovered. This required manually correcting all of the incorrect main-module headers I could find, and running the new llvm/utils/sort_includes.py script over the files. I also manually added quite a few missing headers that were uncovered by shuffling the order or moving headers up to be main-module-headers. llvm-svn: 169237
* SemaTemplateDeduction.cpp: Prune two obsolete descriptions. [-Wdocumentation]NAKAMURA Takumi2012-11-141-9/+0
| | | | | | | | | | | | | | | | | * getMostSpecialized() /// \param Index if non-NULL and the result of this function is non-nULL, /// receives the index corresponding to the resulting function template /// specialization. * DeduceTemplateArguments() /// \param Name the name of the function being called. This is only significant /// when the function template is a conversion function template, in which /// case this routine will also perform template argument deduction based on /// the function to which llvm-svn: 167909
* When template deduction fails on a derived class, try a template deduction onRichard Trieu2012-11-071-1/+6
| | | | | | | | | | the base class. If the base class deduction succeeds, use those results. If it fails, keep using the results from the derived class template deduction. This prevents an assertion later where the type of deduction failure doesn't match up with the template deduction info. llvm-svn: 167550
* Fix assertion failure with auto and nested initializer list; PR14272.Eli Friedman2012-11-061-2/+3
| | | | llvm-svn: 167506
* Fix the AST representation for non-type template arguments to encodeEli Friedman2012-09-261-10/+56
| | | | | | | | | | | | enough information so we can mangle them correctly in cases involving dependent parameter types. (This specifically impacts cases involving null pointers and cases involving parameters of reference type.) Fix the mangler to use this information instead of trying to scavenge it out of the parameter declaration. <rdar://problem/12296776>. llvm-svn: 164656
* Fix a small FIXME involving template partial ordering andEli Friedman2012-09-191-16/+13
| | | | | | member function templates with an rvalue ref qualifier. llvm-svn: 164267
* Fix function template partial ordering rules for static vs. non-staticEli Friedman2012-09-191-9/+12
| | | | | | functions. llvm-svn: 164263
* Remove Context argument from TemplateDeductionInfo constructor. It was no ↵Craig Topper2012-09-191-5/+5
| | | | | | longer needed after the unused Context member was removed in r164104. llvm-svn: 164196
* Don't perform template argument deduction against invalid templates;Douglas Gregor2012-09-131-0/+12
| | | | | | | it's likely to lead to a crash later on. Fixes PR12933 / <rdar://problem/11525335>. llvm-svn: 163838
* 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
OpenPOWER on IntegriCloud