Commit Graph

20 Commits

Author SHA1 Message Date
Richard Smith 01bdb7a971 [modules] When completing the redecl chain for an anonymous declaration in a
merged context, pull in the lexical decls in that context, since one of them
may complete the redecl chain.

llvm-svn: 216652
2014-08-28 05:44:07 +00:00
Richard Smith d08aeb6b57 [modules] Number anonymous declarations that are lexically within mergeable
contexts, so that we can merge them when we merge the surrounding context.

llvm-svn: 216639
2014-08-28 01:33:39 +00:00
Richard Smith 43ccec8e53 [modules] Track the described template in an alias declaration that is the
pattern of an alias template declaration. Use this to merge alias templates
properly when they're members of class template specializations.

llvm-svn: 216437
2014-08-26 03:52:16 +00:00
Richard Smith 72544f875b [modules] Don't assert if the same imported class template specialization
declaration has its definition instantiated in two sibling modules and they use
a partial specialization.

llvm-svn: 215616
2014-08-14 03:30:27 +00:00
Richard Smith 8c913ecd15 [modules] When we merge together multiple class template specialization
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
2014-08-14 02:21:01 +00:00
Richard Smith 049fcd8c64 [modules] Add testcase for a bug reduced from a selfhost issue. This bug was
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
2014-07-29 00:58:01 +00:00
Richard Smith 08b9515f45 Revert accidentally-committed files in r214151.
llvm-svn: 214152
2014-07-29 00:54:09 +00:00
Richard Smith 05ad411aa2 [modules] Add missing #include, found by modules build. We need a class
definition in order to apply isa<...>.

llvm-svn: 214151
2014-07-29 00:51:47 +00:00
Richard Smith f59b735a80 [modules] PR20475: merging support for alias template declarations.
llvm-svn: 214124
2014-07-28 21:16:37 +00:00
Richard Smith dc5523d38f [modules] Don't try to merge template specializations by performing name lookup
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
2014-07-11 00:20:06 +00:00
Richard Smith 561e0dce59 When we inject a declaration into a namespace, add the primary DeclContext to
the update set rather than the current DeclContext. Add test for the local
extern case too.

llvm-svn: 204568
2014-03-23 19:45:26 +00:00
Richard Smith 0c1065fa88 Test that we can merge together explicit and partial specializations from
merged declarations of a class template.

llvm-svn: 192746
2013-10-15 23:19:58 +00:00
Richard Smith 01a7337c6d C++ modules: merging for enumerations and enumerators with multiple definitions
(eg through template instantiations in multiple modules).

llvm-svn: 192740
2013-10-15 22:02:41 +00:00
Richard Smith d46d6dea68 Merge common pointers for redeclarations of the same template across modules.
llvm-svn: 192560
2013-10-13 23:50:45 +00:00
Richard Smith d55889a655 C++ modules: if a class is defined in multiple modules (for instance, because
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
2013-09-09 16:55:27 +00:00
Richard Smith 7ecc31b032 When merging redeclaration chains across modules, if a declaration is visible
in one module but is only declared as a friend in another module, keep it
visible in the result of the merge.

This is incomplete on two axes:

1) Our handling of local extern declarations is basically broken (we put them
in the wrong decl context, and don't find them in redeclaration lookup, unless
they've previously been declared), and this results in them making friends
visible after a merge.

2) Eventually we'll need to mark that this has happened, and more carefully
check whether a declaration should be visible if it was only visible in some
of the modules in which it was declared. Fortunately it's rare for the
identifier namespace of a declaration to change along its redeclaration chain.

llvm-svn: 187639
2013-08-02 01:09:12 +00:00
Richard Smith 0e5d7b8c6b When we perform dependent name lookup during template instantiation, it's not
sufficient to only consider names visible at the point of instantiation,
because that may not include names that were visible when the template was
defined. More generally, if the instantiation backtrace goes through a module
M, then every declaration visible within M should be available to the
instantiation. Any of those declarations might be part of the interface that M
intended to export to a template that it instantiates.

The fix here has two parts:

1) If we find a non-visible declaration during name lookup during template
instantiation, check whether the declaration was visible from the defining
module of all entities on the active template instantiation stack. The defining
module is not the owning module in all cases: we look at the module in which a
template was defined, not the module in which it was first instantiated.

2) Perform pending instantiations at the end of a module, not at the end of the
translation unit. This is general goodness, since it significantly cuts down
the amount of redundant work that is performed in every TU importing a module,
and also implicitly adds the module containing the point of instantiation to
the set of modules checked for declarations in a lookup within a template
instantiation.

There's a known issue here with template instantiations performed while
building a module, if additional imports are added later on. I'll fix that
in a subsequent commit.

llvm-svn: 187167
2013-07-25 23:08:39 +00:00
Richard Smith 5de91b58d0 Fix deserializing of class template partial specializations. Assign sequence
numbers as we deserialize class template partial specializations. We can't
assume that the old sequence numbers will work.

The sequence numbers are still deterministic, but are now a lot less
predictable for class template partial specializations in modules/PCH.

llvm-svn: 184811
2013-06-25 01:25:15 +00:00
Richard Smith bf78e646e1 Check for matching template-parameter-lists when merging template declarations.
llvm-svn: 184791
2013-06-24 22:51:00 +00:00
Richard Smith 8f8f05cf00 Slightly improve cross-module merging for function templates.
llvm-svn: 184689
2013-06-24 04:45:28 +00:00