Open
Description
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.