<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/148662>148662</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
readability-else-after-return breaks comments (needs newline)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
higher-performance
</td>
</tr>
</table>
<pre>
This check turns code such as
```
void f(int a) {
if (a > 0) {
return;
} else {
// comment-1
return;
}
}
```
into
```
void f(int a) {
if (a > 0) {
return;
} // comment-1
// another line
return;
}
```
which is problematic because `comment-1` is associated with the subsequent line, not with the preceding closing brace. This trips up clang-format as well.
A better fix would have been
```
void f(int a) {
if (a > 0) {
return;
}
// comment-1
// another line
return;
}
```
which can then get formatted correctly by clang-format.
I'm not sure how to produce the correct fix here without breaking other cases, though.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyklMGO2yAQhp8GX0aOMI6d-OBDtttIvfcFAE8MXQwpjJPm7SvsVNl226rVSpaRGRj--f4xMiU7esSeNU-seS7kTCbE3tjRYCzPGE8hTtJrLFQYbv1nYxNog_oFaI4-gQ4DQpq1AZkYP7CW3x9-uAQ7wImJvfUEkokO2O6J8QOAPQETewms_gj8dQAgYs7L6vWb7Z4BXcJXC5g4MnEEHaYJPZVVnn6zKStZ36_0WE_h3RLf6vuTqMe09IEMRnDW4685fqv0aqw2YBOcY1AOJ0lWg0It54yi5Y9zWp6XyZSCtpJwgKslA2SyJyrh1xk9reeKD-ADPeLniBoH60fQLqQ8qig1bmCxmKI9J5jPoJ30Y7k0AYFMcEXnNqvuAygkwggn-w2uYXYDGHlBUIj-Xzn_Tyf8pQHezVpLn6l4GJFgrTbT1CFG1ORuoG4_obgj-MTEblq4pjkimHAFCtm1Yda4YL5nWBgZjLgYEGYCFVG-ZOyrXi0TpmxSjo5mUwx9PXR1Jwvsq10jmopv91Vh-pNu227fNrWu262sOtXIYauwbrp929W7urC94KLhu2pbtWLPq03NtRYtql1To-bYsC3HSVq3ce4ybUIcC5vSjH213betKJxU6NJyHwjh8QpLlAmRr4fY502lmsfEttzZROmRhiw57CPKQSrrLN3K_O-W8kQYy9WItez0w72U3feIQwKP17VPu2KOrjdE58Tqw2rraMnMaqPDxMQxn3cfynMMX1ATE8dFZWLieC_j0ovvAQAA__-Qo3k1">