RFC: clang-tidy readability-else-after-return: what about continue/break in loops?

[Please reply *only* to the list and do not include my email directly
in the To: or Cc: of your reply; otherwise I will not see your reply.
Thanks.]

Hi,

Clang-tidy's readability-else-after-return flags constructs such as:

if (foo) {
  return;
} else {
  other_stuff();
}

Since there's no way you can both take the 'if (foo)' branch and the
'else' branch due to the return statement.

What about similar uses of continue?

for (auto item : container) {
  if (foo) {
    continue;
  } else {
    other_stuff();
  }
}

Here the continue statement has the same effect locally within the
for loop as the return statement had in an enclosing function. In
other words, the following code is equivalent:

for (auto item : container) {
  if (foo) {
    continue;
  }
  other_stuff();
}

Doesn't a similar situation occur with a break statement in a loop?

[Please reply *only* to the list and do not include my email directly
in the To: or Cc: of your reply; otherwise I will not see your reply.
Thanks.]

Hi,

Clang-tidy's readability-else-after-return flags constructs such as:

if (foo) {
  return;
} else {
  other_stuff();
}

Since there's no way you can both take the 'if (foo)' branch and the
'else' branch due to the return statement.

What about similar uses of continue?

for (auto item : container) {
  if (foo) {
    continue;
  } else {
    other_stuff();
  }
}

Here the continue statement has the same effect locally within the
for loop as the return statement had in an enclosing function. In
other words, the following code is equivalent:

for (auto item : container) {
  if (foo) {
    continue;
  }
  other_stuff();
}

Doesn't a similar situation occur with a break statement in a loop?

Yep. throw as well. (or a call to a noreturn function? Probably) Anything
that terminates normal control flow.