[analyzer]scan-build: report the total number of steps analyzer performs

This would be useful to investigate performance issues.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159038 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/scan-build/ccc-analyzer b/tools/scan-build/ccc-analyzer
index 86a3616..b8f7193 100755
--- a/tools/scan-build/ccc-analyzer
+++ b/tools/scan-build/ccc-analyzer
@@ -438,6 +438,9 @@
 # Get the constraints engine.
 my $ConstraintsModel = $ENV{'CCC_ANALYZER_CONSTRAINTS_MODEL'};
 
+#Get the internal stats setting.
+my $InternalStats = $ENV{'CCC_ANALYZER_INTERNAL_STATS'};
+
 # Get the output format.
 my $OutputFormat = $ENV{'CCC_ANALYZER_OUTPUT_FORMAT'};
 if (!defined $OutputFormat) { $OutputFormat = "html"; }
@@ -642,6 +645,10 @@
     if (defined $ConstraintsModel) {
       push @AnalyzeArgs, "-analyzer-constraints=$ConstraintsModel";
     }
+
+    if (defined $InternalStats) {
+      push @AnalyzeArgs, "-analyzer-stats";
+    }
     
     if (defined $Analyses) {
       push @AnalyzeArgs, split '\s+', $Analyses;
diff --git a/tools/scan-build/scan-build b/tools/scan-build/scan-build
index 7bcd5c2..424e15a 100755
--- a/tools/scan-build/scan-build
+++ b/tools/scan-build/scan-build
@@ -1025,7 +1025,8 @@
  -maxloop N - specifiy the number of times a block can be visited before giving
               up. Default is 4. Increase for more comprehensive coverage at a
               cost of speed.
-
+ -internal-stats - Generate internal analyzer statistics.
+ 
 CONTROLLING CHECKERS:
 
  A default group of checkers are always run unless explicitly disabled.
@@ -1194,6 +1195,7 @@
 my @AnalysesToRun;
 my $StoreModel;
 my $ConstraintsModel;
+my $InternalStats;
 my $OutputFormat = "html";
 my $AnalyzerStats = 0;
 my $MaxLoop = 0;
@@ -1325,6 +1327,12 @@
     $ConstraintsModel = shift @ARGV;
     next;
   }
+
+  if ($arg eq "-internal-stats") {
+    shift @ARGV;
+    $InternalStats = 1;
+    next;
+  }
   
   if ($arg eq "-plist") {
     shift @ARGV;
@@ -1442,6 +1450,9 @@
 if (defined $ConstraintsModel) {
   $ENV{'CCC_ANALYZER_CONSTRAINTS_MODEL'} = $ConstraintsModel;
 }
+if (defined $InternalStats) {
+  $ENV{'CCC_ANALYZER_INTERNAL_STATS'} = 1;
+}
 if (defined $OutputFormat) {
   $ENV{'CCC_ANALYZER_OUTPUT_FORMAT'} = $OutputFormat;
 }