]> granicus.if.org Git - clang/commit
[Sema] Re-land: Diagnose tautological comparison with type's min/max values
authorRoman Lebedev <lebedev.ri@gmail.com>
Sun, 15 Oct 2017 20:13:17 +0000 (20:13 +0000)
committerRoman Lebedev <lebedev.ri@gmail.com>
Sun, 15 Oct 2017 20:13:17 +0000 (20:13 +0000)
commitb2c9b51338ce013d19de7e15966e7e56ca6ab209
treecb19acaf405bd7d4b71e7a8fb45fb6ce0209ab7b
parent2c42fd5f93712bd3cf3b5db2a9581bdc28acdff8
[Sema] Re-land: Diagnose tautological comparison with type's min/max values

The first attempt, rL315614 was reverted because one libcxx
test broke, and i did not know at the time how to deal with it.

Summary:
Currently, clang only diagnoses completely out-of-range comparisons (e.g. `char` and constant `300`),
and comparisons of unsigned and `0`. But gcc also does diagnose the comparisons with the
`std::numeric_limits<>::max()` / `std::numeric_limits<>::min()` so to speak

Finally Fixes https://bugs.llvm.org/show_bug.cgi?id=34147
Continuation of https://reviews.llvm.org/D37565

Reviewers: rjmccall, rsmith, aaron.ballman

Reviewed By: rsmith

Subscribers: rtrieu, jroelofs, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D38101

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@315875 91177308-0d34-0410-b5e6-96231b3b80d8
docs/ReleaseNotes.rst
include/clang/Basic/DiagnosticGroups.td
include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaChecking.cpp
test/Analysis/conversion.c
test/Analysis/null-deref-ps.c
test/Sema/outof-range-constant-compare.c
test/Sema/tautological-constant-compare.c [new file with mode: 0644]
test/Sema/tautological-unsigned-zero-compare.c