summaryrefslogtreecommitdiffstats
path: root/clang
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
commitb18179da33f61fdc763f518832642b75e3b9bfec (patch)
treebcff9292b253b5beb31e7d08c3fce4816946cf96 /clang
parentd4c392e6ff5f63e1ec5615ebb82c7037dd7e7b5d (diff)
downloadbcm5719-llvm-b18179da33f61fdc763f518832642b75e3b9bfec.tar.gz
bcm5719-llvm-b18179da33f61fdc763f518832642b75e3b9bfec.zip
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. llvm-svn: 173383
Diffstat (limited to 'clang')
-rwxr-xr-xclang/tools/scan-build/scan-build21
-rwxr-xr-xclang/utils/analyzer/SATestBuild.py1
2 files changed, 18 insertions, 4 deletions
diff --git a/clang/tools/scan-build/scan-build b/clang/tools/scan-build/scan-build
index 20b85a06d7b..16ce931c99a 100755
--- a/clang/tools/scan-build/scan-build
+++ b/clang/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/clang/utils/analyzer/SATestBuild.py b/clang/utils/analyzer/SATestBuild.py
index 36199cb281a..067be162e27 100755
--- a/clang/utils/analyzer/SATestBuild.py
+++ b/clang/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 + " "
OpenPOWER on IntegriCloud