]> granicus.if.org Git - clang/commitdiff
[analyzer] Add -analyzer-stats, which hooks up LLVM stats tracking.
authorAnna Zaks <ganna@apple.com>
Mon, 27 Feb 2012 21:33:16 +0000 (21:33 +0000)
committerAnna Zaks <ganna@apple.com>
Mon, 27 Feb 2012 21:33:16 +0000 (21:33 +0000)
As in http://llvm.org/docs/ProgrammersManual.html#Statistic

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151570 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/CC1Options.td
include/clang/Frontend/AnalyzerOptions.h
lib/Frontend/CompilerInvocation.cpp
lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
test/Analysis/stats.c [new file with mode: 0644]

index b885288baeba279a0555de5fca90c727be53efff..9789a85da7b2293d80224a069f3d4a04f2693e52 100644 (file)
@@ -86,6 +86,8 @@ def analyzer_max_nodes : Separate<"-analyzer-max-nodes">,
   HelpText<"The maximum number of nodes the analyzer can generate (150000 default, 0 = no limit)">;
 def analyzer_max_loop : Separate<"-analyzer-max-loop">,
   HelpText<"The maximum number of times the analyzer will go through a loop">;
+def analyzer_stats : Flag<"-analyzer-stats">,
+  HelpText<"Print internal analyzer statistics.">;
 
 def analyzer_checker : Separate<"-analyzer-checker">,
   HelpText<"Choose analyzer checkers to enable">;
index 3565a51d0751bad17cbeeacbc40cc1148a326bb1..66d0c37777817f3955e101a3ccb975c7315cc72e 100644 (file)
@@ -84,6 +84,7 @@ public:
   unsigned CFGAddImplicitDtors : 1;
   unsigned CFGAddInitializers : 1;
   unsigned EagerlyTrimEGraph : 1;
+  unsigned PrintStats : 1;
 
 public:
   AnalyzerOptions() {
@@ -104,6 +105,7 @@ public:
     CFGAddImplicitDtors = 0;
     CFGAddInitializers = 0;
     EagerlyTrimEGraph = 0;
+    PrintStats = 0;
   }
 };
 
index 862a6547f829e4d4d1cd53f8702b26ceeff76ea4..c46c52c7bdd239eca2891c5e263100420ee7cb61 100644 (file)
@@ -1043,6 +1043,7 @@ static bool ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,
   Opts.MaxLoop = Args.getLastArgIntValue(OPT_analyzer_max_loop, 4, Diags);
   Opts.EagerlyTrimEGraph = !Args.hasArg(OPT_analyzer_no_eagerly_trim_egraph);
   Opts.InlineCall = Args.hasArg(OPT_analyzer_inline_call);
+  Opts.PrintStats = Args.hasArg(OPT_analyzer_stats);
 
   Opts.CheckersControlList.clear();
   for (arg_iterator it = Args.filtered_begin(OPT_analyzer_checker,
index 93c879ee96ae4694ce7cdd7b47f70dd91c553613..074ad23ce4653f313780ab280da7e7176785b291 100644 (file)
@@ -35,6 +35,7 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
 #include "llvm/ADT/OwningPtr.h"
+#include "llvm/ADT/Statistic.h"
 
 using namespace clang;
 using namespace ento;
@@ -157,6 +158,8 @@ public:
                                   Opts.UnoptimizedCFG, Opts.CFGAddImplicitDtors,
                                   Opts.CFGAddInitializers,
                                   Opts.EagerlyTrimEGraph));
+    if (Opts.PrintStats)
+      llvm::EnableStatistics();
   }
 
   virtual void HandleTranslationUnit(ASTContext &C);
diff --git a/test/Analysis/stats.c b/test/Analysis/stats.c
new file mode 100644 (file)
index 0000000..004ed3f
--- /dev/null
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -analyze -analyzer-stats %s 2> FileCheck
+
+void foo() {
+  ;
+}
+// CHECK: ... Statistics Collected ...