diff options
author | Alexander Kornienko <alexfh@google.com> | 2014-09-12 08:53:36 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2014-09-12 08:53:36 +0000 |
commit | fa2f5e82a004d9737d33be5374eb1a4c48d00431 (patch) | |
tree | 0eb122a85f036dcc824bd8a87b82447e2a8016e5 /clang-tidy/ClangTidyModule.h | |
parent | 68f0293a66c614cdfd60634e1cf76453a964c50c (diff) |
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
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@217661 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clang-tidy/ClangTidyModule.h')
-rw-r--r-- | clang-tidy/ClangTidyModule.h | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/clang-tidy/ClangTidyModule.h b/clang-tidy/ClangTidyModule.h index 1134d380..6406d636 100644 --- a/clang-tidy/ClangTidyModule.h +++ b/clang-tidy/ClangTidyModule.h @@ -26,11 +26,13 @@ namespace tidy { /// this object. class ClangTidyCheckFactories { public: + typedef std::function<ClangTidyCheck *( + StringRef Name, ClangTidyContext *Context)> 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<ClangTidyCheck *()> Factory); + void registerCheckFactory(StringRef Name, CheckFactory Factory); /// \brief Registers the \c CheckType with the name \p Name. /// @@ -53,19 +55,21 @@ public: /// } /// }; /// \endcode - template<typename CheckType> - void registerCheck(StringRef Name) { - registerCheckFactory(Name, []() { return new CheckType(); }); + template <typename CheckType> 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<std::unique_ptr<ClangTidyCheck>> &Checks); - typedef std::map<std::string, std::function<ClangTidyCheck *()>> FactoryMap; + typedef std::map<std::string, CheckFactory> FactoryMap; FactoryMap::const_iterator begin() const { return Factories.begin(); } FactoryMap::const_iterator end() const { return Factories.end(); } bool empty() const { return Factories.empty(); } |