Skip to content

[clang][ASTImporter] infinite recursion on lambda with deduced return type from struct declared inside #68775

@danix800

Description

@danix800

ASTNodeImporter::VisitFunctionDecl considered about infinite recursion on function with deduced return type from struct declared inside function body, but it's not general enough on the following code:

void foo() {
   (void) []() {
     struct X {};
     return X();
   };
}

The return type of this lambda is not declared as auto so infinite recursion still occurs whem imported:

TEST_P(ASTImporterOptionSpecificTestBase, LambdaReturnWithStructInside) {
  Decl *From, *To;
  std::tie(From, To) = getImportedDecl(
      R"(
      void foo() {
        (void) []() {
          struct X {};
          return X();
        };
      }
      )",
      Lang_CXX11, "", Lang_CXX11, "foo");
  auto *ToLambda = FirstDeclMatcher<LambdaExpr>().match(To, lambdaExpr());
  EXPECT_TRUE(ToLambda);
}

Metadata

Metadata

Assignees

Labels

clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions