[PATCH] D57740: [ASTImporter] Import every Decl in lambda record
Gabor Marton via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 15 04:04:52 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354120: [ASTImporter] Import every Decl in lambda record (authored by martong, committed by ).
Herald added subscribers: llvm-commits, jdoerfert.
Herald added a project: LLVM.
Changed prior to commit:
https://reviews.llvm.org/D57740?vs=185509&id=186991#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D57740/new/
https://reviews.llvm.org/D57740
Files:
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/unittests/AST/ASTImporterTest.cpp
Index: cfe/trunk/lib/AST/ASTImporter.cpp
===================================================================
--- cfe/trunk/lib/AST/ASTImporter.cpp
+++ cfe/trunk/lib/AST/ASTImporter.cpp
@@ -7393,13 +7393,9 @@
// NOTE: lambda classes are created with BeingDefined flag set up.
// It means that ImportDefinition doesn't work for them and we should fill it
// manually.
- if (ToClass->isBeingDefined()) {
- for (auto FromField : FromClass->fields()) {
- auto ToFieldOrErr = import(FromField);
- if (!ToFieldOrErr)
- return ToFieldOrErr.takeError();
- }
- }
+ if (ToClass->isBeingDefined())
+ if (Error Err = ImportDeclContext(FromClass, /*ForceImport = */ true))
+ return std::move(Err);
auto ToCallOpOrErr = import(E->getCallOperator());
if (!ToCallOpOrErr)
Index: cfe/trunk/unittests/AST/ASTImporterTest.cpp
===================================================================
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp
@@ -2709,6 +2709,26 @@
2u);
}
+TEST_P(ImportFunctions, ImportImplicitFunctionsInLambda) {
+ Decl *FromTU = getTuDecl(
+ R"(
+ void foo() {
+ (void)[]() { ; };
+ }
+ )",
+ Lang_CXX11);
+ auto *FromD = FirstDeclMatcher<FunctionDecl>().match(
+ FromTU, functionDecl(hasName("foo")));
+ auto *ToD = Import(FromD, Lang_CXX);
+ EXPECT_TRUE(ToD);
+ CXXRecordDecl *LambdaRec =
+ cast<LambdaExpr>(cast<CStyleCastExpr>(
+ *cast<CompoundStmt>(ToD->getBody())->body_begin())
+ ->getSubExpr())
+ ->getLambdaClass();
+ EXPECT_TRUE(LambdaRec->getDestructor());
+}
+
struct ImportFriendFunctions : ImportFunctions {};
TEST_P(ImportFriendFunctions, ImportFriendFunctionRedeclChainProto) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57740.186991.patch
Type: text/x-patch
Size: 1822 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190215/081822a6/attachment.bin>
More information about the cfe-commits
mailing list