[PATCH] D55125: [clang-tidy] Fix a false positive in misc-redundant-expression check
Alexander Kornienko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 12 07:19:22 PDT 2019
alexfh added a comment.
One more nit.
Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:674
+ return !(
+ (isTokAtEndOfExpr(Lsr, LTok, SM) && isTokAtEndOfExpr(Rsr, RTok, SM)) &&
+ isSameToken(LTok, RTok, SM));
> You can drop a set of parens here as they don't change the order of evaluation.
I'd propagate the negation into the parentheses. I find it easier to understand `!a || !b || !c` than `!(a && b && c)`, since the former can be digested piece by piece, but the latter requires the reader to keep the `!` in their mind and "recurse" into the nested parentheses. It's similar to the "early return" pattern vs. nested conditional statements.
CHANGES SINCE LAST ACTION
More information about the cfe-commits