From 59f1bf46f8c258b9c784ff921b89fb6cb7a06612 Mon Sep 17 00:00:00 2001 From: Vince Bridgers Date: Wed, 1 Jul 2020 16:49:08 -0500 Subject: [PATCH] [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 --- clang/unittests/AST/ASTImporterTest.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp index 172fbb461a7e..d6a5afeeb489 100644 --- a/clang/unittests/AST/ASTImporterTest.cpp +++ b/clang/unittests/AST/ASTImporterTest.cpp @@ -3416,6 +3416,26 @@ TEST_P(ASTImporterOptionSpecificTestBase, EXPECT_TRUE(ToCtor->hasBody()); } +TEST_P(ASTImporterOptionSpecificTestBase, ClassTemplateFriendDecl) { + const 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 =