<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Sep 4, 2014 at 8:15 AM, Benjamin Kramer <span dir="ltr"><<a href="mailto:benny.kra@googlemail.com" target="_blank">benny.kra@googlemail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: d0k<br>
Date: Thu Sep 4 10:15:27 2014<br>
New Revision: 217162<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=217162&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=217162&view=rev</a><br>
Log:<br>
Plug a unit test memory leak.<br>
<br>
MatchFinder.addMatcher doesn't take ownership.<br>
<br>
Modified:<br>
clang-tools-extra/trunk/unittests/clang-modernize/TransformTest.cpp<br>
<br>
Modified: clang-tools-extra/trunk/unittests/clang-modernize/TransformTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-modernize/TransformTest.cpp?rev=217162&r1=217161&r2=217162&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-modernize/TransformTest.cpp?rev=217162&r1=217161&r2=217162&view=diff</a><br>
==============================================================================<br>
--- clang-tools-extra/trunk/unittests/clang-modernize/TransformTest.cpp (original)<br>
+++ clang-tools-extra/trunk/unittests/clang-modernize/TransformTest.cpp Thu Sep 4 10:15:27 2014<br>
@@ -271,7 +271,8 @@ TEST(Transform, isFileModifiable) {<br>
<br>
DummyTransform T("dummy", Options);<br>
MatchFinder Finder;<br>
- Finder.addMatcher(varDecl().bind("decl"), new ModifiableCallback(T));<br>
+ ModifiableCallback Callback(T);<br>
+ Finder.addMatcher(varDecl().bind("decl"), &Callback);<br></blockquote><div><br></div><div>Could/should we modify the addMatcher functions to take the second parameter by reference instead of pointer to reduce the risk of these leaks being written?<br>
<br>(I actually started making this change & eventually realized it's a bit of a rat's-nest of Google-esque "pass non-const references by pointer" which is annoying)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Tool.run(tooling::newFrontendActionFactory(&Finder).get());<br>
}<br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>