summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplate.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Further fixes when thiscall is the default for methods.Rafael Espindola2013-11-191-16/+3
| | | | | | | | | | | | | | | | | | 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
* Issue a diagnostic if we see a templated friend declaration that we do notRichard Smith2013-11-081-3/+4
| | | | | | support. llvm-svn: 194273
* Sema: Emit a nicer diagnostic when IndirectFieldDecls show up ↵David Majnemer2013-10-261-2/+2
| | | | | | inappropriately in non-type template arguments llvm-svn: 193462
* Sema: Correctly build pointer-to-member arguments from a template argument ↵David Majnemer2013-10-261-1/+2
| | | | | | | | | | | | with an IndirectFieldDecl We only considered FieldDecl and CXXMethodDecl as appropriate which would cause us to believe the IndirectFieldDecl corresponded to an argument of it's field type instead of a pointer-to-member type. This fixes PR17696. llvm-svn: 193461
* Sema: Allow IndirectFieldDecl to appear in a non-type template argumentDavid Majnemer2013-10-221-1/+4
| | | | | | | | | | | We would not identify pointer-to-member construction in a non-type template argument if it was either a FieldDecl or a CXXMethodDecl. However, this would incorrectly reject declarations that were injected via an IndirectFieldDecl (e.g. a field inside of an anonymous union). This fixes PR17657. llvm-svn: 193203
* Sema: Do not allow template declarations inside local classesDavid Majnemer2013-10-221-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Enforce the rule in C++11 [temp.mem]p2 that local classes cannot have member templates. This fixes PR16947. N.B. C++14 has slightly different wording to afford generic lambdas declared inside of functions. Fun fact: Some formulations of local classes with member templates would cause clang to crash during Itanium mangling, such as the following: void outer_mem() { struct Inner { template <typename = void> struct InnerTemplateClass { static void itc_mem() {} }; }; Inner::InnerTemplateClass<>::itc_mem(); } Reviewers: eli.friedman, rsmith, doug.gregor, faisalv Reviewed By: doug.gregor CC: cfe-commits, ygao Differential Revision: http://llvm-reviews.chandlerc.com/D1866 llvm-svn: 193144
* Convert anachronistic use of 'void *' to 'DeclContext *' in Scope that was a ↵Ted Kremenek2013-10-081-1/+1
| | | | | | holdover from the long-dead Action interface. llvm-svn: 192203
* Make InstantiatingTemplate depth checks clearerAlp Toker2013-10-081-11/+10
| | | | | | | | | | 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
* Fix a bug where we failed to diagnose class template specializationChandler Carruth2013-09-271-0/+3
| | | | | | | | | uses. This fixes one of the two remaining failures to implement [[deprecated]] as specified for C++14. llvm-svn: 191572
* Variable templates: handle instantiation of static data member templatesRichard Smith2013-09-271-7/+2
| | | | | | appropriately, especially when they appear within class templates. llvm-svn: 191548
* Implement restriction that a partial specialization must actually specializeRichard Smith2013-09-241-3/+82
| | | | | | something, for variable templates. llvm-svn: 191278
* Remove some dead code.Richard Smith2013-09-181-6/+3
| | | | llvm-svn: 190959
* Fix accepts-invalid if a variable template explicit instantiation is missing anRichard Smith2013-09-181-9/+19
| | | | | | argument list, but could be instantiated with argument list of <>. llvm-svn: 190913
* getMostSpecialized for function template sets is never used in the context of aRichard Smith2013-09-101-2/+2
| | | | | | | call; remove its 'number of explicit arguments' and 'what kind of call' parameters. llvm-svn: 190444
* Ignore noreturn when checking function template specializationsReid Kleckner2013-09-101-2/+5
| | | | | | | | | | As requested when applying the same logic to calling conventions. Reviewers: rsmith Differential Revision: http://llvm-reviews.chandlerc.com/D1634 llvm-svn: 190441
* Ignore calling conventions when checking function template specializationsReid Kleckner2013-09-101-3/+13
| | | | | | | | | | | | | | | | | | | | Summary: Calling conventions are inherited during decl merging. Before this change, deduction would fail due to a type mismatch between the template and the specialization. This change adjusts the CCs to match before deduction, and lets the decl merging logic diagnose mismatch or inherit the CC from the template. This allows specializations of static member function templates in the Microsoft C++ ABI. Reviewers: rsmith CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1570 llvm-svn: 190377
* Simplify. This function bails out a few lines above if !Found.empty().Richard Smith2013-09-031-1/+1
| | | | llvm-svn: 189857
* Sema: Subst type default template args earlierDavid Majnemer2013-08-281-32/+41
| | | | | | | | | | | | | | | | | Summary: We would not perform substitution at an appropriate point, allowing strange results to appear. We would accepts things that we shouldn't or mangle things incorrectly. Note that this hasn't fixed the other cases like template-template parameters or non-type template parameters. Reviewers: doug.gregor, rjmccall, rsmith Reviewed By: rsmith CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1507 llvm-svn: 189540
* Cleanup of OpaquePtr. No functionality changes.Serge Pavlov2013-08-271-4/+4
| | | | | | | | - Some documenation were added. - Usages of OpaquePtr<A>.getAsVal<A>() were replaced by OpaquePtr<A>.get(). - Methods getAs and getAsVal were renamed to getPtrTo and getPtrAs respectively. llvm-svn: 189346
* A clean-up pass, exploring the unification of traversals of class, variable ↵Larisse Voufo2013-08-231-3/+4
| | | | | | and function templates. llvm-svn: 189152
* Use pop_back_val() instead of both back() and pop_back().Robert Wilhelm2013-08-231-2/+1
| | | | | | No functionality change intended. llvm-svn: 189112
* Sema: Properly support Microsoft-mode template argumentsDavid Majnemer2013-08-231-95/+148
| | | | | | | | | | | | | | | | | | | | | | | | Summary: There were two things known to be wrong with our implementation of MSVC mode template arguments: - We didn't properly handle __uuidof/CXXUuidofExpr and skipped all type checking completely. - We didn't allow for MSVC's extension of allowing certain constant "foldable" expressions from showing up in template arguments. They allow various casts dereference and address-of operations. We can make it more general as we find further peculiarities but this is the known extent. Reviewers: rsmith, doug.gregor, rjmccall Reviewed By: doug.gregor CC: cfe-commits, rnk Differential Revision: http://llvm-reviews.chandlerc.com/D1444 llvm-svn: 189087
* Remove SequenceNumber from class/variable template partial specializations.Richard Smith2013-08-221-8/+2
| | | | | | | | This was only used to ensure that the traversal order was the same as the insertion order, but that guarantee was already being provided by the use of a FoldingSetVector. llvm-svn: 189075
* Improve support for static data member templates. This revision still has at ↵Larisse Voufo2013-08-221-1/+4
| | | | | | least one bug, as it does not respect the variable template specialization hierarchy well. llvm-svn: 188969
* Sema: Remove dead code in CheckTemplateArgumentAddressOfObjectOrFunctionDavid Majnemer2013-08-191-8/+0
| | | | | | | | | | | | | | | | Summary: DeclRefExpr::getDecl gives us back a ValueDecl, this isa<> check will never fire. Reviewers: eli.friedman, doug.gregor, majnemer Reviewed By: majnemer CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1434 llvm-svn: 188647
* Refactor all diagnosing of TypoCorrections through a common function, inRichard Smith2013-08-171-14/+6
| | | | | | | preparation for teaching this function how to diagnose a correction that includes importing a module. llvm-svn: 188602
* Bug fix: disallow a variable template to be redeclared as a non-templated ↵Larisse Voufo2013-08-141-33/+0
| | | | | | variable llvm-svn: 188350
* Implement [class.friend]p11's special name lookup rules for friend declarationsRichard Smith2013-08-091-2/+2
| | | | | | | | of local classes. We were previously handling this by performing qualified lookup within a function declaration(!!); replace it with the proper scope lookup. llvm-svn: 188050
* PR9992: Serialize and deserialize the token sequence for a function template inRichard Smith2013-08-071-3/+18
| | | | | | -fdelayed-template-parsing mode. Patch by Will Wilson! llvm-svn: 187916
* A bit of clean up based on peer's feedback...Larisse Voufo2013-08-061-5/+5
| | | | llvm-svn: 187784
* Started implementing variable templates. Top level declarations should be ↵Larisse Voufo2013-08-061-61/+584
| | | | | | fully supported, up to some limitations documented as FIXMEs or TODO. Static data member templates work very partially. Static data member templates of class templates need particular attention... llvm-svn: 187762
* PR16288: A template is only missing a default template argument if it providesRichard Smith2013-07-221-4/+1
| | | | | | any default template arguments, not if it inherits some. llvm-svn: 186804
* SemaTemplate.cpp: Prune a stray "\param NumParamLists" in comment. ↵NAKAMURA Takumi2013-07-221-2/+0
| | | | | | [-Wdocumentation] llvm-svn: 186802
* Convert Sema::MatchTemplateParametersToScopeSpecifier to ArrayRef.Robert Wilhelm2013-07-211-36/+25
| | | | llvm-svn: 186794
* FIXME fix: improving diagnostics for template arguments deduction of class ↵Larisse Voufo2013-07-191-22/+29
| | | | | | | | 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-29/+22
| | | | | | | | 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-22/+29
| | | | | | bad template argument deductions. llvm-svn: 186727
* Reinstate r186040, with additional fixes and more test coverage (reverted inRichard Smith2013-07-171-2/+1
| | | | | | | | | | | | | r186331). Original commit log: If we friend a declaration twice, that should not make it visible to name lookup in the surrounding context. Slightly rework how we handle friend declarations to inherit the visibility of the prior declaration, rather than setting a friend declaration to be visible whenever there was a prior declaration. llvm-svn: 186546
* Re-revert r86040, which was un-reverted in r186199.Chandler Carruth2013-07-151-1/+2
| | | | | | | | | | | | | | | This breaks the build of basic patterns with repeated friend declarations. See the added test case in SemaCXX/friend.cpp or the test case reported to the original commit log. Original commit log: If we friend a declaration twice, that should not make it visible to name lookup in the surrounding context. Slightly rework how we handle friend declarations to inherit the visibility of the prior declaration, rather than setting a friend declaration to be visible whenever there was a prior declaration. llvm-svn: 186331
* Unrevert r186040, reverted in r186185, with fix for PR16597.Richard Smith2013-07-121-2/+1
| | | | | | | | | | | Original commit log: If we friend a declaration twice, that should not make it visible to name lookup in the surrounding context. Slightly rework how we handle friend declarations to inherit the visibility of the prior declaration, rather than setting a friend declaration to be visible whenever there was a prior declaration. llvm-svn: 186199
* Revert r186040 to fix PR16597 while Richard investigates what the bestChandler Carruth2013-07-121-1/+2
| | | | | | | | | | | | | fix is. Original commit log: If we friend a declaration twice, that should not make it visible to name lookup in the surrounding context. Slightly rework how we handle friend declarations to inherit the visibility of the prior declaration, rather than setting a friend declaration to be visible whenever there was a prior declaration. llvm-svn: 186185
* If we friend a declaration twice, that should not make it visible to nameRichard Smith2013-07-101-2/+1
| | | | | | | | | lookup in the surrounding context. Slightly rework how we handle friend declarations to inherit the visibility of the prior declaration, rather than setting a friend declaration to be visible whenever there was a prior declaration. llvm-svn: 186040
* Part of PR15673: If a function template has a default argument in whichRichard Smith2013-07-041-3/+9
| | | | | | | | | 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
* Allow typo correction to try removing nested name specifiers.Kaelyn Uhrain2013-07-021-3/+7
| | | | | | | | | | | | | | | | | The removal is tried by retrying the failed lookup of a correction candidate with either the MemberContext or SS (CXXScopeSpecifier) or both set to NULL if they weren't already. If the candidate identifier is then looked up successfully, make a note in the candidate that the SourceRange should include any existing nested name specifier even if the candidate isn't adding a different one (i.e. the candidate has a NULL NestedNameSpecifier). Also tweak the diagnostic messages to differentiate between a suggestion that just replaces the identifer but leaves the existing nested name specifier intact and one that replaces the entire qualified identifier, in cases where the suggested replacement is unqualified. llvm-svn: 185487
* Remove unnecessary check.Eli Friedman2013-06-271-1/+1
| | | | llvm-svn: 185108
* PR8302: Check for shadowing a template parameter when declaring a templateRichard Smith2013-06-251-23/+19
| | | | | | template parameter. llvm-svn: 184884
* Implement DR21David Majnemer2013-06-251-7/+9
| | | | | | | | | | A default template-argument shall not be specified in a friend template declaration. Interestingly, we properly handled default template arguments on friend class members but not on just friend classes. llvm-svn: 184882
* Fix assert if an attempt is made to explicitly instantiate an alias template.Richard Smith2013-06-221-3/+11
| | | | | | Patch by Ismail Pazarbasi! llvm-svn: 184650
* Use FPT::getArgTypes() instead of manually building ArrayRefsReid Kleckner2013-06-101-3/+1
| | | | | | | | Made significantly easier with git-clang-format. Differential Revision: http://llvm-reviews.chandlerc.com/D947 llvm-svn: 183694
* PR16273: Weaken a bogus assertion.Richard Smith2013-06-071-1/+2
| | | | llvm-svn: 183550
OpenPOWER on IntegriCloud