[PATCH] [clang-tidy] Don't leak the TodoCommentHandler object

David Blaikie dblaikie at gmail.com
Thu Sep 18 11:53:17 PDT 2014


================
Comment at: clang-tidy/google/TodoCommentCheck.cpp:58
@@ +57,3 @@
+TodoCommentCheck::TodoCommentCheck(StringRef Name, ClangTidyContext *Context)
+    : ClangTidyCheck(Name, Context), Handler(new TodoCommentHandler(*this)) {}
+
----------------
FWIW I tend to use llvm::make_unique even in init lists like this - it reassures me when I go back to read it that the member is actually a unique_ptr, not a raw pointer I might need to pay attention to.

================
Comment at: clang-tidy/google/TodoCommentCheck.cpp:60
@@ -59,3 +62,3 @@
 void TodoCommentCheck::registerPPCallbacks(CompilerInstance &Compiler) {
-  Compiler.getPreprocessor().addCommentHandler(new TodoCommentHandler(*this));
 }
----------------
might be nice to have addCommentHandler take by reference... maybe, one day, etc.

http://reviews.llvm.org/D5402






More information about the cfe-commits mailing list