[analyzer] Add -analyzer-stats, which hooks up LLVM stats tracking.

As in http://llvm.org/docs/ProgrammersManual.html#Statistic

llvm-svn: 151570
This commit is contained in:
Anna Zaks 2012-02-27 21:33:16 +00:00
parent 84e6e5cd1a
commit b028654031
5 changed files with 14 additions and 0 deletions

View 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">;

View 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;
}
};

View 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,

View 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);

View File

@ -0,0 +1,6 @@
// RUN: %clang_cc1 -analyze -analyzer-stats %s 2> FileCheck
void foo() {
;
}
// CHECK: ... Statistics Collected ...