<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/89595>89595</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
`readability-misleading-indentation` false positive on several stacked loops without indentation
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
HolyBlackCat
</td>
</tr>
</table>
<pre>
```cpp
int main()
{
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
{}
(void)42;
}
```
Analyzing with `clang-tidy 1.cpp -checks=readability-misleading-indentation -- -Wall -Wextra` results in a false positive:
```
1 warning generated.
/path/to/1.cpp:6:5: warning: misleading indentation: statement is indented too deeply [readability-misleading-indentation]
6 | (void)42;
| ^
/path/to/1.cpp:3:5: note: did you mean this line to be inside this 'for'
3 | for (int i = 0; i < 3; i++)
| ^
```
Using this indentation style for 2D loops is not unheard of, and it's a shame that clang-tidy warns about those. (The warning is otherwise useful, so I don't want to disable it everywhere.)
I suggest that this warning should be skipped for control statements with non-indented bodies.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVE-PuzYQ_TSTy4iImBCHQw7506i_e6vf2eABvOvYiBk2TT99ZZLdbFertqqEwDCM_d6bN2OYXReIdlAeoDwtzCR9HHe_Rn87eNO8Ho0s6mhvO9jk96sZBshPkO9dELwYF0BtQVX3b6AP9wUiYhtHBLVN_zmE4oQ5FId5ecRiXoI6zFf1bdLLM-nlmfTyTVI6Vp8e76C2b9FZUNVaQXF4B_YIf_C4v-6D8bc_Xejw6qTHxM-b0GXi7A1Xy2YYMGt6al4ZitNIxpraeSe37OLYk7EudJkLloIYcTFglmH203iP2U_6Q0YDmxxH4skLowtosDWeCYfITtwbQbH_FtYKr2YMCVZHgUYjZJePH9V5MNKDOksEdZ4hQrHfQLEvodi_56XlEyJ-gpgiLEboQqkw_IiRRYkRLdHgbwjl4d_JQnl6lmCDoI84F-M7_fEe0keE8pd_ZFK8MwlRkj5oncVbnPBCJqD0jtG7QCgRa0IX2Fm6fwal2ziC0s8jiw9U_8uMXxH_vUj3---cBJ4BfDYCy83TfKo6oY9x4KR1iIJT6MmMFmML6ogmWHQCSjMa5N5cEhkj-MmGqaSMpo6ToPSRaZmY_NbTh0kcY5SexqtjwompnXzamyP-QBsDKC14NUGSaNaxqT2hE6Q3Gm_XnkZaPjt4vv9AnrqOWO5gZnbvh3EfJ2-T-PzqhoHszLKJQcbon9bie0eFGLIPh9XROuLlwu4KWxWVWdBupVeF3hbVSi36nW6bTamrxmzbTb7N85oqynWjq_WmrVq9XridytU6Xyu1WuXlSi3Lpir0RrcrnWtLWwPrnC7G-aX3b5dlHLuFY55ot63Kqlx4U5PnedYpFeiKcxCUSqNv3KWcrJ46hnXuHQs_dxEnntIQ_A9tscm_dDkmPySxzaxP80r2YYkkUSrrp_TFNPpdLzJwGg7qDOrcOemnetnEC6hzgvR4ZMMYX6gRUOeZCIM6z0T_CgAA__8V_cn9">