r192560 - Merge common pointers for redeclarations of the same template across modules.
Richard Smith
richard-llvm at metafoo.co.uk
Sun Oct 13 16:50:46 PDT 2013
Author: rsmith
Date: Sun Oct 13 18:50:45 2013
New Revision: 192560
URL: http://llvm.org/viewvc/llvm-project?rev=192560&view=rev
Log:
Merge common pointers for redeclarations of the same template across modules.
Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/test/Modules/Inputs/cxx-templates-a.h
cfe/trunk/test/Modules/Inputs/cxx-templates-b.h
cfe/trunk/test/Modules/cxx-templates.cpp
Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=192560&r1=192559&r2=192560&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Sun Oct 13 18:50:45 2013
@@ -1429,6 +1429,11 @@ ASTDeclReader::VisitRedeclarableTemplate
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;
}
Modified: cfe/trunk/test/Modules/Inputs/cxx-templates-a.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/cxx-templates-a.h?rev=192560&r1=192559&r2=192560&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/cxx-templates-a.h (original)
+++ cfe/trunk/test/Modules/Inputs/cxx-templates-a.h Sun Oct 13 18:50:45 2013
@@ -30,3 +30,6 @@ void use_some_template_a() {
SomeTemplate<char[1]> b, c;
b = c;
}
+
+template<int> struct MergeTemplates;
+MergeTemplates<0> *merge_templates_a;
Modified: cfe/trunk/test/Modules/Inputs/cxx-templates-b.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/cxx-templates-b.h?rev=192560&r1=192559&r2=192560&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/cxx-templates-b.h (original)
+++ cfe/trunk/test/Modules/Inputs/cxx-templates-b.h Sun Oct 13 18:50:45 2013
@@ -17,6 +17,9 @@ typedef SomeTemplate<int&> SomeTemplateI
extern DefinedInCommon &defined_in_common;
+template<int> struct MergeTemplates;
+MergeTemplates<0> *merge_templates_b;
+
@import cxx_templates_b_impl;
template<typename T, typename> struct Identity { typedef T type; };
Modified: cfe/trunk/test/Modules/cxx-templates.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/cxx-templates.cpp?rev=192560&r1=192559&r2=192560&view=diff
==============================================================================
--- cfe/trunk/test/Modules/cxx-templates.cpp (original)
+++ cfe/trunk/test/Modules/cxx-templates.cpp Sun Oct 13 18:50:45 2013
@@ -69,6 +69,8 @@ void g() {
// expected-error at Inputs/cxx-templates-a.h:19 {{definition of 'DefinedInBImpl' must be imported}}
// expected-note at 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<int> raf1;
More information about the cfe-commits
mailing list