]> granicus.if.org Git - clang/commitdiff
[analyzer] Fix scan-build's -stats mode.
authorJordan Rose <jordan_rose@apple.com>
Thu, 14 Mar 2013 17:18:30 +0000 (17:18 +0000)
committerJordan Rose <jordan_rose@apple.com>
Thu, 14 Mar 2013 17:18:30 +0000 (17:18 +0000)
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

test/Analysis/analyzer-stats.c
tools/scan-build/scan-build

index 9eeaade793c2721f6bc3e68acf4b068a07e5ce74..63073b7e40b3fcee2c3df7bba9d8dbfc98678771 100644 (file)
@@ -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;
 
index 4965dbdc7a8d0ca550cf4a521cd3f698ca00f692..ff82e129d10f07097283c22e32231e57b681f276 100755 (executable)
@@ -284,10 +284,11 @@ sub UpdateInFilePath {
 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 @@ sub AddStatLine {
 
   # 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 @@ sub ScanFile {
 
   # Don't add internal statistics to the bug reports
   if ($BugCategory =~ /statistics/i) {
-    AddStatLine($BugDescription, $Stats);
+    AddStatLine($BugDescription, $Stats, $BugFile);
     return;
   }