[cfe-dev] RFC: clang-tidy readability-else-after-return: what about continue/break in loops?
Richard via cfe-dev
cfe-dev at lists.llvm.org
Fri Jan 15 12:15:04 PST 2016
[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?
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Computer Graphics Museum <http://ComputerGraphicsMuseum.org>
The Terminals Wiki <http://terminals.classiccmp.org>
Legalize Adulthood! (my blog) <http://LegalizeAdulthood.wordpress.com>
More information about the cfe-dev
mailing list