================ @@ -2146,9 +2147,15 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl( FunctionDecl *SpecFunc = FunctionTemplate->findSpecialization(Innermost, InsertPos); - // If we already have a function template specialization, return it. - if (SpecFunc) - return SpecFunc; + if (SpecFunc) { + if (!SpecFunc->isTemplateInstantiation()) + return SpecFunc; + + for (auto *Redecl : SpecFunc->redecls()) + if (Redecl->getPrimaryTemplate() == FunctionTemplate) + return Redecl; + } + PrevFunc = SpecFunc; ---------------- zyn0217 wrote:
Let me rephrase the purpose here: So now clang instantiates a new function declaration as long as the previous instantiation doesn't exist / the previous instantiation has a distinct primary template declaration, right? I feel I struggle to understand the benefit here, though it might indeed have fixed/improved something. Can you explain it more? https://github.com/llvm/llvm-project/pull/110387 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits