[PATCH] D37629: [Sema] Move some stuff into -Wtautological-unsigned-enum-zero-compare

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 8 09:10:20 PDT 2017


lebedev.ri created this revision.
lebedev.ri added a project: clang.

As requested by Sam McCall:

> Enums (not new I guess). Typical case: if (enum < 0 || enum > MAX)
>  The warning strongly suggests that the enum < 0 check has no effect
>  (for enums with nonnegative ranges).
>  Clang doesn't seem to optimize such checks out though, and they seem
>  likely to catch bugs in some cases. Yes, only if there's UB elsewhere,
>  but I assume not optimizing out these checks indicates a deliberate
>  decision to stay somewhat compatible with a technically-incorrect
>  mental model.
>  If this is the case, should we move these to a
>  -Wtautological-compare-enum subcategory?


Repository:
  rL LLVM

https://reviews.llvm.org/D37629

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37629.114375.patch
Type: text/x-patch
Size: 9339 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170908/11b3ddd3/attachment-0001.bin>


More information about the cfe-commits mailing list