[PATCH] D29858: [clang-tidy] Catch trivially true statements like a != 1 || a != 3
Blaise Watson via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 28 14:52:01 PST 2017
watsond marked 2 inline comments as done.
watsond added a comment.
In https://reviews.llvm.org/D29858#675055, @etienneb wrote:
> Could you add some tests with enums (like the one in your description)?
> This is missing and it's a nice to have.
Added
================
Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:244
+ // x != 5 || x != 10
+ if (OpcodeLHS == BO_NE || OpcodeLHS == BO_NE)
+ return true;
----------------
etienneb wrote:
> etienneb wrote:
> > The good news is that this code will be catch by this check!
> > ```
> > if (OpcodeLHS == BO_NE || OpcodeLHS == BO_NE) <<-- redundant expression
> > ```
> > Should be:
> > ```
> > if (OpcodeLHS == BO_NE || OpcodeRHS == BO_NE)
> > ```
> >
> >
> >
> btw, it should be:
>
> ```
> if (OpcodeLHS == BO_NE && OpcodeRHS == BO_NE)
> ```
Thanks for catching!
https://reviews.llvm.org/D29858
More information about the cfe-commits
mailing list