<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, May 1, 2014 at 1:19 PM, Nico Weber <span dir="ltr"><<a href="mailto:thakis@chromium.org" target="_blank">thakis@chromium.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Thu, May 1, 2014 at 1:17 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br>
> On Thu, May 1, 2014 at 1:12 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:<br>
>> On Thu, May 1, 2014 at 12:55 PM, Etienne Ollivier <<a href="mailto:eollivier@bsu.edu">eollivier@bsu.edu</a>> wrote:<br>
>>><br>
>>> Hello,<br>
>>> I updated my clang repository recently and I an error appeared that was<br>
>>> not<br>
>>> there before:<br>
>>><br>
>>> error: no viable conversion from 'std::unique_ptr<FrontendActionFactory>'<br>
>>> to<br>
>>> 'clang::tooling::ToolAction *'<br>
>>> return Tool.run(newFrontendActionFactory<MyPluginASTAction>());<br>
>>> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
>>><br>
>>> It is because newFrontendActionFactory has been changed to work with<br>
>>> std::unique_ptr. So if I change my code to<br>
>>> return Tool.run(&(*newFrontendActionFactory<MyPluginASTAction>()));<br>
>><br>
>><br>
>> You can use .get() rather than the slightly non-obvious &*.<br>
>><br>
>>><br>
>>> it works. The only little problem is that it can be confusing for users<br>
>>> since is not the way it is written in the documentation, like on this<br>
>>> pages:<br>
>>> <a href="http://clang.llvm.org/docs/LibTooling.html" target="_blank">http://clang.llvm.org/docs/LibTooling.html</a><br>
>>> <a href="http://clang.llvm.org/docs/LibASTMatchersTutorial.html" target="_blank">http://clang.llvm.org/docs/LibASTMatchersTutorial.html</a><br>
>><br>
>><br>
>> Thanks, I've updated the documentation.<br>
><br>
> I'm trying to understand how the ownership used to work/is meant to work now...<br>
<br>
</div></div>The result of newFrontendActionFactory() used to be leaked. Now it's<br>
freed at the end-of-statement cleanup of the returned (invisible)<br>
unique_ptr temporary.</blockquote><div><br></div><div>Why do we need to heap-allocate the FrontendActionFactory at all?</div></div></div></div>