[cfe-commits] r151570 - in /cfe/trunk: include/clang/Driver/CC1Options.td include/clang/Frontend/AnalyzerOptions.h lib/Frontend/CompilerInvocation.cpp lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp test/Analysis/stats.c
Anna Zaks
ganna at apple.com
Mon Feb 27 13:33:16 PST 2012
Author: zaks
Date: Mon Feb 27 15:33:16 2012
New Revision: 151570
URL: http://llvm.org/viewvc/llvm-project?rev=151570&view=rev
Log:
[analyzer] Add -analyzer-stats, which hooks up LLVM stats tracking.
As in http://llvm.org/docs/ProgrammersManual.html#Statistic
Added:
cfe/trunk/test/Analysis/stats.c
Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Frontend/AnalyzerOptions.h
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=151570&r1=151569&r2=151570&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Feb 27 15:33:16 2012
@@ -86,6 +86,8 @@
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">;
Modified: cfe/trunk/include/clang/Frontend/AnalyzerOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/AnalyzerOptions.h?rev=151570&r1=151569&r2=151570&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/AnalyzerOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/AnalyzerOptions.h Mon Feb 27 15:33:16 2012
@@ -84,6 +84,7 @@
unsigned CFGAddImplicitDtors : 1;
unsigned CFGAddInitializers : 1;
unsigned EagerlyTrimEGraph : 1;
+ unsigned PrintStats : 1;
public:
AnalyzerOptions() {
@@ -104,6 +105,7 @@
CFGAddImplicitDtors = 0;
CFGAddInitializers = 0;
EagerlyTrimEGraph = 0;
+ PrintStats = 0;
}
};
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=151570&r1=151569&r2=151570&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Feb 27 15:33:16 2012
@@ -1043,6 +1043,7 @@
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,
Modified: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp?rev=151570&r1=151569&r2=151570&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp Mon Feb 27 15:33:16 2012
@@ -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 @@
Opts.UnoptimizedCFG, Opts.CFGAddImplicitDtors,
Opts.CFGAddInitializers,
Opts.EagerlyTrimEGraph));
+ if (Opts.PrintStats)
+ llvm::EnableStatistics();
}
virtual void HandleTranslationUnit(ASTContext &C);
Added: cfe/trunk/test/Analysis/stats.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/stats.c?rev=151570&view=auto
==============================================================================
--- cfe/trunk/test/Analysis/stats.c (added)
+++ cfe/trunk/test/Analysis/stats.c Mon Feb 27 15:33:16 2012
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -analyze -analyzer-stats %s 2> FileCheck
+
+void foo() {
+ ;
+}
+// CHECK: ... Statistics Collected ...
More information about the cfe-commits
mailing list