[PATCH] D37014: [clang-tidy] Add a checker to remove useless intermediate variables before return statements with comparisons
Tristan Bourvon via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 22 08:46:32 PDT 2017
tbourvon created this revision.
Herald added subscribers: xazax.hun, JDevlieghere, mgorny.
This patch adds a checker to detect patterns of the following form:
auto IntermediateVar = foo();
return (IntermediateVar == 1);
and suggests to turn them into:
return (foo() == 1);
The reasoning behind this checker is that this kind of pattern is useless and lowers readability as long as the return statement remains rather short.
The idea of this checker was suggested to me by Sylvestre Ledru.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 33186 bytes
Desc: not available
More information about the cfe-commits