<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Apr 24, 2014 at 1:02 AM, Dmitri Gribenko <span dir="ltr"><<a href="mailto:gribozavr@gmail.com" target="_blank">gribozavr@gmail.com</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 Wed, Apr 23, 2014 at 10:58 PM, Dmitri Gribenko <<a href="mailto:gribozavr@gmail.com">gribozavr@gmail.com</a>> wrote:<br>

> On Wed, Apr 23, 2014 at 10:54 PM, Nico Weber <<a href="mailto:thakis@chromium.org">thakis@chromium.org</a>> wrote:<br>
>> On Wed, Apr 23, 2014 at 2:53 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>><br>
>> wrote:<br>
>>><br>
>>> On Wed, Apr 23, 2014 at 2:41 PM, Nico Weber <<a href="mailto:nicolasweber@gmx.de">nicolasweber@gmx.de</a>> wrote:<br>
>>>><br>
>>>> Author: nico<br>
>>>> Date: Wed Apr 23 16:41:51 2014<br>
>>>> New Revision: 207031<br>
>>>><br>
>>>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=207031&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=207031&view=rev</a><br>
>>>> Log:<br>
>>>> Fix leak introduced in r194610, found by LSan.<br>
>>>><br>
>>>> LSan folks: LSan pointed to<br>
>>>>     #0 0x4953e0 in operator new[](unsigned long)<br>
>>>> llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:64<br>
>>>>     #1 0x7fb82af5372f in clang::RewriteRope::MakeRopeString(char const*,<br>
>>>> char const*) llvm/tools/clang/lib/Rewrite/Core/RewriteRope.cpp:796<br>
>>>> instead of to the actual leak, which made tracking this down slower than<br>
>>>> it could have been.<br>
>>>><br>
>>>> Modified:<br>
>>>>     cfe/trunk/include/clang/Index/CommentToXML.h<br>
>>>>     cfe/trunk/lib/Index/CommentToXML.cpp<br>
>>>><br>
>>>> Modified: cfe/trunk/include/clang/Index/CommentToXML.h<br>
>>>> URL:<br>
>>>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/CommentToXML.h?rev=207031&r1=207030&r2=207031&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/CommentToXML.h?rev=207031&r1=207030&r2=207031&view=diff</a><br>

>>>><br>
>>>> ==============================================================================<br>
>>>> --- cfe/trunk/include/clang/Index/CommentToXML.h (original)<br>
>>>> +++ cfe/trunk/include/clang/Index/CommentToXML.h Wed Apr 23 16:41:51 2014<br>
>>>> @@ -29,6 +29,7 @@ class CommentToXMLConverter {<br>
>>>><br>
>>>>  public:<br>
>>>>    CommentToXMLConverter() : FormatContext(0), FormatInMemoryUniqueId(0)<br>
>>>> {}<br>
>>>> +  ~CommentToXMLConverter();<br>
>>>><br>
>>>>    void convertCommentToHTML(const comments::FullComment *FC,<br>
>>>>                              SmallVectorImpl<char> &HTML,<br>
>>>><br>
>>>> Modified: cfe/trunk/lib/Index/CommentToXML.cpp<br>
>>>> URL:<br>
>>>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/CommentToXML.cpp?rev=207031&r1=207030&r2=207031&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/CommentToXML.cpp?rev=207031&r1=207030&r2=207031&view=diff</a><br>

>>>><br>
>>>> ==============================================================================<br>
>>>> --- cfe/trunk/lib/Index/CommentToXML.cpp (original)<br>
>>>> +++ cfe/trunk/lib/Index/CommentToXML.cpp Wed Apr 23 16:41:51 2014<br>
>>>> @@ -1136,6 +1136,10 @@ void CommentASTToXMLConverter::appendToR<br>
>>>>    Result << "]]>";<br>
>>>>  }<br>
>>>><br>
>>>> +CommentToXMLConverter::~CommentToXMLConverter() {<br>
>>>> +  delete FormatContext;<br>
>>><br>
>>><br>
>>> Is it possible to use unique_ptr here?<br>
>><br>
>><br>
>> That was my first attempt, but unique_ptr requires a complete type and<br>
>> SimpleFormatContext is defined in lib/Index while CommentToXML.h is in<br>
>> include/clang/Index. Is it possible to use unique_ptr in this scenario?<br>
><br>
> The destructor can be put out-of line into .cpp and defaulted.<br>
<br>
</div></div>r207087.<br></blockquote><div><br></div><div>Ah, so one can use unique_ptr with forward-declared classes when constructors and destructors are out of line, thanks :-)</div><div><br></div><div>(Looks like msvs doesn't like defaulting though; thanks to chapuni for fixing that!)</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
Dmitri<br>
<br>
--<br>
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if<br>
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <<a href="mailto:gribozavr@gmail.com">gribozavr@gmail.com</a>>*/<br>
</div></div></blockquote></div><br></div></div>