From a27ae544f30bfd7dc765b8a6080190d39d893b99 Mon Sep 17 00:00:00 2001 From: Richard Trieu Date: Sat, 19 Oct 2019 00:57:23 +0000 Subject: New tautological warning for bitwise-or with non-zero constant always true. Taking a value and the bitwise-or it with a non-zero constant will always result in a non-zero value. In a boolean context, this is always true. if (x | 0x4) {} // always true, intended '&' This patch creates a new warning group -Wtautological-bitwise-compare for this warning. It also moves in the existing tautological bitwise comparisons into this group. A few other changes were needed to the CFGBuilder so that all bool contexts would be checked. The warnings in -Wtautological-bitwise-compare will be off by default due to using the CFG. Fixes: https://bugs.llvm.org/show_bug.cgi?id=42666 Differential Revision: https://reviews.llvm.org/D66046 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@375318 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/ReleaseNotes.rst | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'docs') diff --git a/docs/ReleaseNotes.rst b/docs/ReleaseNotes.rst index 37dbac3090..41dea299e6 100644 --- a/docs/ReleaseNotes.rst +++ b/docs/ReleaseNotes.rst @@ -56,6 +56,11 @@ Improvements to Clang's diagnostics - -Wtautological-compare for self comparisons and -Wtautological-overlap-compare will now look through member and array access to determine if two operand expressions are the same. +- -Wtautological-bitwise-compare is a new warning group. This group has the + current warning which diagnoses the tautological comparison of a bitwise + operation and a constant. The group also has the new warning which diagnoses + when a bitwise-or with a non-negative value is converted to a bool, since + that bool will always be true. Non-comprehensive list of changes in this release ------------------------------------------------- -- cgit v1.2.1