summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplate.cpp
Commit message (Collapse)AuthorAgeFilesLines
* PR24921: checking explicitly-specified template arguments when matching aRichard Smith2015-10-021-6/+15
| | | | | | | partial specialization can perform conversions on the argument. Be sure we start again from the original argument when checking each possible template. llvm-svn: 249114
* Simplify logic introduced in r247464.David Majnemer2015-09-111-3/+3
| | | | llvm-svn: 247472
* [MS ABI] Select an inheritance model in template argumentsDavid Majnemer2015-09-111-3/+5
| | | | | | | | | | | | We used to only select an inheritance model if the pointer to member was nullptr. Instead, select a model regardless of the member pointer's value. N.B. This bug was exposed by making member pointers report true for isIncompleteType but has been latent since the member pointer scheme's inception. llvm-svn: 247464
* [sema] Fix assertion hit when using libclang to index a particular C++ ↵Argyrios Kyrtzidis2015-09-111-2/+7
| | | | | | | | snippet involving templates. Assertion hit was in ClassTemplateSpecializationDecl::getSourceRange(). llvm-svn: 247373
* [modules] When we see a definition of a function for which we already have aRichard Smith2015-08-211-18/+0
| | | | | | | non-visible definition, skip the new definition to avoid ending up with a function with multiple definitions. llvm-svn: 245664
* PR24483: Delete some dead/incorrect code that triggered assertions.Richard Smith2015-08-201-19/+0
| | | | llvm-svn: 245609
* [AST] ArrayRefize template param list info setters. No functionality change ↵Benjamin Kramer2015-08-051-8/+6
| | | | | | intended. llvm-svn: 244028
* [AST] ArrayRefize template argument packs. No functionality change intended.Benjamin Kramer2015-08-051-10/+6
| | | | llvm-svn: 244026
* Sema: Allow null names to be passed in to isAcceptableTagRedeclarationJustin Bogner2015-07-101-4/+4
| | | | | | | | | | | | | It's possible for TagRedeclarations to involve decls without a name, ie, anonymous enums. We hit some undefined behaviour if we bind these null names to the reference here. We never dereference the name, so it's harmless if it's null - make it a pointer to allow that. Fixes the Modules/submodules-merge-defs.cpp test under ubsan. llvm-svn: 241963
* PR24030, PR24033: Consistently check whether a new declaration conflicts withRichard Smith2015-07-061-3/+18
| | | | | | | | | | an existing using shadow declaration if they define entities of the same kind in different namespaces. We'd previously check this consistently if the using-declaration came after the other declaration, but not if it came before. llvm-svn: 241428
* DR1909: Diagnose all invalid cases of a class member sharing its name with ↵Richard Smith2015-07-061-0/+10
| | | | | | the class. llvm-svn: 241425
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-3/+3
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-3/+3
| | | | | | | | | | | | 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
* [modules] Improve diagnostic for a template-id that's invalid because a defaultRichard Smith2015-06-171-3/+35
| | | | | | argument is not visible. llvm-svn: 239934
* [modules] Don't allow use of non-visible (inherited) default template arguments.Richard Smith2015-06-101-6/+6
| | | | llvm-svn: 239487
* [modules] Track all default template arguments for a given parameter acrossRichard Smith2015-06-101-12/+5
| | | | | | | modules, and allow use of a default template argument if any of the parameters providing it is visible. llvm-svn: 239485
* Refactor storage of default template arguments.Richard Smith2015-06-101-16/+6
| | | | | | | This is just a preparatory step towards fixing visibility for default template arguments in modules builds. llvm-svn: 239447
* Enable DLL attribute propagation on explicit instantiation definitions (PR23770)Hans Wennborg2015-06-091-0/+7
| | | | | | | | This is a follow-up to r225570 which enabled adding DLL attributes when a class template goes from explicit instantiation declaration to explicit instantiation definition. llvm-svn: 239375
* MinGW: don't allow adding DLL attribute if template already has explicit ↵Hans Wennborg2015-06-091-1/+5
| | | | | | | | instantiation declaration This is a follow-up to r238266 which failed to take MinGW into account. llvm-svn: 239374
* clang-cl: Handle dll attributes in explicit class template specialization ↵Hans Wennborg2015-05-271-1/+10
| | | | | | | | | | definitions (PR23667) Previously, we wouldn't call checkDLLAttribute() after the class template specialization definition if the class template was already instantiated by an explicit class template specialization declaration. llvm-svn: 238266
* [modules] Support merging a parsed default argument with an imported hidden ↵Richard Smith2015-05-201-0/+4
| | | | | | one for non-type and template template parameters too. llvm-svn: 237815
* [modules] Support merging a parsed default function/template argument with ↵Richard Smith2015-05-201-0/+3
| | | | | | an imported but hidden one. llvm-svn: 237814
* [modules] Support for merging a parsed class template specialization ↵Richard Smith2015-05-181-2/+11
| | | | | | definition into an imported but hidden definition. llvm-svn: 237612
* [modules] Suport for merging a parsed enum definition into an existing ↵Richard Smith2015-05-071-9/+4
| | | | | | imported but not visible definition. llvm-svn: 236690
* [modules] Handle defining a class template on top of an existing ↵Richard Smith2015-03-271-1/+20
| | | | | | imported-but-not-visible definition. llvm-svn: 233341
* [Modules] Preserve source order for the map of late parsed templates.Chandler Carruth2015-03-261-1/+1
| | | | | | | | | | | | | | | | | | | | Clang was inserting these into a dense map. While it never iterated the dense map during normal compilation, it did when emitting a module. Fix this by using a standard MapVector to preserve the order in which we encounter the late parsed templates. I suspect this still isn't ideal, as we don't seem to remove things from this map even when we mark the templates as no longer late parsed. But I don't know enough about this particular extension to craft a nice, subtle test case covering this. I've managed to get the stress test to at least do some late parsing and demonstrate the core problem here. This patch fixes the test and provides deterministic behavior which is a strict improvement over the prior state. I've cleaned up some of the code here as well to be explicit about inserting when that is what is actually going on. llvm-svn: 233264
* [MSVC] Explicit specializations can be declared in any namespace (fix for ↵Alexey Bataev2015-03-201-5/+7
| | | | | | | | | | | | | | http://llvm.org/PR13738) MS compiler emits no errors in case of explicit specializations outside declaration enclosing namespaces, even when language extensions are disabled. The patch is to suppress errors and emit extension warnings if explicit specializations are not declared in the corresponding namespaces. This fixes PR13738. Patch by Alexey Frolov. Differential Revision: http://reviews.llvm.org/D8283 llvm-svn: 232800
* Wrap to 80 cols by removing trailing whitespace. No behavior change.Nico Weber2015-01-301-1/+1
| | | | llvm-svn: 227553
* When checking the template argument list, use a copy of that list for changesRichard Trieu2015-01-241-22/+34
| | | | | | | | | | | | | | | | | | | and only update the orginal list on a valid arugment list. When checking an individual expression template argument, and conversions are required, update the expression in the template argument. Since template arguments are speculatively checked, the copying of the template argument list prevents updating the template arguments when the list does not match the template. Additionally, clean up the integer checking code in the template diffing code. The code performs unneccessary conversions from APSInt to APInt. Fixes PR21758. This essentially reverts r224770 to recommits r224667 and r224668 with extra changes to prevent the template instantiation problems seen in PR22006. A test to catch the discovered problem is also added. llvm-svn: 226983
* Warn about dllexported explicit class template instantiation declarations ↵Hans Wennborg2015-01-151-3/+21
| | | | | | | | | | | | | | | (PR22035) Clang would previously become confused and crash here. It does not make a lot of sense to export these, so warning seems appropriate. MSVC will export some member functions for this kind of specializations, whereas MinGW ignores the dllexport-edness. The latter behaviour seems better. Differential Revision: http://reviews.llvm.org/D6984 llvm-svn: 226208
* This reverts commit r224668 and r224667.Rafael Espindola2014-12-231-7/+0
| | | | | | | | | | r224667 broke bootstrap on Fedora 20 X86_64 (at least). See pr22006 for the details. r224668 depends on r224667. llvm-svn: 224770
* Fix for PR21758Richard Trieu2014-12-201-0/+7
| | | | | | | | | When a non-type template argument expression needs a conversion to change it into the argument type, preserve that information by remaking the TemplateArgument with an expression that has those conversions. Also a small fix to template type diffing to handle the extra conversions in some cases. llvm-svn: 224667
* Don't drop attributes when checking explicit specializations.Nico Weber2014-12-191-6/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Consider a template class with attributes on a method, and an explicit specialization of that method: template <int> struct A { void foo() final; }; template <> void A<0>::foo() {} In this example, the attribute is `final`, but it might also be an __attribute__((visibility("foo"))), noreturn, inline, etc. clang's current behavior is to strip all attributes, which for some attributes is wrong (the snippet above allows a subclass of A<0> to override the final method, for example) and for others disagrees with gcc. So stop dropping attributes. r95845 added this code without a test case, and r176728 added the code for dropping attributes on parameters (with tests, but they still pass). As an additional wrinkle, do drop dllimport and dllexport, since that's how these two attributes work. (This is covered by existing tests.) Fixes PR21942. The approach is by Richard Smith, initial analysis and typing was done by me. With this, clang also matches GCC and EDG on all attributes Richard tested. llvm-svn: 224651
* Revert "Don't build invalid AST nodes during recovery"Reid Kleckner2014-12-181-1/+1
| | | | | | | | | | | This reverts commit r224451. It caused us to reject some valid existing code. This code appears to run in non-error cases as well as error cases. If the scope of a DependentScopeDeclRefExpr is still incomplete it probably means we still have more instantiation to do. llvm-svn: 224526
* [c++1z] Fixes for generalized non-type template argument support: check forRichard Smith2014-12-171-42/+45
| | | | | | | | exact type match for deduced template arguments, and be sure to produce correct canonical TemplateArgument representations to enable correct redeclaration matching. llvm-svn: 224456
* Don't build invalid AST nodes during recoveryReid Kleckner2014-12-171-1/+1
| | | | | | | | | | | | | | A DependentScopeDeclRefExpr should always have a nested name specifier. During template instantiation, if we found that the named context was incomplete, we would previously build a DependentScopeDeclRefExpr with an empty qualifier. This error recovery path has been asserting for some time. The other error codepaths use ExprError, so we can do the same. Fixes PR21864. llvm-svn: 224451
* Perform correct lookup when '__super' is used in class with dependent base.Nikola Smiljanic2014-12-011-5/+1
| | | | llvm-svn: 223090
* [c++1z] Most of N4268 (allow constant evaluation for non-type template ↵Richard Smith2014-11-261-1/+99
| | | | | | | | | arguments). We don't yet support pointer-to-member template arguments that have undergone pointer-to-member conversions, mostly because we don't have a mangling for them yet. llvm-svn: 222807
* 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
* PR19372: Keep checking template arguments after we see an argument packRichard Smith2014-11-121-28/+11
| | | | | | | | expansion into a parameter pack; we know that we're still filling in that parameter's arguments. Previously, if we hit this case for an alias template, we'd try to substitute using non-canonical template arguments. llvm-svn: 221832
* PR21536: Fix a corner case where we'd get confused by a pack expanding into theRichard Smith2014-11-121-1/+1
| | | | | | | penultimate parameter of a template parameter list, where the last parameter is itself a pack, and build a bogus empty final pack argument. llvm-svn: 221748
* Fix for exception specification mismatch in explicit instantiation.Alexey Bataev2014-11-061-0/+23
| | | | | | | According to C++ standard if an exception-specification is specified in an explicit instantiation directive, it shall be compatible with the exception-specifications of other declarations of that function. This patch adds checks for this. Differential Revision: http://reviews.llvm.org/D5822 llvm-svn: 221448
* Remove StorageClass typedefs from VarDecl and FunctionDecl since ↵Craig Topper2014-10-311-1/+1
| | | | | | StorageClass is in the clang namespace. llvm-svn: 220956
* Pass around CorrectionCandidateCallbacks as unique_ptrs soKaelyn Takata2014-10-271-9/+8
| | | | | | TypoCorrectionConsumer can keep the callback around as long as needed. llvm-svn: 220693
* PR21246: DebugInfo: Emit the appropriate type (cv qualifiers, ↵David Blaikie2014-10-161-4/+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
* -ms-extensions: Implement __super scope specifier (PR13236).Nikola Smiljanic2014-09-261-1/+6
| | | | | | | | | We build a NestedNameSpecifier that records the CXXRecordDecl in which __super appeared. Name lookup is performed in all base classes of the recorded CXXRecordDecl. Use of __super is allowed only inside class and member function scope. llvm-svn: 218484
* Add -Wunused-local-typedef, a warning that finds unused local typedefs.Nico Weber2014-09-061-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The warning warns on TypedefNameDecls -- typedefs and C++11 using aliases -- that are !isReferenced(). Since the isReferenced() bit on TypedefNameDecls wasn't used for anything before this warning it wasn't always set correctly, so this patch also adds a few missing MarkAnyDeclReferenced() calls in various places for TypedefNameDecls. This is made a bit complicated due to local typedefs possibly being used only after their local scope has closed. Consider: template <class T> void template_fun(T t) { typename T::Foo s3foo; // YYY (void)s3foo; } void template_fun_user() { struct Local { typedef int Foo; // XXX } p; template_fun(p); } Here the typedef in XXX is only used at end-of-translation unit, when YYY in template_fun() gets instantiated. To handle this, typedefs that are unused when their scope exits are added to a set of potentially unused typedefs, and that set gets checked at end-of-TU. Typedefs that are still unused at that point then get warned on. There's also serialization code for this set, so that the warning works with precompiled headers and modules. For modules, the warning is emitted when the module is built, for precompiled headers each time the header gets used. Finally, consider a function using C++14 auto return types to return a local type defined in a header: auto f() { struct S { typedef int a; }; return S(); } Here, the typedef escapes its local scope and could be used by only some translation units including the header. To not warn on this, add a RecursiveASTVisitor that marks all delcs on local types returned from auto functions as referenced. (Except if it's a function with internal linkage, or the decls are private and the local type has no friends -- in these cases, it _is_ safe to warn.) Several of the included testcases (most of the interesting ones) were provided by Richard Smith. (gcc's spelling -Wunused-local-typedefs is supported as an alias for this warning.) llvm-svn: 217298
* [modules] Put class template declarations into the scope in which they'reRichard Smith2014-08-231-3/+7
| | | | | | | | | | | declared, rather than putting them into the template parameter scope. We previously had *no record* in the scope for class template declarations, once those declarations completed and their template parameter scopes were popped. This in turn caused us to be unable to merge class template declarations that were declared in the global scope (where we use scope lookup rather than DeclContext lookup for merging), when loading a module. llvm-svn: 216311
* Sema: Permit nullptr template args in MSVC compat modeDavid Majnemer2014-08-141-1/+1
| | | | | | This fixes a regression I caused back in r211766. llvm-svn: 215609
* Take the canonical type when forming a canonical template argument withRichard Smith2014-07-241-3/+6
| | | | | | | 'nullptr' value. Fixes profiling of such template arguments to always give the same value. llvm-svn: 213834
OpenPOWER on IntegriCloud