[PATCH] check for Incorrect logic in operator

Richard Trieu rtrieu at google.com
Fri Oct 25 16:42:46 PDT 2013


A few high level comments.

"-fblocks -Wunreachable-code" is there any reason your test cases have
these flags?
"if (!x == 10) {}" there is an existing warning for this called
-Wlogical-not-parentheses.  The check should be folded into there.
"if ((x < y) == 10) {}" ditto this and -Wtautological-compare-out-of-range
"logical disjunction always evaluates to true"  I wouldn't expect all
programmers to understand what a logical disjunction is.

If you check out -Wlogical-not-parentheses and
-Wtautological-compare-out-of-range, they are in lib/Sema/SemaChecking.cpp.
 Why did you use a CFG approach instead?


On Fri, Oct 25, 2013 at 10:18 AM, Jordan Rose <jordan_rose at apple.com> wrote:

> Richard Trieu has worked on a number of similar warnings. Maybe he can
> take a look?
>
> Jordan
>
>
> On Oct 25, 2013, at 8:18, Anders Rönnholm <Anders.Ronnholm at evidente.se>
> wrote:
>
> > Hi,
> > Resending the patch I sent last week. Anyone want to have a look at it?
> >
> > //Anders
> >
> > -----Original Message-----
> > From: Anders Rönnholm
> > Sent: den 18 oktober 2013 16:05
> > To: cfe-commits at cs.uiuc.edu
> > Subject: [PATCH] check for Incorrect logic in operator
> >
> > Hi,
> >
> > I have a new patch I like to get reviewed. It checks for incorrect
> logics in relational,equal and logic operators in cfgbuilder when trying to
> evaluate bool. A warning is emitted in Sema when an error occurs.
> >
> > eg.
> > if (x != 2 || x != 3) { } always true
> > if ((x < y) <= 10) {}  always true
> >
> > Thanks,
> > Anders
> >
> <incorrectoperatorlogic.diff>_______________________________________________
> > cfe-commits mailing list
> > cfe-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131025/e822f229/attachment.html>


More information about the cfe-commits mailing list