summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateDeduction.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Per [temp.deduct.call], do not deduce an array bound of 0 from an empty ↵Richard Smith2017-01-051-1/+3
| | | | | | initializer list. llvm-svn: 291075
* Factor out more common logic in template argument deduction from function ↵Richard Smith2017-01-051-71/+62
| | | | | | | | call arguments. No functionality change intended. llvm-svn: 291074
* Fix assertion failure on deduction failure due to too short template ↵Richard Smith2017-01-051-2/+3
| | | | | | | | | | | | argument list. We were previously incorrectly using TDK_TooFewArguments to report a template argument list that's too short, but it actually means that the number of arguments in a top-level function call was insufficient. When diagnosing the problem, SemaOverload would (rightly) assert that the failure kind didn't make any sense. llvm-svn: 291064
* Fix failure to treat overloaded function in braced-init-list as a ↵Richard Smith2017-01-041-4/+3
| | | | | | | | | | | | | non-deduced context. Previously, if an overloaded function in a braced-init-list was encountered in template argument deduction, and the overload set couldn't be resolved to a particular function, we'd immediately produce a deduction failure. That's not correct; this situation is supposed to result in that particular P/A pair being treated as a non-deduced context, and deduction can still succeed if the type can be deduced from elsewhere. llvm-svn: 291014
* Factor out duplicated code and simplify.Richard Smith2017-01-041-132/+81
| | | | | | No functionality change intended. llvm-svn: 290996
* Fix deduction of pack elements after a braced-init-list.Richard Smith2017-01-041-6/+2
| | | | | | | | | | Previously, if the arguments for a parameter pack contained a braced-init-list, we would abort deduction (keeping the pack deductions from prior arguments) at the point when we reached the braced-init-list, resulting in wrong deductions and rejects-valids. We now just leave a "hole" in the pack for such an argument, which needs to be filled by another deduction of the same pack. llvm-svn: 290933
* Fix template argument deduction when only some of a parameter pack is a ↵Richard Smith2017-01-041-36/+41
| | | | | | | | | | | | | | | | | non-deduced context. When a parameter pack has multiple corresponding arguments, and some subset of them are overloaded functions, it's possible that some subset of the parameters are non-deduced contexts. In such a case, keep deducing from the remainder of the arguments, and resolve the incomplete pack against whatever other deductions we've performed for the pack. GCC, MSVC, and ICC give three different bad behaviors for this case; what we do now (and what we did before) don't exactly match any of them, sadly :( I'm getting a core issue opened to specify more precisely how this should be handled. llvm-svn: 290923
* Revert "DR1391: Check for implicit conversion sequences for non-dependent ↵Renato Golin2017-01-021-26/+10
| | | | | | | | | | | | | | function template parameters between deduction and substitution. The idea is to accept as many cases as possible, on the basis that substitution failure outside the immediate context is much more common during substitution than during implicit conversion sequence formation." This reverts commit r290808, as it broken all ARM and AArch64 test-suite test: MultiSource/UnitTests/C++11/frame_layout Also, please, next time, try to write a commit message in according to our guidelines: http://llvm.org/docs/DeveloperPolicy.html#commit-messages llvm-svn: 290811
* DR1391: Check for implicit conversion sequences for non-dependent functionRichard Smith2017-01-021-10/+26
| | | | | | | | | | | | template parameters between deduction and substitution. The idea is to accept as many cases as possible, on the basis that substitution failure outside the immediate context is much more common during substitution than during implicit conversion sequence formation. This does not implement the partial ordering portion of DR1391, which so far appears to be misguided. llvm-svn: 290808
* Address post-commit review comments.Richard Smith2017-01-021-3/+0
| | | | llvm-svn: 290807
* [c++17] Implement P0522R0 as written. This allows a template template argumentRichard Smith2016-12-311-9/+76
| | | | | | | | | | | | | | | | | | | to be specified for a template template parameter whenever the parameter is at least as specialized as the argument (when there's an obvious and correct mapping from uses of the parameter to uses of the argument). For example, a template with more parameters can be passed to a template template parameter with fewer, if those trailing parameters have default arguments. This is disabled by default, despite being a DR resolution, as it's fairly broken in its current state: there are no partial ordering rules to cope with template template parameters that have different parameter lists, meaning that code that attempts to decompose template-ids based on arity can hit unavoidable ambiguity issues. The diagnostics produced on a non-matching argument are also pretty bad right now, but I aim to improve them in a subsequent commit. llvm-svn: 290792
* Remove redundant assertion.Richard Smith2016-12-311-3/+0
| | | | llvm-svn: 290780
* Remove bogus assertion and add testcase that triggers it.Richard Smith2016-12-301-2/+4
| | | | llvm-svn: 290743
* DR1495: A partial specialization is ill-formed if it is not (strictly) moreRichard Smith2016-12-271-12/+99
| | | | | | | | specialized than the primary template. (Put another way, if we imagine there were a partial specialization matching the primary template, we should never select it if some other partial specialization also matches.) llvm-svn: 290593
* Work around a standard defect: template argument deduction for non-typeRichard Smith2016-12-271-7/+12
| | | | | | | | | template parameters of reference type basically doesn't work, because we're always deducing from an argument expression of non-reference type, so the type of the deduced expression never matches. Instead, compare the type of an expression naming the parameter to the type of the argument. llvm-svn: 290586
* Factor out repeated code for deducing a non-type template parameter as a givenRichard Smith2016-12-271-81/+38
| | | | | | argument value. No functionality change intended. llvm-svn: 290576
* Wdocumentation fixSimon Pilgrim2016-12-261-2/+2
| | | | llvm-svn: 290547
* Fix assertion failure when deducing an auto-typed argument against a ↵Richard Smith2016-12-251-1/+1
| | | | | | different-width int. llvm-svn: 290522
* Fix some subtle wrong partial ordering bugs particularly with C++1z auto-typedRichard Smith2016-12-251-67/+113
| | | | | | | | | | | | | | | | | | non-type template parameters. During partial ordering, when checking the substituted deduced template arguments match the original, check the types of non-type template arguments match even if they're dependent. The only way we get dependent types here is if they really represent types of the other template (which are supposed to be modeled as being substituted for unique, non-dependent types). In order to make this work for auto-typed non-type template arguments, we need to be able to perform auto deduction even when the initializer and (potentially) the auto type are dependent, support for which is the bulk of this patch. (Note that this requires the ability to deduce only a single level of a multi-level dependent type.) llvm-svn: 290511
* Factor out duplication between partial ordering for class template partialRichard Smith2016-12-241-182/+90
| | | | | | specializations and variable template partial specializations. llvm-svn: 290497
* ArrayRefize lists of TemplateArguments in template argument deduction.Richard Smith2016-12-231-48/+33
| | | | llvm-svn: 290461
* Only substitute into type of non-type template parameter once, rather thanRichard Smith2016-12-231-34/+27
| | | | | | | | | | twice, in finalization of template argument deduction. This is a re-commit of r290310 (reverted in r290329); the bug found by the buildbots was fixed in r290399 (we would sometimes build a deduced template argument with a bogus type). llvm-svn: 290403
* When merging two deduced non-type template arguments for the same parameter,Richard Smith2016-12-231-28/+41
| | | | | | | | | | | | | | | | | | | fail the merge if the arguments have different types (except if one of them was deduced from an array bound, in which case take the type from the other). This is correct because (except in the array bound case) the type of the template argument in each deduction must match the type of the parameter, so at least one of the two deduced arguments must have a mismatched type. This is necessary because we would otherwise lose the type information for the discarded template argument in the merge, and fail to diagnose the mismatch. In order to power this, we now properly retain the type of a deduced non-type template argument deduced from a declaration, rather than giving it the type of the template parameter; we'll convert it to the template parameter type when checking the deduced arguments. llvm-svn: 290399
* Speculative revert of r290310 to see if that's the change that's making some ofRichard Smith2016-12-221-27/+34
| | | | | | the bots unhappy. llvm-svn: 290329
* Sema: print qualified name for overload candidatesSaleem Abdulrasool2016-12-221-5/+5
| | | | | | | | | | | | | Print the fully qualified names for the overload candidates. This makes it easier to tell what the ambiguity is. Especially if a template is instantiated after a using namespace, it will not inherit the namespace where it was declared. The specialization will give a message about a partial order being ambiguous for the same (unqualified) name, which does not help identify the failure. Addresses PR31450! llvm-svn: 290315
* Only substitute into type of non-type template parameter once, rather thanRichard Smith2016-12-221-34/+27
| | | | | | twice, in finalization of template argumetn deduction. llvm-svn: 290310
* Factor out checking of template arguments after deduction into a separateRichard Smith2016-12-211-148/+135
| | | | | | | function. (This change would also allow us to handle default template arguments in partial specializations if the standard ever permits them.) llvm-svn: 290225
* PR31081: ignore exception specifications when deducing function templateRichard Smith2016-12-011-34/+79
| | | | | | | arguments from a declaration; despite what the standard says, this form of deduction should not be considering exception specifications. llvm-svn: 288301
* p0012: Teach resolving address of overloaded function with dependent exceptionRichard Smith2016-11-011-0/+9
| | | | | | | | specification to resolve the exception specification as part of the type check, in C++1z onwards. This is not actually part of P0012 / CWG1330 rules for when an exception specification is "needed", but is necessary for sanity. llvm-svn: 285663
* [c++1z] P0012R1: Implement a few remaining pieces: downgrade diagnostic forRichard Smith2016-10-221-3/+9
| | | | | | | | | | | | | | mismatched dynamic exception specifications in expressions from an error to a warning, since this is no longer ill-formed in C++1z. Allow reference binding of a reference-to-non-noexcept function to a noexcept function lvalue. As defect resolutions, also allow a conditional between noexcept and non-noexcept function lvalues to produce a non-noexcept function lvalue (rather than decaying to a function pointer), and allow function template argument deduction to deduce a reference to non-noexcept function when binding to a noexcept function type. llvm-svn: 284905
* P0012R1: Make exception specifications be part of the type system. ThisRichard Smith2016-10-161-6/+5
| | | | | | | implements the bulk of the change (modifying the type system to include exception specifications), but not all the details just yet. llvm-svn: 284337
* P0127R2: Support type deduction for types of non-type template parameters inRichard Smith2016-09-281-22/+61
| | | | | | | | C++1z. Patch by James Touton! Some bugfixes and rebasing by me. llvm-svn: 282651
* Fix bug where template argument deduction of a non-type template parameter usedRichard Smith2016-09-281-1/+30
| | | | | | | | | as a template argument in a template-id, from a null non-type template argument, failed. Extracted from a patch by James Touton! llvm-svn: 282641
* Fix Wdocumentation unknown parameter warningSimon Pilgrim2016-08-121-116/+114
| | | | llvm-svn: 278503
* P0217R3: Perform semantic checks and initialization for the bindings in aRichard Smith2016-08-111-23/+17
| | | | | | | decomposition declaration for arrays, aggregate-like structs, tuple-like types, and (as an extension) for complex and vector types. llvm-svn: 278435
* Reapply r276069 with workaround for MSVC 2013Hubert Tong2016-07-301-2/+2
| | | | llvm-svn: 277286
* Revert r276069: MSVC bots not happyHubert Tong2016-07-201-2/+2
| | | | llvm-svn: 276074
* Concepts: Create space for requires-clause in TemplateParameterList; NFCHubert Tong2016-07-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Space for storing the //constraint-expression// of the //requires-clause// associated with a `TemplateParameterList` is arranged by taking a bit out of the `NumParams` field for the purpose of determining whether there is a //requires-clause// or not, and by adding to the trailing objects tied to the `TemplateParameterList`. An accessor is provided. An appropriate argument is supplied to `TemplateParameterList::Create` at the various call sites. Serialization changes will addressed as the Concepts implementation becomes more solid. Drive-by fix: This change also replaces the custom `FixedSizeTemplateParameterListStorage` implementation with one that follows the interface provided by `llvm::TrailingObjects`. Reviewers: aaron.ballman, faisalv, rsmith Subscribers: cfe-commits, nwilson Differential Revision: https://reviews.llvm.org/D19322 llvm-svn: 276069
* [AST] Use ArrayRef in more interfacesDavid Majnemer2016-07-071-4/+2
| | | | | | | | | ArrayRef is a little better than passing around a pointer/length pair. No functional change is intended. llvm-svn: 274732
* [AST] Use ArrayRef in more interfacesDavid Majnemer2016-07-031-21/+12
| | | | | | | | ArrayRef is a little better than passing around a pointer/length pair. No functional change is intended. llvm-svn: 274475
* [Sema] Disallow ambigious base classes in template argument deductionErik Pilkington2016-06-281-22/+31
| | | | | | | | Fixes PR28195. Differential revision: http://reviews.llvm.org/D21653 llvm-svn: 274077
* Use more ArrayRefsDavid Majnemer2016-06-241-5/+3
| | | | | | No functional change is intended, just a small refactoring. llvm-svn: 273647
* Apply some suggestions from clang-tidy's performance-unnecessary-value-param.Benjamin Kramer2016-06-151-7/+4
| | | | | | No functionality change intended. llvm-svn: 272789
* Fix PR27601 by reverting [r267453] - Refactor traversal of bases in ↵Faisal Vali2016-05-191-26/+45
| | | | | | | | | | | | deduction of template parameters from base This reversal is being done with r267453's author's (i.e. Richard Smith's) permission. This fixes https://llvm.org/bugs/show_bug.cgi?id=27601 Also, per Richard's request the examples from the bug report have been added to our test suite. llvm-svn: 270016
* Refactor traversal of bases in deduction of template parameters from baseRichard Smith2016-04-251-45/+26
| | | | | | | classes of an argument to use CXXRecordDecl::forallBases. Fix forallBases to only visit each base class once. llvm-svn: 267453
* When deducing template parameters from base classes of an argument type, don'tRichard Smith2016-04-251-76/+83
| | | | | | | preserve any deduced types from a failed deduction to a subsequent attempt at deduction. Patch by Erik Pilkington! llvm-svn: 267444
* [Sema] Make type deduction work with some overloadable functionsGeorge Burgess IV2016-03-191-0/+5
| | | | | | | | | | | Some functions can't have their address taken. If we encounter an overload set where only one of the candidates can have its address taken, we should automatically select that candidate's type in type deduction. Differential Revision: http://reviews.llvm.org/D15591 llvm-svn: 263888
* Fix the template instantiation of ExtParameterInfos; tests to follow.John McCall2016-03-011-4/+10
| | | | llvm-svn: 262289
* Ensure that we substitute into the declaration of a template parameter packRichard Smith2016-02-031-4/+32
| | | | | | | (that is not a pack expansion) during template argument deduction, even if we deduced that the pack would be empty. llvm-svn: 259688
* Refactor conversion of deduced template arguments to reduce repetition.Richard Smith2016-02-031-103/+49
| | | | llvm-svn: 259687
OpenPOWER on IntegriCloud