Index: unittests/AST/ASTImporterTest.cpp =================================================================== --- unittests/AST/ASTImporterTest.cpp +++ unittests/AST/ASTImporterTest.cpp @@ -1095,6 +1095,20 @@ unless(has(cxxRecordDecl(hasName("declToImport")))))))); } +TEST(ImportDecl, ImportClassTemplatePartialSpecialization) { + MatchVerifier Verifier; + auto Code = + R"s( + struct declToImport { + template struct X; + template struct X {}; + }; + )s"; + testImport(Code, Lang_CXX, "", Lang_CXX, Verifier, + recordDecl(has(classTemplateDecl()), + has(classTemplateSpecializationDecl()))); +} + TEST(ImportExpr, CXXOperatorCallExpr) { MatchVerifier Verifier; testImport("class declToImport {" @@ -1128,6 +1142,52 @@ EXPECT_EQ(ToTemplated1, ToTemplated); } +TEST_P(ASTImporterTestBase, + DISABLED_ImportOfTemplatedDeclOfFunctionTemplateDecl) { + Decl *FromTU = getTuDecl("template void f(){}", Lang_CXX); + auto From = FirstDeclMatcher().match( + FromTU, functionTemplateDecl()); + ASSERT_TRUE(From); + auto To = cast(Import(From, Lang_CXX)); + ASSERT_TRUE(To); + Decl *ToTemplated = To->getTemplatedDecl(); + Decl *ToTemplated1 = Import(From->getTemplatedDecl(), Lang_CXX); + EXPECT_TRUE(ToTemplated1); + EXPECT_EQ(ToTemplated1, ToTemplated); +} + +TEST_P(ASTImporterTestBase, + ImportOfTemplatedDeclShouldImportTheClassTemplateDecl) { + Decl *FromTU = getTuDecl("template struct S{};", Lang_CXX); + auto FromFT = + FirstDeclMatcher().match(FromTU, classTemplateDecl()); + ASSERT_TRUE(FromFT); + + auto ToTemplated = + cast(Import(FromFT->getTemplatedDecl(), Lang_CXX)); + EXPECT_TRUE(ToTemplated); + auto ToTU = ToTemplated->getTranslationUnitDecl(); + auto ToFT = + FirstDeclMatcher().match(ToTU, classTemplateDecl()); + EXPECT_TRUE(ToFT); +} + +TEST_P(ASTImporterTestBase, + DISABLED_ImportOfTemplatedDeclShouldImportTheFunctionTemplateDecl) { + Decl *FromTU = getTuDecl("template void f(){}", Lang_CXX); + auto FromFT = FirstDeclMatcher().match( + FromTU, functionTemplateDecl()); + ASSERT_TRUE(FromFT); + + auto ToTemplated = + cast(Import(FromFT->getTemplatedDecl(), Lang_CXX)); + EXPECT_TRUE(ToTemplated); + auto ToTU = ToTemplated->getTranslationUnitDecl(); + auto ToFT = FirstDeclMatcher().match( + ToTU, functionTemplateDecl()); + EXPECT_TRUE(ToFT); +} + TEST_P(ASTImporterTestBase, ImportCorrectTemplatedDecl) { auto Code = R"(