Add scan-build option '-no-failure-reports' to supress the creation of a 'failures' subdirectory that includes crash reports, preprocessed files, etc.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77644 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/utils/ccc-analyzer b/utils/ccc-analyzer
index 73cc47b..e8a9f6f 100755
--- a/utils/ccc-analyzer
+++ b/utils/ccc-analyzer
@@ -22,6 +22,10 @@
 
 my $CC = $ENV{'CCC_CC'};
 if (!defined $CC) { $CC = "gcc"; }
+
+my $ReportFailures = $ENV{'CCC_REPORT_FAILURES'};
+if (!defined $ReportFailures) { $ReportFailures = 1; }
+
 my $CleanupFile;
 my $ResultFile;
 
@@ -225,55 +229,57 @@
   my $Result = $?;
 
   # Did the command die because of a signal?
-  if ($Result & 127 and $Cmd eq $ClangCC and defined $HtmlDir) {
-    ProcessClangFailure($ClangCC, $Lang, $file, \@CmdArgsSansAnalyses, $HtmlDir,
-                        "Crash", $ofile);
-  }
-  elsif ($Result) {
-    if ($IncludeParserRejects && !($file =~/conftest/)) {
-      ProcessClangFailure($ClangCC, $Lang, $file, \@CmdArgsSansAnalyses, $HtmlDir,
-                          $ParserRejects, $ofile);
+  if ($ReportFailures) {
+    if ($Result & 127 and $Cmd eq $ClangCC and defined $HtmlDir) {
+      ProcessClangFailure($ClangCC, $Lang, $file, \@CmdArgsSansAnalyses,
+                          $HtmlDir, "Crash", $ofile);
     }
-  }
-  else {
-    # Check if there were any unhandled attributes.
-    if (open(CHILD, $ofile)) {
-      my %attributes_not_handled;
-      
-      # Don't flag warnings about the following attributes that we
-      # know are currently not supported by Clang.
-      $attributes_not_handled{"cdecl"} = 1;
-      
-      my $ppfile;
-      while (<CHILD>) {
-        next if (! /warning: '([^\']+)' attribute ignored/);
-
-        # Have we already spotted this unhandled attribute?
-        next if (defined $attributes_not_handled{$1});
-        $attributes_not_handled{$1} = 1;
-        
-        # Get the name of the attribute file.
-        my $dir = "$HtmlDir/failures";
-        my $afile = "$dir/attribute_ignored_$1.txt";
-        
-        # Only create another preprocessed file if the attribute file
-        # doesn't exist yet.
-        next if (-e $afile);
-        
-        # Add this file to the list of files that contained this attribute.
-        # Generate a preprocessed file if we haven't already.
-        if (!(defined $ppfile)) {
-          $ppfile = ProcessClangFailure($ClangCC, $Lang, $file,
-                                        \@CmdArgsSansAnalyses,
-                                        $HtmlDir, $AttributeIgnored, $ofile);
-        }
-
-        mkpath $dir;
-        open(AFILE, ">$afile");
-        print AFILE "$ppfile\n";
-        close(AFILE);
+    elsif ($Result) {
+      if ($IncludeParserRejects && !($file =~/conftest/)) {
+        ProcessClangFailure($ClangCC, $Lang, $file, \@CmdArgsSansAnalyses,
+                            $HtmlDir, $ParserRejects, $ofile);
       }
-      close CHILD;
+    }
+    else {
+      # Check if there were any unhandled attributes.
+      if (open(CHILD, $ofile)) {
+        my %attributes_not_handled;
+      
+        # Don't flag warnings about the following attributes that we
+        # know are currently not supported by Clang.
+        $attributes_not_handled{"cdecl"} = 1;
+      
+        my $ppfile;
+        while (<CHILD>) {
+          next if (! /warning: '([^\']+)' attribute ignored/);
+
+          # Have we already spotted this unhandled attribute?
+          next if (defined $attributes_not_handled{$1});
+          $attributes_not_handled{$1} = 1;
+        
+          # Get the name of the attribute file.
+          my $dir = "$HtmlDir/failures";
+          my $afile = "$dir/attribute_ignored_$1.txt";
+        
+          # Only create another preprocessed file if the attribute file
+          # doesn't exist yet.
+          next if (-e $afile);
+        
+          # Add this file to the list of files that contained this attribute.
+          # Generate a preprocessed file if we haven't already.
+          if (!(defined $ppfile)) {
+            $ppfile = ProcessClangFailure($ClangCC, $Lang, $file,
+                                          \@CmdArgsSansAnalyses,
+                                          $HtmlDir, $AttributeIgnored, $ofile);
+          }
+
+          mkpath $dir;
+          open(AFILE, ">$afile");
+          print AFILE "$ppfile\n";
+          close(AFILE);
+        }
+        close CHILD;
+      }
     }
   }
   
diff --git a/utils/scan-build b/utils/scan-build
index d766258..acdc4ce 100755
--- a/utils/scan-build
+++ b/utils/scan-build
@@ -959,6 +959,9 @@
                   the 'basic' store model is used. 'region' specifies a field-
                   sensitive store model. Be warned that the 'region' model
                   is still in very early testing phase and may often crash.
+                  
+ -no-failure-reports - Do not create a 'failures' subdirectory that includes
+                       analyzer crash reports and preprocessed source files.
 
 AVAILABLE ANALYSES (multiple analyses may be specified):
 
@@ -1172,6 +1175,11 @@
     $OutputFormat = "plist-html";
     next;
   }
+  
+  if ($arg eq "-no-failure-reports") {
+    $ENV{"CCC_REPORT_FAILURES"} = 0;
+    next;
+  }
 
   DieDiag("unrecognized option '$arg'\n") if ($arg =~ /^-/);