From: Richard Smith Date: Wed, 1 Jul 2015 23:19:58 +0000 (+0000) Subject: [modules] Merging support for specializations of a function template. This very X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4107de1e702486e7f06c9622b2343ccfa4d0661a;p=clang [modules] Merging support for specializations of a function template. This very rarely matters, but can affect whether two dependent types are canonically equivalent. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241207 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp index c89140dcaf..b23c33c551 100644 --- a/lib/Serialization/ASTReaderDecl.cpp +++ b/lib/Serialization/ASTReaderDecl.cpp @@ -810,14 +810,14 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) { FunctionTemplateSpecializationInfo::Profile(ID, TemplArgs, C); void *InsertPos = nullptr; FunctionTemplateDecl::Common *CommonPtr = CanonTemplate->getCommonPtr(); - CommonPtr->Specializations.FindNodeOrInsertPos(ID, InsertPos); + FunctionTemplateSpecializationInfo *ExistingInfo = + CommonPtr->Specializations.FindNodeOrInsertPos(ID, InsertPos); if (InsertPos) CommonPtr->Specializations.InsertNode(FTInfo, InsertPos); else { assert(Reader.getContext().getLangOpts().Modules && "already deserialized this template specialization"); - // FIXME: This specialization is a redeclaration of one from another - // module. Merge it. + mergeRedeclarable(FD, ExistingInfo->Function, Redecl); } } break; @@ -839,8 +839,8 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) { FD->setDependentTemplateSpecialization(Reader.getContext(), TemplDecls, TemplArgs); - - // FIXME: Merging. + // These are not merged; we don't need to merge redeclarations of dependent + // template friends. break; } } diff --git a/test/Modules/Inputs/submodules-merge-defs/defs.h b/test/Modules/Inputs/submodules-merge-defs/defs.h index bf720aaba3..bda0567c93 100644 --- a/test/Modules/Inputs/submodules-merge-defs/defs.h +++ b/test/Modules/Inputs/submodules-merge-defs/defs.h @@ -86,3 +86,11 @@ namespace SeparateInline { namespace TrailingAttributes { template struct X {} __attribute__((aligned(8))); } + +namespace MergeFunctionTemplateSpecializations { + template T f(); + template struct X { + template using Q = decltype(f() + U()); + }; + using xiq = X::Q; +} diff --git a/test/Modules/submodules-merge-defs.cpp b/test/Modules/submodules-merge-defs.cpp index 2e771c1562..92c784440b 100644 --- a/test/Modules/submodules-merge-defs.cpp +++ b/test/Modules/submodules-merge-defs.cpp @@ -100,6 +100,8 @@ J<> post_j2; FriendDefArg::Y friend_def_arg; FriendDefArg::D<> friend_def_arg_d; +MergeFunctionTemplateSpecializations::X::Q xiqc; + #ifdef TEXTUAL #include "use-defs.h" void use_static_inline() { StaticInline::g({}); }