[cfe-commits] r173383 - in /cfe/trunk: tools/scan-build/scan-build utils/analyzer/SATestBuild.py
Jordan Rose
jordan_rose at apple.com
Thu Jan 24 15:07:59 PST 2013
Author: jrose
Date: Thu Jan 24 17:07:59 2013
New Revision: 173383
URL: http://llvm.org/viewvc/llvm-project?rev=173383&view=rev
Log:
scan-build: Add a --keep-empty option for better testing.
SATestBuild expects to compare output directories for each invocation of
scan-build that it runs, but scan-build clears out empty directories by
default. We were coincidentally not getting that behavior until r173294.
Modified:
cfe/trunk/tools/scan-build/scan-build
cfe/trunk/utils/analyzer/SATestBuild.py
Modified: cfe/trunk/tools/scan-build/scan-build
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build/scan-build?rev=173383&r1=173382&r2=173383&view=diff
==============================================================================
--- cfe/trunk/tools/scan-build/scan-build (original)
+++ cfe/trunk/tools/scan-build/scan-build Thu Jan 24 17:07:59 2013
@@ -475,6 +475,7 @@
my $Dir = shift;
my $BaseDir = shift;
my $AnalyzerStats = shift;
+ my $KeepEmpty = shift;
die "No directory specified." if (!defined $Dir);
@@ -488,8 +489,10 @@
closedir(DIR);
if (scalar(@files) == 0 and ! -e "$Dir/failures") {
- Diag("Removing directory '$Dir' because it contains no reports.\n");
- system ("rm", "-fR", $Dir);
+ if (! $KeepEmpty) {
+ Diag("Removing directory '$Dir' because it contains no reports.\n");
+ system ("rm", "-fR", $Dir);
+ }
return 0;
}
@@ -1081,7 +1084,11 @@
scan-build uses the 'clang' executable relative to itself for static
analysis. One can override this behavior with this option by using the
'clang' packaged with Xcode (on OS X) or from the PATH.
-
+
+ --keep-empty
+
+ Don't remove the build results directory even if no issues were reported.
+
CONTROLLING CHECKERS:
A default group of checkers are always run unless explicitly disabled.
@@ -1248,6 +1255,7 @@
my $IgnoreErrors = 0; # Ignore build errors.
my $ViewResults = 0; # View results when the build terminates.
my $ExitStatusFoundBugs = 0; # Exit status reflects whether bugs were found
+my $KeepEmpty = 0; # Don't remove output directory even with 0 results.
my @AnalysesToRun;
my $StoreModel;
my $ConstraintsModel;
@@ -1441,6 +1449,11 @@
$AnalyzerDiscoveryMethod = $1;
next;
}
+ if ($arg eq "--keep-empty") {
+ shift @ARGV;
+ $KeepEmpty = 1;
+ next;
+ }
DieDiag("unrecognized option '$arg'\n") if ($arg =~ /^-/);
@@ -1565,7 +1578,7 @@
}
if ($OutputFormat =~ /html/) {
# Postprocess the HTML directory.
- my $NumBugs = Postprocess($HtmlDir, $BaseDir, $AnalyzerStats);
+ my $NumBugs = Postprocess($HtmlDir, $BaseDir, $AnalyzerStats, $KeepEmpty);
if ($ViewResults and -r "$HtmlDir/index.html") {
Diag "Analysis run complete.\n";
Modified: cfe/trunk/utils/analyzer/SATestBuild.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/SATestBuild.py?rev=173383&r1=173382&r2=173383&view=diff
==============================================================================
--- cfe/trunk/utils/analyzer/SATestBuild.py (original)
+++ cfe/trunk/utils/analyzer/SATestBuild.py Thu Jan 24 17:07:59 2013
@@ -206,6 +206,7 @@
SBOptions = "--use-analyzer " + Clang + " "
SBOptions += "-plist-html -o " + SBOutputDir + " "
SBOptions += "-enable-checker " + Checkers + " "
+ SBOptions += "--keep-empty "
try:
SBCommandFile = open(BuildScriptPath, "r")
SBPrefix = "scan-build " + SBOptions + " "
More information about the cfe-commits
mailing list