From 6e0cbc89471c210c59cd080901b1dfe656db117f Mon Sep 17 00:00:00 2001 From: Alexander Kornienko Date: Fri, 12 Sep 2014 08:53:36 +0000 Subject: Implemented clang-tidy-check-specific options. Summary: Each check can implement readOptions and storeOptions methods to read and store custom options. Each check's options are stored in a local namespace to avoid name collisions and provide some sort of context to the user. Reviewers: bkramer, klimek Reviewed By: klimek Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5296 llvm-svn: 217661 --- clang-tools-extra/clang-tidy/ClangTidyModule.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'clang-tools-extra/clang-tidy/ClangTidyModule.h') diff --git a/clang-tools-extra/clang-tidy/ClangTidyModule.h b/clang-tools-extra/clang-tidy/ClangTidyModule.h index 1134d38..6406d63 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyModule.h +++ b/clang-tools-extra/clang-tidy/ClangTidyModule.h @@ -26,11 +26,13 @@ namespace tidy { /// this object. class ClangTidyCheckFactories { public: + typedef std::function CheckFactory; + /// \brief Registers check \p Factory with name \p Name. /// /// For all checks that have default constructors, use \c registerCheck. - void registerCheckFactory(StringRef Name, - std::function Factory); + void registerCheckFactory(StringRef Name, CheckFactory Factory); /// \brief Registers the \c CheckType with the name \p Name. /// @@ -53,19 +55,21 @@ public: /// } /// }; /// \endcode - template - void registerCheck(StringRef Name) { - registerCheckFactory(Name, []() { return new CheckType(); }); + template void registerCheck(StringRef CheckName) { + registerCheckFactory(CheckName, + [](StringRef Name, ClangTidyContext *Context) { + return new CheckType(Name, Context); + }); } /// \brief Create instances of all checks matching \p CheckRegexString and /// store them in \p Checks. /// /// The caller takes ownership of the return \c ClangTidyChecks. - void createChecks(GlobList &Filter, + void createChecks(ClangTidyContext *Context, std::vector> &Checks); - typedef std::map> FactoryMap; + typedef std::map FactoryMap; FactoryMap::const_iterator begin() const { return Factories.begin(); } FactoryMap::const_iterator end() const { return Factories.end(); } bool empty() const { return Factories.empty(); } -- cgit v1.1