From: Richard Smith Date: Sun, 13 Oct 2013 23:50:45 +0000 (+0000) Subject: Merge common pointers for redeclarations of the same template across modules. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8bfc1e118169229960b90a4ef8761ee0eb296755;p=clang Merge common pointers for redeclarations of the same template across modules. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192560 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp index 341f8eb068..2a1ac11ec0 100644 --- a/lib/Serialization/ASTReaderDecl.cpp +++ b/lib/Serialization/ASTReaderDecl.cpp @@ -1429,6 +1429,11 @@ ASTDeclReader::VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D) { mergeRedeclarable(D, Redecl); + // If we merged the template with a prior declaration chain, merge the common + // pointer. + // FIXME: Actually merge here, don't just overwrite. + D->Common = D->getCanonicalDecl()->Common; + return Redecl; } diff --git a/test/Modules/Inputs/cxx-templates-a.h b/test/Modules/Inputs/cxx-templates-a.h index 37e3426fc0..d2261f6a29 100644 --- a/test/Modules/Inputs/cxx-templates-a.h +++ b/test/Modules/Inputs/cxx-templates-a.h @@ -30,3 +30,6 @@ void use_some_template_a() { SomeTemplate b, c; b = c; } + +template struct MergeTemplates; +MergeTemplates<0> *merge_templates_a; diff --git a/test/Modules/Inputs/cxx-templates-b.h b/test/Modules/Inputs/cxx-templates-b.h index c495074a93..6cc951b0ee 100644 --- a/test/Modules/Inputs/cxx-templates-b.h +++ b/test/Modules/Inputs/cxx-templates-b.h @@ -17,6 +17,9 @@ typedef SomeTemplate SomeTemplateIntRef; extern DefinedInCommon &defined_in_common; +template struct MergeTemplates; +MergeTemplates<0> *merge_templates_b; + @import cxx_templates_b_impl; template struct Identity { typedef T type; }; diff --git a/test/Modules/cxx-templates.cpp b/test/Modules/cxx-templates.cpp index f34a2bdaa7..911f953a5c 100644 --- a/test/Modules/cxx-templates.cpp +++ b/test/Modules/cxx-templates.cpp @@ -69,6 +69,8 @@ void g() { // expected-error@Inputs/cxx-templates-a.h:19 {{definition of 'DefinedInBImpl' must be imported}} // expected-note@Inputs/cxx-templates-b-impl.h:1 {{definition is here}} PerformDelayedLookup(defined_in_b_impl); // expected-note {{in instantiation of}} + + merge_templates_a = merge_templates_b; // ok, same type } RedeclaredAsFriend raf1;