[cfe-commits] [Patch] Add new warning for logical not on LHS of comparison
silvas at purdue.edu
Fri Oct 12 09:55:20 PDT 2012
How many lines of code have you compiled with this warning enabled?
How many bugs did it catch?
How many false positives did it have?
-- Sean Silva
On Fri, Oct 12, 2012 at 12:38 PM, Richard Trieu <rtrieu at google.com> wrote:
> This patch is for a new warning to Clang, called -Wlogical-not-compare. It
> is designed to catch the case where the user is attempting to negate a
> comparison, but only manages to negate the LHS because of missing parens.
> For instance, warn here:
> if (!x < 5)
> The user probably meant:
> if (!(x < 5))
> if (x >= 5)
> When emitted, the warning will have a note suggesting this as a fix-it (drop
> the not and inverting the comparison operator).
> Also, a second note will be offer parenthesis around the LHS to silence this
> if ((!x) < 5)
> This will not warn.
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
More information about the cfe-commits