Add -Wtautological-value-range-compare warning.
authorRichard Smith <richard@metafoo.co.uk>
Tue, 4 Aug 2020 22:33:57 +0000 (15:33 -0700)
committerRichard Smith <richard@metafoo.co.uk>
Thu, 6 Aug 2020 20:28:50 +0000 (13:28 -0700)
commitd6492d874478b1d3b1ce3adb4c3044618bec29e9
tree3d2c7e2369ef871ffd2b7499f301dd76615937c5
parentffc248f3b88cd6a0153d23660727b45dde8f27b5
Add -Wtautological-value-range-compare warning.

This warning diagnoses cases where an expression is compared to a
constant, and the comparison is tautological due to the form of the
expression (but not merely due to its type). This applies in cases such
as comparisons of bit-fields and the result of bit-masks.

The new warning is added to the Clang diagnostic group
-Wtautological-constant-in-range-compare but not to the
formerly-equivalent GCC-compatibility diagnostic group -Wtype-limits,
which retains its old meaning of diagnosing only tautological
comparisons to extremal values of a type (eg, int > INT_MAX).

Reviewed By: rtrieu

Differential Revision: https://reviews.llvm.org/D85256
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaChecking.cpp
clang/test/Sema/tautological-constant-compare.c