forked from OSchip/llvm-project
Use std::unique_ptr in ClangTidyCheckFactories
I had to explicitly define some destructors that could only be defined in the corresponding .cpp files. llvm-svn: 372978
This commit is contained in:
parent
c15cd009ac
commit
5338ffcfa1
|
@ -13,6 +13,7 @@
|
|||
#include "llvm/ADT/StringRef.h"
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
|
@ -25,9 +26,8 @@ namespace tidy {
|
|||
/// this object.
|
||||
class ClangTidyCheckFactories {
|
||||
public:
|
||||
typedef std::function<ClangTidyCheck *(StringRef Name,
|
||||
ClangTidyContext *Context)>
|
||||
CheckFactory;
|
||||
using CheckFactory = std::function<std::unique_ptr<ClangTidyCheck>(
|
||||
StringRef Name, ClangTidyContext *Context)>;
|
||||
|
||||
/// Registers check \p Factory with name \p Name.
|
||||
///
|
||||
|
@ -58,7 +58,7 @@ public:
|
|||
template <typename CheckType> void registerCheck(StringRef CheckName) {
|
||||
registerCheckFactory(CheckName,
|
||||
[](StringRef Name, ClangTidyContext *Context) {
|
||||
return new CheckType(Name, Context);
|
||||
return std::make_unique<CheckType>(Name, Context);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -55,6 +55,8 @@ TodoCommentCheck::TodoCommentCheck(StringRef Name, ClangTidyContext *Context)
|
|||
Handler(std::make_unique<TodoCommentHandler>(
|
||||
*this, Context->getOptions().User)) {}
|
||||
|
||||
TodoCommentCheck::~TodoCommentCheck() = default;
|
||||
|
||||
void TodoCommentCheck::registerPPCallbacks(const SourceManager &SM,
|
||||
Preprocessor *PP,
|
||||
Preprocessor *ModuleExpanderPP) {
|
||||
|
|
|
@ -22,6 +22,8 @@ namespace readability {
|
|||
class TodoCommentCheck : public ClangTidyCheck {
|
||||
public:
|
||||
TodoCommentCheck(StringRef Name, ClangTidyContext *Context);
|
||||
~TodoCommentCheck();
|
||||
|
||||
void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
|
||||
Preprocessor *ModuleExpanderPP) override;
|
||||
|
||||
|
|
|
@ -193,6 +193,8 @@ IdentifierNamingCheck::IdentifierNamingCheck(StringRef Name,
|
|||
IgnoreFailedSplit = Options.get("IgnoreFailedSplit", 0);
|
||||
}
|
||||
|
||||
IdentifierNamingCheck::~IdentifierNamingCheck() = default;
|
||||
|
||||
void IdentifierNamingCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
|
||||
auto const toString = [](CaseType Type) {
|
||||
switch (Type) {
|
||||
|
|
|
@ -34,6 +34,7 @@ namespace readability {
|
|||
class IdentifierNamingCheck : public ClangTidyCheck {
|
||||
public:
|
||||
IdentifierNamingCheck(StringRef Name, ClangTidyContext *Context);
|
||||
~IdentifierNamingCheck();
|
||||
|
||||
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
|
||||
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
|
||||
|
|
Loading…
Reference in New Issue