================ @@ -5185,9 +5189,24 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, RebuildTypeSourceInfoForDefaultSpecialMembers(); SetDeclDefaulted(Function, PatternDecl->getLocation()); } else { + NamedDecl *ND = Function; + std::optional<ArrayRef<TemplateArgument>> Innermost; + if (auto *Primary = Function->getPrimaryTemplate(); + Primary && + !isGenericLambdaCallOperatorOrStaticInvokerSpecialization(Function)) { + ND = *llvm::find_if(Primary->redecls(), + [](const RedeclarableTemplateDecl *RTD) { + auto *FTD = cast<FunctionTemplateDecl>(RTD); + return FTD->isInstantiatedFromDefinition() || + FTD->isThisDeclarationADefinition(); + }); ---------------- mizvekov wrote:
We are finding one declaration within all the redeclarations of the primary template. The list of redeclarations can't have a null element in it. Otherwise, if you meant a null iterator, we shouldn't get here without a definition, as we should have diagnosed that before. We could perhaps add a null check for that. Is that what you meant? 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