Open Quuxplusone opened 11 years ago
Attached multireport-fastjet.tar.gz
(265041 bytes, application/x-gzip): Scripts that reproduce the behavior; supplementary scripts; results of my test run
This is a result of the analyzer running on a per-translation-unit basis --
there's no information shared across translation units, except for the index
scan-build creates at the end of execution. That means it doesn't actually know
that these issues are "the same".
This is a contentious point: in your case, the errors really are in the header
file, but in many cases the issues are the caller's fault, such as in this
example:
// foo.h
void require(bool *ptr) {
if (!*ptr)
abort();
}
// foo.cpp
void testA() {
require(NULL); // null pointer dereference, caller's fault
}
void testB(bool *ptr) {
if (ptr) // null check, but backwards!
return;
require(ptr); // null pointer dereference, caller's fault
}
There is some support for reporting the issues in the callers rather than in
the header with the hidden analyzer option "report-in-main-source-file=true",
but that won't help your current case. The CmpRuns.py script in the Clang
repository has some support for issue uniquing, but it hasn't been integrated
into scan-build.
scan-build
runs the method ScanFile
on each report HTML file. The method (when called repeatedly) removes the files that are redundant by their binary content (or its MD5 hash, to be more precise). (I suppose that this is the process that reduces the number of reports from 51 to 9.)
However, the 9 HTML reports in question are not exact copies (although they refer to the same bug). They differ in the spelling they use to describe the path to the source file in question ("ClusterSequenceStructure.hh"). For example:
./../../include/fastjet/ClusterSequenceStructure.hh 64c64 <
74c74 <
File: /afs/cern.ch/user/f/fbartek/sas/scanbuild/fastjet-report/fastjet-3.0.4/src/./../include/fastjet/ClusterSequenceStructure.hh File: /afs/cern.ch/user/f/fbartek/sas/scanbuild/fastjet-report/fastjet-3.0.4/plugins/SISCone/./../../include/fastjet/ClusterSequenceStructure.hh
It looks like the HTML reports are generated by clang -analyzer-output=html
called from scan-build
.
I think that a good solution would be cancelling out the "." and ".." parts in the source file paths before they are printed to the HTML reports in clang -analyzer-output=html
.
Would canceling out the "." and ".." unite the reports that are not united in
this case?
As Jordan points out, there are expected cases where we would issue multiple
reports in the same header file.
Yes, I believe that canceling out the "." and (especially) ".." would prevent the duplicity.
multireport-fastjet.tar.gz
(265041 bytes, application/x-gzip)