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) {
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) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits