[PATCH] D65999: [ASTImporter] Import additional flags for functions.
Balázs Kéri via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 12 01:12:35 PDT 2019
balazske updated this revision to Diff 214585.
balazske added a comment.
- Using StringRef, added comment.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D65999/new/
https://reviews.llvm.org/D65999
Files:
clang/lib/AST/ASTImporter.cpp
clang/unittests/AST/ASTImporterTest.cpp
Index: clang/unittests/AST/ASTImporterTest.cpp
===================================================================
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5270,9 +5270,53 @@
}
}
-INSTANTIATE_TEST_CASE_P(ParameterizedTests, SVEBuiltins,
- ::testing::Values(ArgVector{"-target",
- "aarch64-linux-gnu"}), );
+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, ASTImporterLookupTableTest,
DefaultTestValuesForRunOptions, );
@@ -5326,5 +5370,9 @@
INSTANTIATE_TEST_CASE_P(ParameterizedTests, LLDBLookupTest,
DefaultTestValuesForRunOptions, );
+INSTANTIATE_TEST_CASE_P(ParameterizedTests, SVEBuiltins,
+ ::testing::Values(ArgVector{"-target",
+ "aarch64-linux-gnu"}), );
+
} // end namespace ast_matchers
} // end namespace clang
Index: clang/lib/AST/ASTImporter.cpp
===================================================================
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -3292,6 +3292,9 @@
ToFunction->setVirtualAsWritten(D->isVirtualAsWritten());
ToFunction->setTrivial(D->isTrivial());
ToFunction->setPure(D->isPure());
+ ToFunction->setDefaulted(D->isDefaulted());
+ ToFunction->setExplicitlyDefaulted(D->isExplicitlyDefaulted());
+ ToFunction->setDeletedAsWritten(D->isDeletedAsWritten());
ToFunction->setRangeEnd(ToEndLoc);
// Set the parameters.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65999.214585.patch
Type: text/x-patch
Size: 3407 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190812/1bc71990/attachment-0001.bin>
More information about the cfe-commits
mailing list