Skip to content

Commit 715406a

Browse files
committed
[Clang][Sema] Don't set instantiated from function when rewriting operator<=>
1 parent 77c5cea commit 715406a

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2269,16 +2269,18 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(
22692269
TemplateArgumentList::CreateCopy(SemaRef.Context,
22702270
Innermost),
22712271
/*InsertPos=*/nullptr);
2272-
} else if (isFriend && D->isThisDeclarationADefinition()) {
2273-
// Do not connect the friend to the template unless it's actually a
2274-
// definition. We don't want non-template functions to be marked as being
2275-
// template instantiations.
2276-
Function->setInstantiationOfMemberFunction(D, TSK_ImplicitInstantiation);
2277-
} else if (!isFriend) {
2278-
// If this is not a function template, and this is not a friend (that is,
2279-
// this is a locally declared function), save the instantiation relationship
2280-
// for the purposes of constraint instantiation.
2281-
Function->setInstantiatedFromDecl(D);
2272+
} else if (FunctionRewriteKind == RewriteKind::None) {
2273+
if (isFriend && D->isThisDeclarationADefinition()) {
2274+
// Do not connect the friend to the template unless it's actually a
2275+
// definition. We don't want non-template functions to be marked as being
2276+
// template instantiations.
2277+
Function->setInstantiationOfMemberFunction(D, TSK_ImplicitInstantiation);
2278+
} else if (!isFriend) {
2279+
// If this is not a function template, and this is not a friend (that is,
2280+
// this is a locally declared function), save the instantiation relationship
2281+
// for the purposes of constraint instantiation.
2282+
Function->setInstantiatedFromDecl(D);
2283+
}
22822284
}
22832285

22842286
if (isFriend) {
@@ -2669,7 +2671,7 @@ Decl *TemplateDeclInstantiator::VisitCXXMethodDecl(
26692671
TemplateArgumentList::CreateCopy(SemaRef.Context,
26702672
Innermost),
26712673
/*InsertPos=*/nullptr);
2672-
} else if (!isFriend) {
2674+
} else if (!isFriend && FunctionRewriteKind == RewriteKind::None) {
26732675
// Record that this is an instantiation of a member function.
26742676
Method->setInstantiationOfMemberFunction(D, TSK_ImplicitInstantiation);
26752677
}

0 commit comments

Comments
 (0)