diff options
author | Gabor Marton <gabor.marton@ericsson.com> | 2020-11-25 18:32:30 +0100 |
---|---|---|
committer | Gabor Marton <gabor.marton@ericsson.com> | 2020-11-30 17:55:25 +0100 |
commit | 70eb2ce395be1fe39ceede6719aa667658d1e5a3 (patch) | |
tree | 39913f1739bbd4f266d9afb70e0edb47ec7c0bd7 /clang/unittests | |
parent | 7a91794d5b261bc87991d5acce9fa503e9a4f269 (diff) | |
download | llvm-project-70eb2ce395be1fe39ceede6719aa667658d1e5a3.tar.gz |
[ASTImporter] Support import of CXXDeductionGuideDecl
CXXDeductionGuideDecl is a FunctionDecl, but its constructor should be called
appropriately, at least to set the kind variable properly.
Differential Revision: https://reviews.llvm.org/D92109
Diffstat (limited to 'clang/unittests')
-rw-r--r-- | clang/unittests/AST/ASTImporterTest.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp index 81a92a10f48d..7e56b3ed501f 100644 --- a/clang/unittests/AST/ASTImporterTest.cpp +++ b/clang/unittests/AST/ASTImporterTest.cpp @@ -5957,6 +5957,47 @@ TEST_P(ImportWithExternalSource, CompleteRecordBeforeImporting) { EXPECT_EQ(Record, CompletedTags.front()); } +TEST_P(ImportFunctions, CTADImplicit) { + Decl *FromTU = getTuDecl( + R"( + template <typename T> struct A { + A(T); + }; + A a{(int)0}; + )", + Lang_CXX17, "input.cc"); + auto *FromD = FirstDeclMatcher<CXXDeductionGuideDecl>().match( + FromTU, + cxxDeductionGuideDecl(hasParameter(0, hasType(asString("A<T>"))))); + auto *ToD = Import(FromD, Lang_CXX17); + ASSERT_TRUE(ToD); + EXPECT_TRUE(ToD->isCopyDeductionCandidate()); + // Check that the deduced class template is also imported. + EXPECT_TRUE(findFromTU(FromD)->Importer->GetAlreadyImportedOrNull( + FromD->getDeducedTemplate())); +} + +TEST_P(ImportFunctions, CTADUserDefinedExplicit) { + Decl *FromTU = getTuDecl( + R"( + template <typename T> struct A { + A(T); + }; + template <typename T> explicit A(T) -> A<float>; + A a{(int)0}; // calls A<float>::A(float) + )", + Lang_CXX17, "input.cc"); + auto *FromD = FirstDeclMatcher<CXXDeductionGuideDecl>().match( + FromTU, cxxDeductionGuideDecl(unless(isImplicit()))); + // Not-implicit: i.e. not compiler-generated, user defined. + ASSERT_FALSE(FromD->isImplicit()); + ASSERT_TRUE(FromD->isExplicit()); // Has the explicit keyword. + auto *ToD = Import(FromD, Lang_CXX17); + ASSERT_TRUE(ToD); + EXPECT_FALSE(FromD->isImplicit()); + EXPECT_TRUE(ToD->isExplicit()); +} + INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest, DefaultTestValuesForRunOptions, ); |