[PATCH] D13126: New static analyzer checker for loss of sign/precision

Daniel Marjamäki via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 7 01:01:45 PST 2015


danielmarjamaki marked 2 inline comments as done.
danielmarjamaki added a comment.

In http://reviews.llvm.org/D13126#302647, @dcoughlin wrote:

> In http://reviews.llvm.org/D13126#302328, @danielmarjamaki wrote:
>
> > When scanning 692 projects with this checker I got 56 warnings. I've triaged 21 random warnings of these so far and saw 20 TP and 1 FP.
> >
> > When I have triaged the results there is one kind of "possible FP" that I see, like this:
> >
> >   unsigned long x = largevalue;
> >   bytes[0] = x;  // Possible FP here. Technically it's a TP but it's an loss of precision by design.
> >   bytes[1] = x >> 8;
> >   ....
> >   
> >
> > I am currently considering to allow this FP. Any opinions about allowing it?
>
>
> Is there mechanism by which the user can suppress false positives like this (for example, an explicit cast)?


Yes it can be suppressed using for instance "x & 0xff" or "(unsigned char)x".

The checker could hide the warning if the previous or next statement is "somevar = x >> 8". I don't think that would cause any significant FN. However I still consider to write the "FP".


================
Comment at: test/Analysis/conversion.c:23
@@ +22,2 @@
+  U8 = S+10;
+}
----------------
it was removed


http://reviews.llvm.org/D13126





More information about the cfe-commits mailing list