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

Daniel Marjamäki via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 4 03:20:44 PST 2015


danielmarjamaki updated this revision to Diff 41858.
danielmarjamaki added a comment.

Another diff.

This time I have stripped the checker to make it simpler to review, triage, etc.

It will now only warn about loss of precision in assignments when RHS is a variable.

For me, triaging these results are time consuming. It's not obvious at first glance why there is warning. I have tried to strip down the source files to smaller testcases to see where it "goes wrong" and then very often saw that the warning was a TP.

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?


http://reviews.llvm.org/D13126

Files:
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
  test/Analysis/conversion.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13126.41858.patch
Type: text/x-patch
Size: 7783 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151204/098005de/attachment.bin>


More information about the cfe-commits mailing list