diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp --- a/clang/unittests/AST/ASTImporterTest.cpp +++ b/clang/unittests/AST/ASTImporterTest.cpp @@ -3417,6 +3417,29 @@ } TEST_P(ASTImporterOptionSpecificTestBase, + ClassTemplateFriendDecl) { + auto Code = + R"( + template class X { friend T; }; + struct Y {}; + template class X; + )"; + Decl *ToTU = getToTuDecl(Code, Lang_CXX11); + Decl *FromTU = getTuDecl(Code, Lang_CXX11); + auto *FromSpec = + FirstDeclMatcher().match( + FromTU, classTemplateSpecializationDecl()); + auto *ToSpec = + FirstDeclMatcher().match( + ToTU, classTemplateSpecializationDecl()); + + auto *ImportedSpec = Import(FromSpec, Lang_CXX11); + EXPECT_EQ(ImportedSpec, ToSpec); + EXPECT_EQ(1u, DeclCounter().match( + ToTU, classTemplateSpecializationDecl())); +} + +TEST_P(ASTImporterOptionSpecificTestBase, ClassTemplatePartialSpecializationsShouldNotBeDuplicated) { auto Code = R"(