scan-build/ccc-analyzer now also report clang parser failures.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54931 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/utils/ccc-analyzer b/utils/ccc-analyzer
index fd24a8b..ad7b412 100755
--- a/utils/ccc-analyzer
+++ b/utils/ccc-analyzer
@@ -28,18 +28,19 @@
   return ".i";
 }
 
-sub ProcessClangCrash {
-  my ($Clang, $Lang, $file, $Args, $HtmlDir) = @_;
+sub ProcessClangFailure {
+  my ($Lang, $file, $Args, $HtmlDir, $ErrorType) = @_;
   my $Dir = "$HtmlDir/crashes";
   mkpath $Dir;
   my ($PPH, $PPFile) = tempfile("clang_crash_XXXXXX",
                                   SUFFIX => GetPPExt($Lang),
                                   DIR => $Dir);
 
-  system $Clang, @$Args, "-E", "-o", $PPFile;  
+  system "gcc", @$Args, "-E", "-o", $PPFile;  
   close ($PPH);
   open (OUT, ">", "$PPFile.info") or die "Cannot open $PPFile.info\n";
-  print OUT "$file";
+  print OUT "$file\n";
+  print OUT "$ErrorType\n";
   close OUT;
 }
 
@@ -52,7 +53,7 @@
 
   # Skip anything related to C++.
   return if ($Lang =~ /c[+][+]/);
-  
+
   my $RunAnalyzer = 0;
   my $Cmd;
   my @CmdArgs;
@@ -105,7 +106,12 @@
 
    # Did the command die because of a signal?
    if ($? & 127 and $Cmd eq $Clang and defined $HtmlDir) {
-     ProcessClangCrash($Clang, $Lang, $file, \@CmdArgsSansAnalyses, $HtmlDir);
+     ProcessClangFailure($Lang, $file, \@CmdArgsSansAnalyses, $HtmlDir,
+                          "Crash");
+   }
+   elsif ($?) {
+     ProcessClangFailure($Lang, $file, \@CmdArgsSansAnalyses, $HtmlDir,
+                          "Parser Rejects");
    }
 }
 
diff --git a/utils/scan-build b/utils/scan-build
index 9004b35..44c2db3 100755
--- a/utils/scan-build
+++ b/utils/scan-build
@@ -567,12 +567,12 @@
 
     if (scalar(@files)) {
       print OUT <<ENDTEXT;
-<h3>Analyzer Crashes</h3>
+<h3>Analyzer Failures</h3>
 
-<p>The analyzer crashed while processing the following files:</p>
+<p>The analyzer had problems processing the following files:</p>
 
 <table>
-<thead><tr><td>Source File</td><td>Preprocessed File</td></tr></thead>
+<thead><tr><td>Problem</td><td>Source File</td><td>Preprocessed File</td></tr></thead>
 ENDTEXT
   
       foreach my $file (sort @files) {
@@ -583,9 +583,12 @@
         open (INFO, "$Dir/crashes/$file") or
           die "Cannot open $Dir/crashes/$file\n";
         my $srcfile = <INFO>;
+        chomp $srcfile;
+        my $problem = <INFO>;
+        chomp $problem;
         close (INFO);
         # Print the information in the table.
-        print OUT "<tr><td>$srcfile</td><td class=\"View\"><a href=\"crashes/$ppfile\">View</a></td></tr>\n";
+        print OUT "<tr><td>$problem</td><td>$srcfile</td><td class=\"View\"><a href=\"crashes/$ppfile\">View</a></td></tr>\n";
       }
 
       print OUT <<ENDTEXT;