[clang] [clang] Track function template instantiation from definition (PR #110387)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Sat Oct 5 18:46:36 PDT 2024
================
@@ -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();
+ });
----------------
zyn0217 wrote:
We'd better have an assertion here, ND shouldn't be a nullptr.
https://github.com/llvm/llvm-project/pull/110387
More information about the cfe-commits
mailing list