summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2014-09-18 18:59:50 +0000
committerHans Wennborg <hans@hanshq.net>2014-09-18 18:59:50 +0000
commitdfd8c74a988991fa1e69aa61c42a8ff29f8151be (patch)
treeb747be0a555840e5cee8a56f6b15e262880f008e /clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp
parent9767d2f8da212193cddda15e639a118096f6fe76 (diff)
downloadbcm5719-llvm-dfd8c74a988991fa1e69aa61c42a8ff29f8151be.tar.gz
bcm5719-llvm-dfd8c74a988991fa1e69aa61c42a8ff29f8151be.zip
[clang-tidy] Don't leak the TodoCommentHandler object
Preprocessor:addCommentHandler() does not take ownership, so we'd end up leaking the TodoCommentHandler. This patch makes it owned by the Check object. Differential Revision: http://reviews.llvm.org/D5402 llvm-svn: 218068
Diffstat (limited to 'clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp12
1 files changed, 8 insertions, 4 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
OpenPOWER on IntegriCloud