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

Anna Zaks via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 1 17:20:09 PDT 2015


zaks.anna added a comment.

This checker produces a lot of warnings! Have you analyzed how many are false positives? Have you tried reporting these warnings?

It's hard to make use of the results you posted from the debian packages. For most of them, I cannot tell if they are valid reports or false positives. For example, why this one is a valid warning:

ftp://ftp.sunet.se/pub/Linux/distributions/Debian/debian/pool/main/a/autotrace/autotrace_0.31.1.orig.tar.gz
output-emf.c:164:9: warning: Loss of precision

  outch = (UI8) (data & 0x0FF);

It might be more useful if you could print the paths on which the errors occurred (this could be done for text output with -analyzer-output=text). Of cause, that assumes that the important information on why the issue occurs is highlighted on the path. (I am not sure if you'll have that without adding a BugReporterVisitor.)

> It seems to me that this checker shows that Clang does not always properly track values. It seems to 

>  think that result of ! can be negative for instance.


What do you mean? I do not see any tests with '!'.


================
Comment at: test/Analysis/conversion.c:54
@@ +53,3 @@
+  for (int i = 0; i < 200; i++) {
+    S = Buf[i];  // RHS is smaller than LHS
+  }
----------------
This is not a good test because the analyzer unrolls loops only a very small number of times.


http://reviews.llvm.org/D13126





More information about the cfe-commits mailing list