Use clang-tidy to simplify boolean conditional return statements
Details
Diff Detail
Event Timeline
Got only part way through this one.
We should come to some conclusion about these chained return cases - they seem fairly benign/not buggy/not worth changing.
Basically what I mean when I say "chain" or "possible chain" is that it looks like this last if/return is just another case of several in the same function and shouldn't be treated differently by being rolled into one final return statement. Mostly the question I think that's worth asking is "could I reasonably add another condition on to the end of this function?" and if so, it hurts readability/writability by rolling it in and making it somehow different from the other cases in the function.
I think this was a concern John McCall raised a few weeks ago on the same sort of changes you'd been proposing.
lib/Sema/SemaChecking.cpp | ||
---|---|---|
5019 | Possible chain | |
9131 | Possible chain | |
9229 | Possible chain | |
lib/Sema/SemaDecl.cpp | ||
2556 | Possible chain | |
14011 | Possible chain | |
lib/Sema/SemaDeclAttr.cpp | ||
367 | possible chain | |
460 | Possible chain | |
1816 | possible chain |
Ah... I see what you mean. So like the other case where it was something like if (expr) var = true; else if (expr2) var = true; else if (expr3) var = true; else var = false;, you'd like the option of disabling this check when it is a series of chained return statements?
That's great feedback and is something I can do to enhance the check.
Possible chain