]> granicus.if.org Git - clang/commit
Warn on unsigned zero in call to std::max
authorRichard Trieu <rtrieu@google.com>
Mon, 5 Dec 2016 23:41:46 +0000 (23:41 +0000)
committerRichard Trieu <rtrieu@google.com>
Mon, 5 Dec 2016 23:41:46 +0000 (23:41 +0000)
commit40adebeca0f99006d407508653c2cbd270a1a51c
tree2a72637d3c9e2d35da6d19c970d50891e53b2de6
parentda013e4587afd58526c341bb94213dfb08eda1e8
Warn on unsigned zero in call to std::max

New default warning that triggers when an unsigned zero is used in a call to
std::max.  For unsigned values, zero is the minimum value, so any call to
std::max is always equal to the other value.  A common pattern was to take
the max of zero and the difference of two unsigned values, not taking into
account that unsigned values wrap around below zero.  This warning also emits
a note with a fixit hint to remove the zero and call to std::max.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@288732 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Basic/DiagnosticGroups.td
include/clang/Basic/DiagnosticSemaKinds.td
include/clang/Sema/Sema.h
lib/Sema/SemaChecking.cpp