Author: Vince Bridgers Date: 2020-07-02T09:26:34-05:00 New Revision: 59f1bf46f8c258b9c784ff921b89fb6cb7a06612
URL: https://github.com/llvm/llvm-project/commit/59f1bf46f8c258b9c784ff921b89fb6cb7a06612 DIFF: https://github.com/llvm/llvm-project/commit/59f1bf46f8c258b9c784ff921b89fb6cb7a06612.diff LOG: [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 Added: Modified: clang/unittests/AST/ASTImporterTest.cpp Removed: ################################################################################ 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 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 = _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits