aboutsummaryrefslogtreecommitdiff
path: root/unittests/AST/ASTImporterTest.cpp
diff options
context:
space:
mode:
authorBalazs Keri <1.int32@gmail.com>2019-08-13 08:04:06 +0000
committerBalazs Keri <1.int32@gmail.com>2019-08-13 08:04:06 +0000
commitdd1f0cfb631e1c4f8c5a0caac3080bac9385a3c1 (patch)
tree429fb15502b882864cc47f683e78f7b9c0039fce /unittests/AST/ASTImporterTest.cpp
parent9684fd216c1a0c3079fc42664b13ef4e10980195 (diff)
[ASTImporter] Import additional flags for functions.
Summary: At AST import of function delcarations import the flags for defaulted and deleted. Reviewers: martong, a.sidorin, shafik, a_sidorin Reviewed By: a_sidorin Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65999 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368655 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/AST/ASTImporterTest.cpp')
-rw-r--r--unittests/AST/ASTImporterTest.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/unittests/AST/ASTImporterTest.cpp b/unittests/AST/ASTImporterTest.cpp
index 3cdad0dfd5..78b67d836b 100644
--- a/unittests/AST/ASTImporterTest.cpp
+++ b/unittests/AST/ASTImporterTest.cpp
@@ -5314,6 +5314,54 @@ TEST_P(SVEBuiltins, ImportTypes) {
}
}
+TEST_P(ASTImporterOptionSpecificTestBase, ImportOfDefaultImplicitFunctions) {
+ // Test that import of implicit functions works and the functions
+ // are merged into one chain.
+ auto GetDeclToImport = [this](StringRef File) {
+ Decl *FromTU = getTuDecl(
+ R"(
+ struct X { };
+ // Force generating some implicit operator definitions for X.
+ void f() { X x1, x2; x1 = x2; X *x3 = new X; delete x3; }
+ )",
+ Lang_CXX11, File);
+ auto *FromD = FirstDeclMatcher<CXXRecordDecl>().match(
+ FromTU, cxxRecordDecl(hasName("X"), unless(isImplicit())));
+ // Destructor is picked as one example of implicit function.
+ return FromD->getDestructor();
+ };
+
+ auto *ToD1 = Import(GetDeclToImport("input1.cc"), Lang_CXX11);
+ ASSERT_TRUE(ToD1);
+
+ auto *ToD2 = Import(GetDeclToImport("input2.cc"), Lang_CXX11);
+ ASSERT_TRUE(ToD2);
+
+ EXPECT_EQ(ToD1->getCanonicalDecl(), ToD2->getCanonicalDecl());
+}
+
+TEST_P(ASTImporterOptionSpecificTestBase,
+ ImportOfExplicitlyDefaultedOrDeleted) {
+ Decl *FromTU = getTuDecl(
+ R"(
+ struct X { X() = default; X(const X&) = delete; };
+ )",
+ Lang_CXX11);
+ auto *FromX = FirstDeclMatcher<CXXRecordDecl>().match(
+ FromTU, cxxRecordDecl(hasName("X")));
+ auto *ImportedX = Import(FromX, Lang_CXX11);
+ auto *Constr1 = FirstDeclMatcher<CXXConstructorDecl>().match(
+ ImportedX, cxxConstructorDecl(hasName("X"), unless(isImplicit())));
+ auto *Constr2 = LastDeclMatcher<CXXConstructorDecl>().match(
+ ImportedX, cxxConstructorDecl(hasName("X"), unless(isImplicit())));
+
+ ASSERT_TRUE(ImportedX);
+ EXPECT_TRUE(Constr1->isDefaulted());
+ EXPECT_TRUE(Constr1->isExplicitlyDefaulted());
+ EXPECT_TRUE(Constr2->isDeletedAsWritten());
+ EXPECT_EQ(ImportedX->isAggregate(), FromX->isAggregate());
+}
+
INSTANTIATE_TEST_CASE_P(ParameterizedTests, SVEBuiltins,
::testing::Values(ArgVector{"-target",
"aarch64-linux-gnu"}), );
@@ -5370,5 +5418,6 @@ INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportVariables,
INSTANTIATE_TEST_CASE_P(ParameterizedTests, LLDBLookupTest,
DefaultTestValuesForRunOptions, );
+
} // end namespace ast_matchers
} // end namespace clang