aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-04-18 15:09:30 +0000
committerTed Kremenek <kremenek@apple.com>2008-04-18 15:09:30 +0000
commit57cf446d344bb2649e8742cedf1cf4342ed78aa9 (patch)
tree85c3e3ee8d4fceda83f555a38de6be03211f8b42
parentd5e2d87d53bb578a9f99da9aa116b73ade0d31eb (diff)
Compute a digest of each report file, and nuke reports that have the same
digest as a file already added to the index. This a workaround for the analyzer analyzing the same file more than once, which can happen when building multiple targets. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49903 91177308-0d34-0410-b5e6-96231b3b80d8
-rwxr-xr-xutils/scan-build31
1 files changed, 31 insertions, 0 deletions
diff --git a/utils/scan-build b/utils/scan-build
index f6d894b2f2..441f63f1c1 100755
--- a/utils/scan-build
+++ b/utils/scan-build
@@ -116,15 +116,46 @@ sub SetHtmlEnv {
}
##----------------------------------------------------------------------------##
+# ComputeDigest - Compute a digest of the specified file.
+##----------------------------------------------------------------------------##
+
+sub ComputeDigest {
+ my $FName = shift;
+ die "Cannot read $FName" if (! -r $FName);
+ my $Result = `sha1sum -b $FName`;
+ my @Output = split /\s+/,$Result;
+ die "Bad output from sha1sum" if (scalar(@Output) != 2);
+ return $Output[0];
+}
+
+##----------------------------------------------------------------------------##
# ScanFile - Scan a report file for various identifying attributes.
##----------------------------------------------------------------------------##
+# Sometimes a source file is scanned more than once, and thus produces
+# multiple error reports. We use a cache to solve this problem.
+
+my %AlreadyScanned;
+
sub ScanFile {
my $Index = shift;
my $Dir = shift;
my $FName = shift;
+ # Compute a digest for the report file. Determine if we have already
+ # scanned a file that looks just like it.
+
+ my $digest = ComputeDigest("$Dir/$FName");
+
+ if (defined($AlreadyScanned{$digest})) {
+ # Redundant file. Remove it.
+ `rm -f $Dir/$FName`;
+ return;
+ }
+
+ $AlreadyScanned{$digest} = 1;
+
open(IN, "$Dir/$FName") or die "$Prog: Cannot open '$Dir/$FName'\n";
my $BugDesc = "";