[ASTImporter] Add unittest case for friend decl import

Summary:
This change adds a matching test case for the recent bug fix to
VisitFriendDecl in ASTImporterLookup.cpp.

See https://reviews.llvm.org/D82882 for details.

Reviewers: martong, a.sidorin, shafik

Reviewed By: martong

Subscribers: rnkovacs, teemperor, cfe-commits, dkrupp

Tags: #clang

Differential Revision: https://reviews.llvm.org/D83006
This commit is contained in:
Vince Bridgers 2020-07-01 16:49:08 -05:00 committed by einvbri
parent 10a898b3ec
commit 59f1bf46f8
1 changed files with 20 additions and 0 deletions

View File

@ -3416,6 +3416,26 @@ TEST_P(ASTImporterOptionSpecificTestBase,
EXPECT_TRUE(ToCtor->hasBody());
}
TEST_P(ASTImporterOptionSpecificTestBase, ClassTemplateFriendDecl) {
const auto *Code =
R"(
template <class T> class X { friend T; };
struct Y {};
template class X<Y>;
)";
Decl *ToTU = getToTuDecl(Code, Lang_CXX11);
Decl *FromTU = getTuDecl(Code, Lang_CXX11);
auto *FromSpec = FirstDeclMatcher<ClassTemplateSpecializationDecl>().match(
FromTU, classTemplateSpecializationDecl());
auto *ToSpec = FirstDeclMatcher<ClassTemplateSpecializationDecl>().match(
ToTU, classTemplateSpecializationDecl());
auto *ImportedSpec = Import(FromSpec, Lang_CXX11);
EXPECT_EQ(ImportedSpec, ToSpec);
EXPECT_EQ(1u, DeclCounter<ClassTemplateSpecializationDecl>().match(
ToTU, classTemplateSpecializationDecl()));
}
TEST_P(ASTImporterOptionSpecificTestBase,
ClassTemplatePartialSpecializationsShouldNotBeDuplicated) {
auto Code =