<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/68775>68775</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang][ASTImporter] infinite recursion on lambda with deduced return type from struct declared inside
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
danix800
</td>
</tr>
</table>
<pre>
`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:
```c
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:
```c
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);
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVNuO2zYQ_RrqZRCDoixZftCD1xcgQNoGa7X124ImRxILSjRIKpv8fUHSm2hzaYoYBmwO53LmnBly51Q_ITakfCDlIeOzH4xtJJ_Ux5rS7Grkp4ZUdHdufzcS3443Yz1aUuxIsftLOeVP8yS8MtMBhSYVBWEmpyRalMCvZvagpk5NyiNYFLN1ykxgJujuYfCs_AAS5SxQgkU_2wn8pxtCZ80IzttZeJAoNA8pVUz-JTrgI2wP11DIE7ZxMBkPPU5ouQaczNwPoZ4fEDqjtXlWUw_CSAw90AOhO1LR9BXp_MEoCZ0xhNWEbYFsHpIdAAirw200R8K-4wMvoC_RvDmQYnl5b_GSIpd3S9fw_zW4dGwHfEWS6cAPyoHm41VyUKn9z3RxB6SifPYmSOPM98RwXmkNRoQzPA84gkoqyx8y1B7P7dN7wurduX0ZiT9uQZDzDYXqlGjR-QfuMGjzLmJ7jKj_Vn44R3reRiW_Ii8MERC2O1kzhlDCdq1ZcOS8TKPnFRJWv7i1JuYpDtCjvwOScSBZvaAeHgljX5n-Q-z4-X-K_1z2n2ifai2DPk_AC45tBL9fGt_xqX_aXy55nshiyeVbe2yQva4ZpiIRnASK_J2UdT4w9xv3YgiLvk-3x483S4pjQr4awy1hdSB-fx--6JEaW9Y5Xt4f9-1T-_jnMQakdEuXb2c9k00ht8WWZ9jk1XZDc1bQTTY0kvJ1TrtrJ0vMGYpqW5UFVkyWlezKvM5UwygrcprntM5rtllVVdHJQqypwI6tkZE1xZErvdL6w7gyts-UczM2Vb3ZlJnmV9QuPoaMCc2nPtBWHjLbBP8317l3ZE21ct59yeCV1_EFTRHlgZQPi80g5eEHj-B9a3_lCcxmq5vB-5sLC8FOhJ165Yf5uhJhJ04B3P3nzc2af1B4wk6xV0fYKbb7bwAAAP__UfXD4w">