summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateDeduction.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Fix PR24694 (CWG1591): Deducing array bound and element type from ↵Faisal Vali2015-12-101-13/+52
| | | | | | | | | | | | | | | initializer list https://llvm.org/bugs/show_bug.cgi?id=24694 http://wg21.link/cwg1591 Teach DeduceFromInitializerList in SemaTemplateDeduction.cpp to deduce against array (constant and dependent sized) parameters (really, reference to arrays since they don't decay to pointers), by checking if the template parameter is either one of those kinds of arrays, and if so, deducing each initializer list element against the element type, and then deducing the array bound if needed. In brief, this patch enables the following code: template<class T, int N> int *f(T (&&)[N]); int *ip = f({1, 2, 3}); llvm-svn: 255221
* [MS Compat] Adjust thiscall to cdecl when deducing template argumentsDavid Majnemer2015-11-301-2/+11
| | | | | | | | | | Function types can be extracted from member pointer types. However, the type is not appropriate without first adjusting the calling convention. This fixes PR25661. llvm-svn: 254323
* Add support for GCC's '__auto_type' extension, per the GCC manual:Richard Smith2015-11-111-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | https://gcc.gnu.org/onlinedocs/gcc/Typeof.html Differences from the GCC extension: * __auto_type is also permitted in C++ (but only in places where it could appear in C), allowing its use in headers that might be shared across C and C++, or used from C++98 * __auto_type can be combined with a declarator, as with C++ auto (for instance, "__auto_type *p") * multiple variables can be declared in a single __auto_type declaration, with the C++ semantics (the deduced type must be the same in each case) This patch also adds a missing restriction on applying typeof to a bit-field, which GCC has historically rejected in C (due to lack of clarity as to whether the operand should be promoted). The same restriction also applies to __auto_type in C (in both GCC and Clang). This also fixes PR25449. Patch by Nicholas Allegra! llvm-svn: 252690
* Convert a few classes over to use the new TrailingObjects helper.James Y Knight2015-08-061-10/+9
| | | | | | | | | | This initial commit serves as an example -- the remainder of the classes using pointer arithmetic for trailing objects will be converted in subsequent changes. Differential Revision: http://reviews.llvm.org/D11298 llvm-svn: 244262
* [AST] ArrayRefize template argument packs. No functionality change intended.Benjamin Kramer2015-08-051-5/+5
| | | | llvm-svn: 244026
* [Sema] Don't crash when deduction fails for decltype(auto)David Majnemer2015-07-011-0/+2
| | | | | | | | | We didn't check the return result of BuildDecltypeType, resulting in us crashing when we tried to grab the canonical version of the type. This fixes PR23995. llvm-svn: 241131
* Consolidate and unify initializer list deductionHubert Tong2015-06-251-33/+49
| | | | | | | | | | | | | | | | | | | | | | | Summary: This patch reduces duplication in the template argument deduction code for handling deduction from initializer lists in a function call. This extends the fix for PR12119 to also apply to the case where the corresponding parameter is a trailing parameter pack. Test Plan: A test for deduction from nested initializer lists where the corresponding parameter is a trailing parameter pack is added in `clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp`. Reviewers: fraggamuffin, rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D10681 llvm-svn: 240612
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-2/+2
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-2/+2
| | | | | | | | | | | | The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
* Silence Visual C++ warning C4189: 'Result' : local variable is initialized ↵Yaron Keren2015-05-131-2/+4
| | | | | | | | | but not referenced. Sadly, LLVM_ATTRIBUTE_UNUSED does nothing with Visual C++ which means we'll have to workaround such cases again and again. llvm-svn: 237267
* Move private classes into anonymous namespacesBenjamin Kramer2015-03-231-0/+2
| | | | | | Also merge anonymous namespaces in Targets.cpp a bit. NFC. llvm-svn: 232945
* PR22435: Correctly implement tiebreaker for reference ordering in functionRichard Smith2015-02-201-158/+47
| | | | | | | template partial ordering rules. This rule applies per pair of types being compared, not per pair of function templates being compared. llvm-svn: 229965
* Initial support for C++ parameter completionFrancisco Lopes da Silva2015-01-211-10/+16
| | | | | | | | | | | | | | | | | | | | The improved completion in call context now works with: - Functions. - Member functions. - Constructors. - New expressions. - Function call expressions. - Template variants of the previous. There are still rough edges to be fixed: - Provide support for optional parameters. (fix known) - Provide support for member initializers. (fix known) - Provide support for variadic template functions. (fix unknown) - Others? llvm-svn: 226670
* restore fix for 18645, buildbot apparently gave a false positive.Nathan Sidwell2015-01-161-30/+17
| | | | | | Correct logic concerning 'T &&' deduction against lvalues. llvm-svn: 226278
* reverting due to build bot failureNathan Sidwell2015-01-121-17/+30
| | | | llvm-svn: 225684
* fix pr18645. Correct logic concerning 'T &&' deduction against lvalues.Nathan Sidwell2015-01-101-30/+17
| | | | llvm-svn: 225587
* PR22117: Fix a case where we would get confused about which function parameterRichard Smith2015-01-091-0/+3
| | | | | | | | | | we're instantiating, if there's a ParmVarDecl within a FunctionDecl context that is not a parameter of that function. Add some asserts to catch this kind of issue more generally, and fix another bug exposed by those asserts where we were missing a local instantiation scope around substitution of explicitly-specified template arguments. llvm-svn: 225490
* Adding a -Wunused-value warning for expressions with side effects used in an ↵Aaron Ballman2014-12-171-1/+1
| | | | | | unevaluated expression context, such as sizeof(), or decltype(). Also adds a similar warning when the expression passed to typeid() *is* evaluated, since it is equally likely that the user would expect the expression operand to be unevaluated in that case. llvm-svn: 224465
* Update for LLVM API change to make Small(Ptr)Set::insert return ↵David Blaikie2014-11-191-1/+1
| | | | | | pair<iterator, bool> as per the C++ standard's associative container concept. llvm-svn: 222335
* PR21246: DebugInfo: Emit the appropriate type (cv qualifiers, ↵David Blaikie2014-10-161-7/+4
| | | | | | | | | | | | | | | | | | | | | | | | | reference-ness, etc) for non-type template parameters Plumb through the full QualType of the TemplateArgument::Declaration, as it's insufficient to only know whether the type is a reference or pointer (that was necessary for mangling, but insufficient for debug info). This shouldn't increase the size of TemplateArgument as TemplateArgument::Integer is still longer by another 32 bits. Several bits of code were testing that the reference-ness of the parameters matched, but this seemed to be insufficient (various other features of the type could've mismatched and wouldn't've been caught) and unnecessary, at least insofar as removing those tests didn't cause anything to fail. (Richard - perchaps you can hypothesize why any of these checks might need to test reference-ness of the parameters (& explain why reference-ness is part of the mangling - I would've figured that for the reference-ness to be different, a prior template argument would have to be different). I'd be happy to add them in/beef them up and add test cases if there's a reason for them) llvm-svn: 219900
* C++1y is now C++14!Aaron Ballman2014-08-191-2/+2
| | | | | | Changes diagnostic options, language standard options, diagnostic identifiers, diagnostic wording to use c++14 instead of c++1y. It also modifies related test cases to use the updated diagnostic wording. llvm-svn: 215982
* Wrap to 80 columns. No behavior change.Nico Weber2014-07-281-20/+23
| | | | llvm-svn: 214059
OpenPOWER on IntegriCloud