[PATCH][tablegen] Eliminate memory leaks in TGParser.cpp
Anton Yartsev
anton.yartsev at gmail.com
Tue Aug 5 20:50:53 PDT 2014
Got it. Attached is an updated patch. First tried to use unique_ptr but
soon realized that shared_ptr is more suitable here.
> Personally I'd favor:
>
> auto foo = llvm::make_unique<T>(...);
> foo = llvm::make_unique<T>(...);
>
> over:
>
> std::unique_ptr<T> foo(new T(...));
> foo.reset(new T(...));
>
> Though opinions may vary there.
>
> I'd probably consider renaming your "CurRecLocalView" to "CurRec" so
> that most of the code doesn't need to change (and CurRecUniquePtr
> maybe "CurRecOwner"?)
>
> Also in a preliminary/prior patch, it might be worth changing "addDef"
> to take a unique_ptr by value to properly document the ownershp
> passing (I'm hoping to keep focusing on any 'release()' calls and use
> them as a marker of places to clean up/continue pushing unique_ptr
> through).
>
> On Tue, Aug 5, 2014 at 12:20 PM, Anton Yartsev <anton.yartsev at gmail.com> wrote:
>> Hi all,
>>
>> I've recently ran the alpha.cplusplus.NewDeleteLeaks checker over the LLVM
>> codebase to eliminate false-positives. The checker evolved a number of real
>> leaks. I've decided to fix some of them.
>> Attached is the patch that eliminates memory leaks found in the
>> TGParser.cpp. Please review.
>>
>> --
>> Anton
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
--
Anton
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TGParser_eliminate_leaks_v01.patch
Type: text/x-diff
Size: 13896 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140806/83fabf0d/attachment.patch>
More information about the llvm-commits
mailing list