r241207 - [modules] Merging support for specializations of a function template. This very
Richard Smith
richard-llvm at metafoo.co.uk
Wed Jul 1 16:19:58 PDT 2015
Author: rsmith
Date: Wed Jul 1 18:19:58 2015
New Revision: 241207
URL: http://llvm.org/viewvc/llvm-project?rev=241207&view=rev
Log:
[modules] Merging support for specializations of a function template. This very
rarely matters, but can affect whether two dependent types are canonically
equivalent.
Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/test/Modules/Inputs/submodules-merge-defs/defs.h
cfe/trunk/test/Modules/submodules-merge-defs.cpp
Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=241207&r1=241206&r2=241207&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Wed Jul 1 18:19:58 2015
@@ -810,14 +810,14 @@ void ASTDeclReader::VisitFunctionDecl(Fu
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(Fu
FD->setDependentTemplateSpecialization(Reader.getContext(),
TemplDecls, TemplArgs);
-
- // FIXME: Merging.
+ // These are not merged; we don't need to merge redeclarations of dependent
+ // template friends.
break;
}
}
Modified: cfe/trunk/test/Modules/Inputs/submodules-merge-defs/defs.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/submodules-merge-defs/defs.h?rev=241207&r1=241206&r2=241207&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/submodules-merge-defs/defs.h (original)
+++ cfe/trunk/test/Modules/Inputs/submodules-merge-defs/defs.h Wed Jul 1 18:19:58 2015
@@ -86,3 +86,11 @@ namespace SeparateInline {
namespace TrailingAttributes {
template<typename T> struct X {} __attribute__((aligned(8)));
}
+
+namespace MergeFunctionTemplateSpecializations {
+ template<typename T> T f();
+ template<typename T> struct X {
+ template<typename U> using Q = decltype(f<T>() + U());
+ };
+ using xiq = X<int>::Q<int>;
+}
Modified: cfe/trunk/test/Modules/submodules-merge-defs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/submodules-merge-defs.cpp?rev=241207&r1=241206&r2=241207&view=diff
==============================================================================
--- cfe/trunk/test/Modules/submodules-merge-defs.cpp (original)
+++ cfe/trunk/test/Modules/submodules-merge-defs.cpp Wed Jul 1 18:19:58 2015
@@ -100,6 +100,8 @@ J<> post_j2;
FriendDefArg::Y<int> friend_def_arg;
FriendDefArg::D<> friend_def_arg_d;
+MergeFunctionTemplateSpecializations::X<int>::Q<char> xiqc;
+
#ifdef TEXTUAL
#include "use-defs.h"
void use_static_inline() { StaticInline::g({}); }
More information about the cfe-commits
mailing list