summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateDeduction.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* [OpenCL] Pipe type supportXiuli Pan2016-01-091-0/+2
| | | | | | | | | | | | | | | Summary: Support for OpenCL 2.0 pipe type. This is a bug-fix version for bader's patch reviews.llvm.org/D14441 Reviewers: pekka.jaaskelainen, Anastasia Subscribers: bader, Anastasia, cfe-commits Differential Revision: http://reviews.llvm.org/D15603 llvm-svn: 257254
* Improve diagnostic for the case where a function template candidate is rejectedRichard Smith2015-12-311-2/+6
| | | | | | | | by overload resolution because deduction succeeds, but the substituted parameter type for some parameter (with deduced type) doesn't exactly match the corresponding adjusted argument type. llvm-svn: 256657
* Implement [temp.deduct.type]p6: if the nested-name-specifier of a type isRichard Smith2015-12-301-10/+14
| | | | | | dependent, the type is a non-deduced context. llvm-svn: 256651
* ArrayRef-ize TemplateParameterList. NFCDavid Majnemer2015-12-271-1/+1
| | | | llvm-svn: 256463
* [TrailingObjects] Convert ASTTemplateKWAndArgsInfo and ↵James Y Knight2015-12-241-1/+1
| | | | | | | | | | | | | | | | | | | ASTTemplateArgumentListInfo. Doing so required separating them so that the former doesn't inherit from the latter anymore. Investigating that, it became clear that the inheritance wasn't actually providing real value in any case. So also: - Remove a bunch of redundant functions (getExplicitTemplateArgs, getOptionalExplicitTemplateArgs) on various Expr subclasses which depended on the inheritance relationship. - Switched external callers to use pre-existing accessors that return the data they're actually interested in (getTemplateArgs, getNumTemplateArgs, etc). - Switched internal callers to use pre-existing getTemplateKWAndArgsInfo. llvm-svn: 256359
* Split RequireCompleteType into a function that actually requires that the typeRichard Smith2015-12-181-2/+4
| | | | | | | | | | | | | | | | | | | is complete (with an error produced if not) and a function that merely queries whether the type is complete. Either way we'll trigger instantiation if necessary, but only the former will diagnose and recover from missing module imports. The intent of this change is to prevent a class of bugs where code would call RequireCompleteType(..., 0) and then ignore the result. With modules, we must check the return value and use it to determine whether the definition of the type is visible. This also fixes a debug info quality issue: calls to isCompleteType do not trigger the emission of debug information for a type in limited-debug-info mode. This allows us to avoid emitting debug information for type definitions in more cases where we believe it is safe to do so. llvm-svn: 256049
* Wire a SourceLocation into IsDerivedFrom and move the RequireCompleteType callRichard Smith2015-12-181-1/+1
| | | | | | | | for the derived class into it. This is mostly just a cleanup, but could in principle be a bugfix if there is some codepath that reaches here and didn't previously require a complete type (I couldn't find any such codepath, though). llvm-svn: 256037
* [NFC] Improve a comment from my previous commit (r255221)Faisal Vali2015-12-101-1/+1
| | | | llvm-svn: 255244
* Add parentheses to suppress a -Wparentheses warning.Craig Topper2015-12-101-2/+2
| | | | llvm-svn: 255231
OpenPOWER on IntegriCloud