[clang] [clang][ASTImporter] Allow import of similar friend template with different depth (PR #115734)
Michael Buch via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 11 15:08:23 PST 2024
================
@@ -6120,6 +6119,19 @@ ExpectedDecl ASTNodeImporter::VisitClassTemplateDecl(ClassTemplateDecl *D) {
// see ASTTests test ImportExistingFriendClassTemplateDef.
continue;
}
+ // When importing a friend, it is possible that multiple declarations
+ // with same name can co-exist in specific cases (if a template contains
+ // a friend template and has a specialization). For this case the
+ // declarations should match, except that the "template depth" is
+ // different. No linking of previous declaration is needed in this case.
+ // FIXME: This condition may need refinement.
+ if (D->getFriendObjectKind() != Decl::FOK_None &&
+ FoundTemplate->getFriendObjectKind() != Decl::FOK_None &&
+ D->getFriendObjectKind() != FoundTemplate->getFriendObjectKind() &&
+ IsStructuralMatch(D, FoundTemplate, /*Complain=*/false,
+ /*IgnoreTemplateParmDepth=*/true))
+ continue;
----------------
Michael137 wrote:
It feels like the logic on 6103 and this here could be merged together? Should `IgnoreTemplateParmDepth` on 6104 just be changed to also be set if the `FriendObjectKind` matches? Then I *think* everything should work out as expected
https://github.com/llvm/llvm-project/pull/115734
More information about the cfe-commits
mailing list