[clang-tidy] Catch trivially true statements like a != 1 || a != 3
authorAlexander Kornienko <alexfh@google.com>
Thu, 23 Mar 2017 15:13:54 +0000 (15:13 +0000)
committerAlexander Kornienko <alexfh@google.com>
Thu, 23 Mar 2017 15:13:54 +0000 (15:13 +0000)
commitc3acd2e9c048d5e63436cf775760beab21579801
tree11cdeec7507024ec483c47d1c74adfe25aeb1d88
parent11ad33912790760552a0f02e5b0c1f813422ddd9
[clang-tidy] Catch trivially true statements like a != 1 || a != 3

Catch trivially true statements of the form a != 1 || a != 3. Statements like
these are likely errors. They are particularly easy to miss when handling enums:

enum State {
RUNNING,
STOPPED,
STARTING,
ENDING
}

...
if (state != RUNNING || state != STARTING)
...

Patch by Blaise Watson!

Differential revision: https://reviews.llvm.org/D29858

llvm-svn: 298607
clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
clang-tools-extra/test/clang-tidy/misc-redundant-expression.cpp