summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp12
-rw-r--r--clang-tools-extra/clang-tidy/google/TodoCommentCheck.h8
2 files changed, 14 insertions, 6 deletions
diff --git a/clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp b/clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp
index 287aa8de55a..5937f8f1423 100644
--- a/clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp
@@ -15,8 +15,7 @@ namespace clang {
namespace tidy {
namespace readability {
-namespace {
-class TodoCommentHandler : public CommentHandler {
+class TodoCommentCheck::TodoCommentHandler : public CommentHandler {
public:
explicit TodoCommentHandler(TodoCommentCheck &Check)
: Check(Check), TodoMatch("^// *TODO(\\(.*\\))?:?( )?(.*)$") {}
@@ -54,10 +53,15 @@ private:
TodoCommentCheck &Check;
llvm::Regex TodoMatch;
};
-} // namespace
+
+TodoCommentCheck::TodoCommentCheck(StringRef Name, ClangTidyContext *Context)
+ : ClangTidyCheck(Name, Context),
+ Handler(llvm::make_unique<TodoCommentHandler>(*this)) {}
+
+TodoCommentCheck::~TodoCommentCheck() {}
void TodoCommentCheck::registerPPCallbacks(CompilerInstance &Compiler) {
- Compiler.getPreprocessor().addCommentHandler(new TodoCommentHandler(*this));
+ Compiler.getPreprocessor().addCommentHandler(Handler.get());
}
} // namespace readability
diff --git a/clang-tools-extra/clang-tidy/google/TodoCommentCheck.h b/clang-tools-extra/clang-tidy/google/TodoCommentCheck.h
index f6947096626..10e84a7be2e 100644
--- a/clang-tools-extra/clang-tidy/google/TodoCommentCheck.h
+++ b/clang-tools-extra/clang-tidy/google/TodoCommentCheck.h
@@ -21,9 +21,13 @@ namespace readability {
/// Corresponding cpplint.py check: readability/todo
class TodoCommentCheck : public ClangTidyCheck {
public:
- TodoCommentCheck(StringRef Name, ClangTidyContext *Context)
- : ClangTidyCheck(Name, Context) {}
+ TodoCommentCheck(StringRef Name, ClangTidyContext *Context);
+ ~TodoCommentCheck();
void registerPPCallbacks(CompilerInstance &Compiler) override;
+
+private:
+ class TodoCommentHandler;
+ std::unique_ptr<TodoCommentHandler> Handler;
};
} // namespace readability
OpenPOWER on IntegriCloud