This is an archive of the discontinued LLVM Phabricator instance.

Refactor: Simplify boolean conditional return statements in lib/Sema
AbandonedPublic

Authored by LegalizeAdulthood on May 25 2015, 2:27 PM.

Details

Reviewers
dblaikie
Summary

Use clang-tidy to simplify boolean conditional return statements

Diff Detail

Event Timeline

LegalizeAdulthood retitled this revision from to Refactor: Simplify boolean conditional return statements in lib/Sema.
LegalizeAdulthood updated this object.
LegalizeAdulthood edited the test plan for this revision. (Show Details)
LegalizeAdulthood added a subscriber: Unknown Object (MLST).

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

We should come to some conclusion about these chained return cases - they seem fairly benign/not buggy/not worth changing.

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.

Update from latest.
Update from comments.
I do not have commit access.

alexfh removed a subscriber: dblaikie.
alexfh added a subscriber: alexfh.

David, have your comments been addressed completely?

LegalizeAdulthood abandoned this revision.Feb 19 2016, 9:22 AM