]> granicus.if.org Git - clang/commitdiff
[modules] Merging support for specializations of a function template. This very
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 1 Jul 2015 23:19:58 +0000 (23:19 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 1 Jul 2015 23:19:58 +0000 (23:19 +0000)
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

lib/Serialization/ASTReaderDecl.cpp
test/Modules/Inputs/submodules-merge-defs/defs.h
test/Modules/submodules-merge-defs.cpp

index c89140dcaf2484e1c667fb27031eada927c0ff12..b23c33c55188cf045347d445185f180f8b04f493 100644 (file)
@@ -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;
   }
   }
index bf720aaba330ad6b74dc93a77677e6061a5c0c7d..bda0567c93a38d55046ab857be191918e5655184 100644 (file)
@@ -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>;
+}
index 2e771c1562b1730f6066ea0276e55c848dd32d67..92c784440b9e4eb145a956d3de9975a02bde6465 100644 (file)
@@ -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({}); }