[PATCH] D85256: Add -Wtautological-value-range-compare warning.

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 4 16:21:15 PDT 2020


rsmith created this revision.
rsmith added a reviewer: rtrieu.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
rsmith requested review of this revision.

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).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85256

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/tautological-constant-compare.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85256.283055.patch
Type: text/x-patch
Size: 9763 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200804/b0cefd67/attachment.bin>


More information about the cfe-commits mailing list