[analyzer] Fix scan-build's -stats mode.

We were failing to match the output line, which led to us collecting no
stats at all, which led to a divide-by-zero error.

Fixes PR15510.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177084 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Analysis/analyzer-stats.c b/test/Analysis/analyzer-stats.c
index 9eeaade..63073b7 100644
--- a/test/Analysis/analyzer-stats.c
+++ b/test/Analysis/analyzer-stats.c
@@ -2,7 +2,7 @@
 
 int foo();
 
-int test() { // expected-warning{{Total CFGBlocks}}
+int test() { // expected-warning-re{{test -> Total CFGBlocks: [0-9]+ \| Unreachable CFGBlocks: 0 \| Exhausted Block: no \| Empty WorkList: yes}}
   int a = 1;
   a = 34 / 12;
 
diff --git a/tools/scan-build/scan-build b/tools/scan-build/scan-build
index 4965dbd..ff82e12 100755
--- a/tools/scan-build/scan-build
+++ b/tools/scan-build/scan-build
@@ -284,10 +284,11 @@
 sub AddStatLine {
   my $Line  = shift;
   my $Stats = shift;
+  my $File  = shift;
 
   print $Line . "\n";
 
-  my $Regex = qr/(.*?)\ :\ (.*?)\ ->\ Total\ CFGBlocks:\ (\d+)\ \|\ Unreachable
+  my $Regex = qr/(.*?)\ ->\ Total\ CFGBlocks:\ (\d+)\ \|\ Unreachable
       \ CFGBlocks:\ (\d+)\ \|\ Exhausted\ Block:\ (yes|no)\ \|\ Empty\ WorkList:
       \ (yes|no)/x;
 
@@ -297,12 +298,12 @@
 
   # Create a hash of the interesting fields
   my $Row = {
-    Filename    => $1,
-    Function    => $2,
-    Total       => $3,
-    Unreachable => $4,
-    Aborted     => $5,
-    Empty       => $6
+    Filename    => $File,
+    Function    => $1,
+    Total       => $2,
+    Unreachable => $3,
+    Aborted     => $4,
+    Empty       => $5
   };
 
   # Add them to the stats array
@@ -383,7 +384,7 @@
 
   # Don't add internal statistics to the bug reports
   if ($BugCategory =~ /statistics/i) {
-    AddStatLine($BugDescription, $Stats);
+    AddStatLine($BugDescription, $Stats, $BugFile);
     return;
   }