summaryrefslogtreecommitdiffstats
path: root/clang/test/Modules/cxx-templates.cpp
Commit message (Collapse)AuthorAgeFilesLines
* PR38627: Fix handling of exception specification adjustment forRichard Smith2018-09-051-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | destructors. We previously tried to patch up the exception specification after completing the class, which went wrong when the exception specification was needed within the class body (in particular, by a friend redeclaration of the destructor in a nested class). We now mark the destructor as having a not-yet-computed exception specification immediately after creating it. This requires delaying various checks against the exception specification (where we'd previously have just got the wrong exception specification, and now find we have an exception specification that we can't compute yet) when those checks fire while the class is being defined. This also exposed an issue that we were missing a CodeSynthesisContext for computation of exception specifications (otherwise we'd fail to make the module containing the definition of the class visible when computing its members' exception specs). Adding that incidentally also gives us a diagnostic quality improvement. This has also exposed an pre-existing problem: making the exception specification evaluation context a non-SFINAE context (as it should be) results in a bootstrap failure; PR38850 filed for this. llvm-svn: 341499
* Extend -ast-dump for CXXRecordDecl to dump the flags from the DefinitionData.Richard Smith2017-09-221-0/+14
| | | | llvm-svn: 313943
* PR32185: Revert r291512 and add a testcase for PR32185.Richard Smith2017-04-131-2/+8
| | | | | | | | | | | | | | | This reverts an attempt to check that types match when matching a dependently-typed non-type template parameter. (This comes up when matching the parameters of a template template parameter against the parameters of a template template argument.) The matching rules here are murky at best. Our behavior after this revert is definitely wrong for certain C++17 features (for 'auto' template parameter types within the parameter list of a template template argument in particular), but our behavior before this revert is wrong for some pre-existing testcases, so reverting to our prior behavior seems like our best option. llvm-svn: 300262
* Check that template template arguments match template template parametersRichard Smith2017-01-091-8/+2
| | | | | | | | | | | | | | | properly even when a non-type template parameter has a dependent type. Previously, if a non-type template parameter was dependent, but not dependent on an outer level of template parameter, we would not match the type of the parameter. Under [temp.arg.template], we are supposed to check that the types are equivalent, which means checking for syntactic equivalence in the dependent case. This also fixes some accepts-invalids when passing templates with auto-typed non-type template parameters as template template arguments. llvm-svn: 291512
* When producing a name of a partial specialization in a diagnostic, use theRichard Smith2016-12-241-8/+8
| | | | | | | template arguments as written rather than the canonical template arguments, so we print more user-friendly names for template parameters. llvm-svn: 290483
* [modules] Be sure to emit local specializations of imported templates, even ifRichard Smith2016-10-061-4/+4
| | | | | | | | | | | the resulting specialization is not referenced by the rest of the AST. This both avoids performing unnecessary reinstantiations in downstream users of the AST file and fixes a bug (breaking modules self-host right now) where we would sometimes fail to emit a definition of a class template specialization if we imported just a declaration of it from elsewhere (see new testcase for reduced example). llvm-svn: 283489
* Redirect unused output in test to /dev/nullRichard Trieu2016-06-091-3/+3
| | | | | | | Discard unused output so when the test fails, it only prints information that is helpful about the failure. No functional change. llvm-svn: 272325
* [modules] Enforce the rules that an explicit or partial specialization must beRichard Smith2016-05-051-6/+64
| | | | | | | | declared before it is used. Because we don't use normal name lookup to find these, the normal code to filter out non-visible names from name lookup results does not apply. llvm-svn: 268585
* [modules] Don't try to use the definition of a class ifRichard Smith2015-12-181-2/+2
| | | | | | | RequireCompleteType(..., 0) says we're not permitted to do so. The definition might not be visible, even though we know what it is. llvm-svn: 256045
* Re-commit r246497 (and dependent changes r246524 and r246521), reverted inRichard Smith2015-09-011-2/+6
| | | | | | | | | | | | | | | | | | | r246546, with a workaround for an MSVC 2013 miscompile and an MSVC 2015 rejects-valid. Original commit message: [modules] Rework serialized DeclContext lookup table management. Instead of walking the loaded ModuleFiles looking for lookup tables for the context, store them all in one place, and merge them together if we find we have too many (currently, more than 4). If we do merge, include the merged form in our serialized lookup table, so that downstream readers never need to look at our imports' tables. This gives a huge performance improvement to builds with very large numbers of modules (in some cases, more than a 2x speedup was observed). llvm-svn: 246582
* Reverting r246497 (which requires also reverting r246524 and r246521 to ↵Aaron Ballman2015-09-011-6/+2
| | | | | | | | | | | avoid merge conflicts). It broke the build on MSVC 2015. It also broke an MSVC 2013 bot with testing issues. llvm\tools\clang\lib\serialization\MultiOnDiskHashTable.h(117): error C2065: 'Files': undeclared identifier http://bb.pgr.jp/builders/ninja-clang-i686-msc18-R/builds/2917 llvm-svn: 246546
* [modules] Preserve DeclID order when merging lookup tables to give a moreRichard Smith2015-09-011-3/+3
| | | | | | | | predictable diagnostic experience. The hash-of-DeclID order we were using before gave different results on Win32 due to a different predefined declaration of __builtin_va_list. llvm-svn: 246521
* [modules] Rework serialized DeclContext lookup table management. Instead ofRichard Smith2015-08-311-2/+6
| | | | | | | | | | | | | walking the loaded ModuleFiles looking for lookup tables for the context, store them all in one place, and merge them together if we find we have too many (currently, more than 4). If we do merge, include the merged form in our serialized lookup table, so that downstream readers never need to look at our imports' tables. This gives a huge performance improvement to builds with very large numbers of modules (in some cases, more than a 2x speedup was observed). llvm-svn: 246497
* [modules] Rearrange how redeclaration chains are loaded, to remove a walk overRichard Smith2015-08-221-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | all modules and reduce the number of declarations we load when loading a redeclaration chain. The new approach is: * when loading the first declaration of an entity within a module file, we first load all declarations of the entity that were imported into that module file, and then load all the other declarations of that entity from that module file and build a suitable decl chain from them * when loading any other declaration of an entity, we first load the first declaration from the same module file As before, we complete redecl chains through name lookup where necessary. To make this work, I also had to change the way that template specializations are stored -- it no longer suffices to track only canonical specializations; we now emit all "first local" declarations when emitting a list of specializations for a template. On one testcase with several thousand imported module files, this reduces the total runtime by 72%. llvm-svn: 245779
* [modules] Simplify -cc1 interface for enabling implicit module maps.Richard Smith2015-06-161-5/+5
| | | | | | | | | | | | | We used to have a flag to enable module maps, and two more flags to enable implicit module maps. This is all redundant; we don't need any flag for enabling module maps in the abstract, and we don't usually have -fno- flags for -cc1. We now have just a single flag, -fimplicit-module-maps, that enables implicitly searching the file system for module map files and loading them. The driver interface is unchanged for now. We should probably rename -fmodule-maps to -fimplicit-module-maps at some point. llvm-svn: 239789
* [modules] When merging class definitions, make the retained definition visibleRichard Smith2015-03-271-4/+1
| | | | | | | | if the merged definition is visible, and perform lookups into all merged copies of the definition (not just for special members) so that we can complete the redecl chains for members of the class. llvm-svn: 233420
* [modules] Remove redundant import of lexical decls when building a lookup tableRichard Smith2015-03-231-5/+5
| | | | | | | | | | | | | | | for a DeclContext, and fix propagation of exception specifications along redeclaration chains. This reverts r232905, r232907, and r232907, which reverted r232793, r232853, and r232853. One additional change is present here to resolve issues with LLDB: distinguish between whether lexical decls missing from the lookup table are local or are provided by the external AST source, and still look in the external source if that's where they came from. llvm-svn: 232928
* Reverting r232793 until some new LLDB failures are discussedVince Harron2015-03-221-5/+5
| | | | llvm-svn: 232905
* [modules] Remove some redundant work when building a lookup table for a ↵Richard Smith2015-03-201-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | DeclContext. When we need to build the lookup table for a DeclContext, we used to pull in all lexical declarations for the context; instead, just build a lookup table for the local lexical declarations. We previously didn't guarantee that the imported declarations would be in the returned map, but in some cases we'd happen to put them all in there regardless. Now we're even lazier about this. This unnecessary work was papering over some other bugs: - LookupVisibleDecls would use the DC for name lookups in the TU in C, and this was not guaranteed to find all imported names (generally, the DC for the TU in C is not a reliable place to perform lookups). We now use an identifier-based lookup mechanism for this. - We didn't actually load in the list of eagerly-deserialized declarations when importing a module (so external definitions in a module wouldn't be emitted by users of those modules unless they happened to be deserialized by the user of the module). llvm-svn: 232793
* [modules] When collecting declarations to complete a redeclaration chain for anRichard Smith2015-02-121-4/+4
| | | | | | | | | | entity, put the originally-canonical decl IDs in the right places in the redecl chain rather than reordering them all to the start. If we don't ensure that the redecl chain order is consistent with the topological module order, we can fail to make a declaration visible if later declarations are in more IDNSs than earlier ones (for instance, because the earlier decls are invisible friends). llvm-svn: 228978
* [modules] If a module declares an entity and then imports another declarationRichard Smith2015-02-061-6/+0
| | | | | | | | | of that entity, ensure that the redeclaration chain is reordered properly on reload. Otherwise, the result of name lookup for that entity may point to an entity that is too old; if that's an injected friend name or the like, that can result in the name not being found at all. llvm-svn: 228371
* [modules] When building an injected-class-name type, we may have to insert itRichard Smith2014-10-211-0/+4
| | | | | | into multiple merged classes' TypeForDecl slots. llvm-svn: 220331
* [modules] When instantiating a class member, don't expect to find the previousRichard Smith2014-10-111-0/+3
| | | | | | | declaration in the instantiation if the previous declaration came from another definition of the class template that got merged into the pattern definition. llvm-svn: 219552
* [modules] Delay loading the field declared with an anonymous tag declarationRichard Smith2014-10-101-0/+2
| | | | | | until after we've had a chance to merge that tag. llvm-svn: 219539
* [modules] When completing the redecl chain for an anonymous declaration in aRichard Smith2014-08-281-2/+5
| | | | | | | merged context, pull in the lexical decls in that context, since one of them may complete the redecl chain. llvm-svn: 216652
* [modules] Number anonymous declarations that are lexically within mergeableRichard Smith2014-08-281-0/+5
| | | | | | contexts, so that we can merge them when we merge the surrounding context. llvm-svn: 216639
* [modules] Track the described template in an alias declaration that is theRichard Smith2014-08-261-0/+2
| | | | | | | pattern of an alias template declaration. Use this to merge alias templates properly when they're members of class template specializations. llvm-svn: 216437
* [modules] Put class template declarations into the scope in which they'reRichard Smith2014-08-231-0/+16
| | | | | | | | | | | 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
* [modules] When we merge together multiple class template specializationRichard Smith2014-08-141-0/+2
| | | | | | | | | | definitions (because some other declaration declares a special member that isn't present in the canonical definition), we need to search *all* of them; we can't just stop when we find the requested name in any of the definitions, because that can fail to find things (and in particular, it can fail to find the member of the canonical declaration and return a bogus ODR failure). llvm-svn: 215612
* [modules] When performing a lookup into a namespace, ensure that any laterRichard Smith2014-08-131-2/+2
| | | | | | | | | | redefinitions of that namespace have already been loaded. When writing out the names in a namespace, if we see a name that is locally declared and had imported declarations merged on top of it, export the local declaration as the lookup result, because it will be the most recent declaration of that entity in the redeclaration chain of an importer of the module. llvm-svn: 215518
* Modify behavior of -ast-dump-lookups: if -ast-dump is not also provided, dumpRichard Smith2014-08-111-2/+2
| | | | | | | | anyway. If -ast-dump *is* also provided, then dump the AST declarations as well as the lookup results. This is invaluable for cross-correlating the lookup information with the declarations actually found. llvm-svn: 215393
* [modules] Add testcase for a bug reduced from a selfhost issue. This bug wasRichard Smith2014-07-291-0/+1
| | | | | | | never present in Clang trunk, but was present in some of my development work, and it seems like a useful test to have. llvm-svn: 214154
* Revert accidentally-committed files in r214151.Richard Smith2014-07-291-1/+0
| | | | llvm-svn: 214152
* [modules] Add missing #include, found by modules build. We need a classRichard Smith2014-07-291-0/+1
| | | | | | definition in order to apply isa<...>. llvm-svn: 214151
* [modules] When merging a class template, also merge the definition of its ↵Richard Smith2014-07-111-0/+3
| | | | | | pattern. llvm-svn: 212836
* [modules] Don't try to merge template specializations by performing name lookupRichard Smith2014-07-111-0/+3
| | | | | | | | | into their container; we won't find them there. These things are already being merged when they're added to their primary template's folding set, so this merging is redundant (and causes us to reject-valid because we think we've found an odr violation). llvm-svn: 212788
* [modules] If a referenced-but-not-instantiated class template specializationRichard Smith2014-05-231-0/+1
| | | | | | | | | | gets explicitly specialized, don't reuse the previous class template specialization declaration as a new declaration. The benefit here is fairly marginal, it harms source fidelity, and this is horrible to model if the specialization was imported from another module (without this change, it asserts or worse). llvm-svn: 209552
* If a class template specialization from one module has its definitionRichard Smith2014-05-221-0/+2
| | | | | | | | | instantiated in another module, and the instantiation uses a partial specialization, include the partial specialization and its template arguments in the update record. We'll need them if someone imports the second module and tries to instantiate a member of the template. llvm-svn: 209472
* If an instantiation of a template is required to be a complete type, checkRichard Smith2014-05-071-5/+18
| | | | | | | whether the definition of the template is visible rather than checking whether the instantiated definition happens to be in an imported module. llvm-svn: 208150
* When two templates get merged together, also merge their pattern declarationsRichard Smith2014-04-241-10/+2
| | | | | | | | | | | | | | together. This is extremely hairy, because in general we need to have loaded both the template and the pattern before we can determine whether either should be merged, so we temporarily violate the rule that all merging happens before reading a decl ends, but *only* in the case where a template's pattern is being loaded while loading the template itself. In order to accomodate this for class templates, delay loading the injected class name type for the pattern of the template until after we've loaded the template itself, if we happen to load the template first. llvm-svn: 207063
* Add the location of Decls to ast dump.David Blaikie2014-04-021-1/+1
| | | | | | | | | While investigating some debug info issues, Eric and I came across a particular template case where the location of a decl was quite different from the range of the same decl. It might've been rather helpful if the dumper had actually showed us this. llvm-svn: 205396
* Save out a correct lookup table if a lookup table entry is stale (it containsRichard Smith2014-03-251-0/+8
| | | | | | | | | an out-of-date external decls list). This happens if we declare some names, force the lookup table for the decl context to be built, import a module that adds more decls for the name, then write out our module without looking up the name. llvm-svn: 204694
* When we inject a declaration into a namespace, add the primary DeclContext toRichard Smith2014-03-231-0/+5
| | | | | | | the update set rather than the current DeclContext. Add test for the local extern case too. llvm-svn: 204568
* If a template instantation introduces a name into a namespace, we need to writeRichard Smith2014-03-231-0/+4
| | | | | | | out a visible update record for that namespace even if it was never declared in this module. llvm-svn: 204554
* clang/test/Modules/cxx-templates.cpp: Tweak for dos path.NAKAMURA Takumi2014-03-181-1/+1
| | | | llvm-svn: 204116
* AST dumper: if we have multiple implicit instantiations of the same classRichard Smith2014-03-181-0/+11
| | | | | | | template specialization (from different modules), dump them all, so that every declaration is dumped somewhere. llvm-svn: 204100
* Test that we can merge together explicit and partial specializations fromRichard Smith2013-10-151-0/+8
| | | | | | merged declarations of a class template. llvm-svn: 192746
* C++ modules: merging for enumerations and enumerators with multiple definitionsRichard Smith2013-10-151-0/+16
| | | | | | (eg through template instantiations in multiple modules). llvm-svn: 192740
* Merge common pointers for redeclarations of the same template across modules.Richard Smith2013-10-131-0/+2
| | | | llvm-svn: 192560
* C++ modules: if a class is defined in multiple modules (for instance, becauseRichard Smith2013-09-091-0/+8
| | | | | | | | | | | | it is an implicit instantiation of a class template specialization), pick the first-loaded definition to be the canonical definition, and merge all other definitions into it. This is still rather incomplete -- we need to extend every form of declaration that can appear within a CXXRecordDecl to be redeclarable if it came from an AST file (this includes fields, enumerators, ...). llvm-svn: 190315
OpenPOWER on IntegriCloud