summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateDeduction.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [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
* Added the pack_elements range accessor. Refactoring some for loops to use ↵Aaron Ballman2014-07-151-8/+4
| | | | | | range-based for loops instead. No functional changes intended. llvm-svn: 213095
* Fix PR18498: Support explicit template arguments with variadic generic lambdasFaisal Vali2014-06-011-1/+11
| | | | | | | | | | | | | | | | | | | | http://llvm.org/bugs/show_bug.cgi?id=18498 This code was resulting in a crash: auto L = [](auto ... v) { }; L.operator()<int>(3); The reason is that the partially-substituted-pack is incorrectly retained within the current-instantiation-scope during template-argument-finalization, and because lambda's are local, there parent instantiation scopes are merged, which leads to the expansion-pattern being retained in the finalized specialization. This patch ensures that once we have finalized deduction of a parameter-pack, we remove the partially-substituted-pack so that it doesn't cause CheckParameterPacksForExpansion to incorrectly inform the caller that it needs to retain the expansion pattern. Thanks to Richard Smith for the review! http://reviews.llvm.org/D2135 llvm-svn: 209992
* PR12961 - Extend DR532 to cover C++98/03.Nikola Smiljanic2014-05-311-19/+9
| | | | llvm-svn: 209955
* Refactoring. Remove release and take methods from ActionResult. Rename ↵Nikola Smiljanic2014-05-291-4/+4
| | | | | | takeAs to getAs. llvm-svn: 209800
* PR19878: If a pack expansion appears within another pack expansion, correctlyRichard Smith2014-05-291-199/+178
| | | | | | deduce any packs that are expanded by both expansions. llvm-svn: 209786
* [C++11] Use 'nullptr'. Sema edition.Craig Topper2014-05-261-27/+27
| | | | llvm-svn: 209613
* [C++11] Replacing CXXRecordDecl iterators bases_begin() and bases_end() with ↵Aaron Ballman2014-03-131-5/+3
| | | | | | iterator_range bases(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203803
* [C++11] Replacing FunctionDecl iterators param_begin() and param_end() with ↵Aaron Ballman2014-03-071-5/+2
| | | | | | iterator_range params(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203248
* [C++11] Replace llvm::tie with std::tie.Benjamin Kramer2014-03-021-3/+3
| | | | llvm-svn: 202639
* Rename getResultType() on function and method declarations to getReturnType()Alp Toker2014-01-251-40/+36
| | | | | | | | | | | | | | | A return type is the declared or deduced part of the function type specified in the declaration. A result type is the (potentially adjusted) type of the value of an expression that calls the function. Rule of thumb: * Declarations have return types and parameters. * Expressions have result types and arguments. llvm-svn: 200082
* Rename FunctionProtoType accessors from 'arguments' to 'parameters'Alp Toker2014-01-201-13/+12
| | | | | | | | | | | | | | | | | Fix a perennial source of confusion in the clang type system: Declarations and function prototypes have parameters to which arguments are supplied, so calling these 'arguments' was a stretch even in C mode, let alone C++ where default arguments, templates and overloading make the distinction important to get right. Readability win across the board, especially in the casting, ADL and overloading implementations which make a lot more sense at a glance now. Will keep an eye on the builders and update dependent projects shortly. No functional change. llvm-svn: 199686
* Use the appropriate SourceLocation for the template backtrace when doingNick Lewycky2014-01-111-16/+12
| | | | | | template argument deduction. llvm-svn: 198995
* Objective-C ARC++: Prefer references to __strong/__weak over ↵Douglas Gregor2014-01-021-0/+11
| | | | | | | | __unsafe_unretained. Fixes <rdar://problem/15713945>. llvm-svn: 198343
* PR18229: Fix typo in assert condition.Richard Smith2013-12-121-1/+1
| | | | llvm-svn: 197185
* Handle CC and NoReturn when instantiating members of class templates.Rafael Espindola2013-12-011-17/+24
| | | | | | | | Before we were considering them only when instantiating templates. This fixes pr18033. llvm-svn: 196050
* Further fixes when thiscall is the default for methods.Rafael Espindola2013-11-191-0/+17
| | | | | | | | | | | | | | | | | | The previous patches tried to deduce the correct function type. I now realize this is not possible in general. Consider class foo { template <typename T> static void bar(T v); }; extern template void foo::bar(const void *); We will only know that bar is static after a lookup, so we have to handle this in the template instantiation code. This patch reverts my previous two changes (but not the tests) and instead handles the issue in DeduceTemplateArguments. llvm-svn: 195154
* Objective-C++ ARC: Improve the conversion to a const __unsafe_unretained ↵Douglas Gregor2013-11-081-7/+10
| | | | | | | | | | | | | reference. Under ARC++, a reference to a const Objective-C pointer is implicitly treated as __unsafe_unretained, and can be initialized with (e.g.) a __strong lvalue. Make sure this behavior does not break template argument deduction and (related) that partial ordering still prefers a 'T* const&' template over a 'T const&' template when this case kicks in. Fixes <rdar://problem/14467941>. llvm-svn: 194239
* Refactor: Extract specializing the generic lambda call operator during ↵Faisal Vali2013-10-241-141/+133
| | | | | | | | | | | | conversion to fptr deduction into its own function. No functionality change. All clang regression tests pass. Thanks! llvm-svn: 193383
* Make InstantiatingTemplate depth checks clearerAlp Toker2013-10-081-4/+4
| | | | | | | | | | The bool conversion operator on InstantiatingTemplate never added value and only served to obfuscate the template instantiation routines. This replaces the conversion and its callers with an explicit isInvalid() function to make it clear what's going on at a glance. llvm-svn: 192177
OpenPOWER on IntegriCloud