@@ -2269,16 +2269,18 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(
2269
2269
TemplateArgumentList::CreateCopy (SemaRef.Context ,
2270
2270
Innermost),
2271
2271
/* 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
+ }
2282
2284
}
2283
2285
2284
2286
if (isFriend) {
@@ -2669,7 +2671,7 @@ Decl *TemplateDeclInstantiator::VisitCXXMethodDecl(
2669
2671
TemplateArgumentList::CreateCopy (SemaRef.Context ,
2670
2672
Innermost),
2671
2673
/* InsertPos=*/ nullptr );
2672
- } else if (!isFriend) {
2674
+ } else if (!isFriend && FunctionRewriteKind == RewriteKind::None ) {
2673
2675
// Record that this is an instantiation of a member function.
2674
2676
Method->setInstantiationOfMemberFunction (D, TSK_ImplicitInstantiation);
2675
2677
}
0 commit comments