r183688 - Add a new warning, -Wlogical-not-parentheses, to -Wparentheses.

Richard Trieu rtrieu at google.com
Tue Jun 11 12:01:44 PDT 2013


Thanks for the info, Sean.  It's always nice to see my work in action.


On Tue, Jun 11, 2013 at 9:41 AM, Sean McBride <sean at rogue-research.com>wrote:

> Hi,
>
> I updated clang on my buildbot that builds the open source VTK project and
> it reported 4 unique -Wlogical-not-parentheses warnings:
> <http://open.cdash.org/viewBuildError.php?type=1&buildid=2933590>
>
> I consider them to all be valid warnings either because the code really is
> wrong or could be made clearer anyway.
>
> My (hopefully correct) patch for VTK:
> <http://review.source.kitware.com/11566>
>
> hth,
>
> Sean
>
>
>
> On Mon, 10 Jun 2013 13:22:18 -0700, Nico Weber said:
>
> >Do you have numbers on the true positive rate of this new warning (give
> >that it's on by default)?
> >
> >
> >On Mon, Jun 10, 2013 at 11:52 AM, Richard Trieu <rtrieu at google.com>
> wrote:
> >
> >> Author: rtrieu
> >> Date: Mon Jun 10 13:52:07 2013
> >> New Revision: 183688
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=183688&view=rev
> >> Log:
> >> Add a new warning, -Wlogical-not-parentheses, to -Wparentheses.
> >>
> >> This warning triggers on the logical not of a non-boolean expression on
> the
> >> left hand side of comparison.  Often, the user meant to negate the
> >> comparison,
> >> not just the left hand side of the comparison.  Two notes are also
> emitted,
> >> the first with a fix-it to add parentheses around the comparison, and
> the
> >> other
> >> to put parenthesis around the not expression to silence the warning.
> >>
> >> bool not_equal(int x, int y) {
> >>   return !x == y;  // warn here
> >> }
> >>
> >>   return !(x == y);  // first fix-it, to negate comparison.
> >>
> >>   return (!x) == y;  // second fix-it, to silence warning.
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130611/bb8e185a/attachment.html>


More information about the cfe-commits mailing list