[cfe-commits] [Patch] Add new warning for logical not on LHS of comparison
Richard Trieu
rtrieu at google.com
Fri Oct 12 09:38:29 PDT 2012
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))
or
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 warning.
if ((!x) < 5)
This will not warn.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121012/d25edb42/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: logical-not-compare.patch
Type: application/octet-stream
Size: 6780 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121012/d25edb42/attachment.obj>
More information about the cfe-commits
mailing list