aboutsummaryrefslogtreecommitdiff
path: root/clang-tidy/ClangTidyModule.h
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2014-09-10 11:06:43 +0000
committerAlexander Kornienko <alexfh@google.com>2014-09-10 11:06:43 +0000
commit5787fcf8445673ead21f77d64bfe9a39f38b22de (patch)
tree48da7e20ac49e9aa98eae5bcde69f8206dda1dc4 /clang-tidy/ClangTidyModule.h
parent1362217834629c9d4d334f8e5448731e04fc5ba1 (diff)
Unique-ptrify ClangTidyCheckFactories. Add a more convenient alternative to
addCheckFactory: registerCheck. Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5288 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@217489 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clang-tidy/ClangTidyModule.h')
-rw-r--r--clang-tidy/ClangTidyModule.h18
1 files changed, 11 insertions, 7 deletions
diff --git a/clang-tidy/ClangTidyModule.h b/clang-tidy/ClangTidyModule.h
index c9c51438..9580ce9a 100644
--- a/clang-tidy/ClangTidyModule.h
+++ b/clang-tidy/ClangTidyModule.h
@@ -74,13 +74,17 @@ public:
/// this object.
class ClangTidyCheckFactories {
public:
- ClangTidyCheckFactories() {}
- ~ClangTidyCheckFactories();
-
/// \brief Register \p Factory with the name \p Name.
- ///
- /// The \c ClangTidyCheckFactories object takes ownership of the \p Factory.
- void addCheckFactory(StringRef Name, CheckFactoryBase *Factory);
+ void addCheckFactory(StringRef Name,
+ std::unique_ptr<CheckFactoryBase> Factory);
+
+ /// \brief Registers the \c CheckType with the name \p Name by adding a
+ /// corresponding \c ClangTidyCheckFactory.
+ template<typename CheckType>
+ void registerCheck(StringRef Name) {
+ addCheckFactory(Name,
+ llvm::make_unique<ClangTidyCheckFactory<CheckType>>());
+ }
/// \brief Create instances of all checks matching \p CheckRegexString and
/// store them in \p Checks.
@@ -89,7 +93,7 @@ public:
void createChecks(GlobList &Filter,
std::vector<std::unique_ptr<ClangTidyCheck>> &Checks);
- typedef std::map<std::string, CheckFactoryBase *> FactoryMap;
+ typedef std::map<std::string, std::unique_ptr<CheckFactoryBase>> FactoryMap;
FactoryMap::const_iterator begin() const { return Factories.begin(); }
FactoryMap::const_iterator end() const { return Factories.end(); }
bool empty() const { return Factories.empty(); }