summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/ClangTidy.cpp
diff options
context:
space:
mode:
authorSamuel Benzaquen <sbenza@google.com>2014-10-23 17:23:20 +0000
committerSamuel Benzaquen <sbenza@google.com>2014-10-23 17:23:20 +0000
commitaedd994560e8714127a244f57d8a01474082c3f0 (patch)
treeb0c61a849a356e14786716619e19ce86ac7c868b /clang-tools-extra/clang-tidy/ClangTidy.cpp
parentadffd01498bbbe16a9bc63009cdbd62954c3fa8b (diff)
downloadbcm5719-llvm-aedd994560e8714127a244f57d8a01474082c3f0.tar.gz
bcm5719-llvm-aedd994560e8714127a244f57d8a01474082c3f0.zip
Add flag --enable-check-profile to clang-tidy.
Summary: Add flag --enable-check-profile to clang-tidy. It turns on per-matcher profiles in MatchFinder and prints a report to stderr at the end. Reviewers: alexfh Subscribers: curdeius, cfe-commits Differential Revision: http://reviews.llvm.org/D5937 llvm-svn: 220491
Diffstat (limited to 'clang-tools-extra/clang-tidy/ClangTidy.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/ClangTidy.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index 0712f69e9fd..b8afc08d784 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -216,8 +216,13 @@ ClangTidyASTConsumerFactory::CreateASTConsumer(
std::vector<std::unique_ptr<ClangTidyCheck>> Checks;
CheckFactories->createChecks(&Context, Checks);
+ ast_matchers::MatchFinder::MatchFinderOptions FinderOptions;
+ if (auto *P = Context.getCheckProfileData())
+ FinderOptions.CheckProfiling.emplace(P->Records);
+
std::unique_ptr<ast_matchers::MatchFinder> Finder(
- new ast_matchers::MatchFinder);
+ new ast_matchers::MatchFinder(std::move(FinderOptions)));
+
for (auto &Check : Checks) {
Check->registerMatchers(&*Finder);
Check->registerPPCallbacks(Compiler);
@@ -356,9 +361,12 @@ ClangTidyStats
runClangTidy(std::unique_ptr<ClangTidyOptionsProvider> OptionsProvider,
const tooling::CompilationDatabase &Compilations,
ArrayRef<std::string> InputFiles,
- std::vector<ClangTidyError> *Errors) {
+ std::vector<ClangTidyError> *Errors, ProfileData *Profile) {
ClangTool Tool(Compilations, InputFiles);
clang::tidy::ClangTidyContext Context(std::move(OptionsProvider));
+ if (Profile)
+ Context.setCheckProfileData(Profile);
+
ClangTidyDiagnosticConsumer DiagConsumer(Context);
Tool.setDiagnosticConsumer(&DiagConsumer);
OpenPOWER on IntegriCloud