diff options
author | Alexander Kornienko <alexfh@google.com> | 2014-01-03 09:31:57 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2014-01-03 09:31:57 +0000 |
commit | 031ffc87a994a115ed6a3e01805ddaeb93d630b2 (patch) | |
tree | eea6439d3aa805c5f07a6e1dafe8e24f05fce517 /clang-tidy/ClangTidy.h | |
parent | 3450fcead7f1f9eb78ea591abdf02a613fc2614b (diff) |
Refactored Clang-tidy for better reusability.
Summary:
Made ClangTidyAction more slim and moved its declaration to header to
allow easy creation of Clang-tidy ASTConsumer. Don't derive from
clang::ento::AnalysisAction, use clang::ento::CreateAnalysisConsumer instead
(I'll propose making this function a part of a public API in a separate patch).
Use MultiplexConsumer instead of a custom class.
Don't re-filter checkers list for each TU.
Reviewers: klimek
Reviewed By: klimek
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D2481
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@198402 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clang-tidy/ClangTidy.h')
-rw-r--r-- | clang-tidy/ClangTidy.h | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/clang-tidy/ClangTidy.h b/clang-tidy/ClangTidy.h index 9426c004..677e6e9c 100644 --- a/clang-tidy/ClangTidy.h +++ b/clang-tidy/ClangTidy.h @@ -19,9 +19,6 @@ namespace clang { class CompilerInstance; -namespace ast_matchers { -class MatchFinder; -} namespace tooling { class CompilationDatabase; } @@ -96,17 +93,38 @@ private: llvm::Regex DisableChecks; }; +class ClangTidyCheckFactories; + +class ClangTidyASTConsumerFactory { +public: + ClangTidyASTConsumerFactory(StringRef EnableChecksRegex, + StringRef DisableChecksRegex, + ClangTidyContext &Context); + ~ClangTidyASTConsumerFactory(); + + /// \brief Returns an ASTConsumer that runs the specified clang-tidy checks. + clang::ASTConsumer *CreateASTConsumer(clang::CompilerInstance &Compiler, + StringRef File); + + /// \brief Get the list of enabled checks. + std::vector<std::string> getCheckNames(); + +private: + typedef std::vector<std::pair<std::string, bool> > CheckersList; + CheckersList getCheckersControlList(); + + ChecksFilter Filter; + SmallVector<ClangTidyCheck *, 8> Checks; + ClangTidyContext &Context; + ast_matchers::MatchFinder Finder; + OwningPtr<ClangTidyCheckFactories> CheckFactories; +}; + /// \brief Fills the list of check names that are enabled when the provided /// filters are applied. std::vector<std::string> getCheckNames(StringRef EnableChecksRegex, StringRef DisableChecksRegex); -/// \brief Returns an action factory that runs the specified clang-tidy checks. -tooling::FrontendActionFactory * -createClangTidyActionFactory(StringRef EnableChecksRegex, - StringRef DisableChecksRegex, - ClangTidyContext &Context); - /// \brief Run a set of clang-tidy checks on a set of files. void runClangTidy(StringRef EnableChecksRegex, StringRef DisableChecksRegex, const tooling::CompilationDatabase &Compilations, |