aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2013-01-24 23:07:59 +0000
committerJordan Rose <jordan_rose@apple.com>2013-01-24 23:07:59 +0000
commit33e9500784a6b8dc7f01ae5c85ebf0883fbc6662 (patch)
tree0ac9f39127fa8e74a18ed09676db3f75b2722ab6
parent75c12bf46d5175060d0adeab992a886f22ef7ef8 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173383 91177308-0d34-0410-b5e6-96231b3b80d8
-rwxr-xr-xtools/scan-build/scan-build21
-rwxr-xr-xutils/analyzer/SATestBuild.py1
2 files changed, 18 insertions, 4 deletions
diff --git a/tools/scan-build/scan-build b/tools/scan-build/scan-build
index 20b85a06d7..16ce931c99 100755
--- a/tools/scan-build/scan-build
+++ b/tools/scan-build/scan-build
@@ -475,6 +475,7 @@ sub Postprocess {
my $Dir = shift;
my $BaseDir = shift;
my $AnalyzerStats = shift;
+ my $KeepEmpty = shift;
die "No directory specified." if (!defined $Dir);
@@ -488,8 +489,10 @@ sub Postprocess {
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 @@ ADVANCED OPTIONS:
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 $HtmlDir; # Parent directory to store HTML files.
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 @@ while (@ARGV) {
$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 (defined $OutputFormat) {
}
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";
diff --git a/utils/analyzer/SATestBuild.py b/utils/analyzer/SATestBuild.py
index 36199cb281..067be162e2 100755
--- a/utils/analyzer/SATestBuild.py
+++ b/utils/analyzer/SATestBuild.py
@@ -206,6 +206,7 @@ def runScanBuild(Dir, SBOutputDir, PBuildLogFile):
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 + " "