r285946 - Using release to free memory is at best confusing -- one would expect

David Blaikie via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 8 11:43:27 PST 2016


Ah, I see - your follow up in 285950 mentions that this unique_ptr was
always null, so none of it really mattered/did anything.

On Tue, Nov 8, 2016 at 11:42 AM David Blaikie <dblaikie at gmail.com> wrote:

> On Thu, Nov 3, 2016 at 10:52 AM Chandler Carruth via cfe-commits <
> cfe-commits at lists.llvm.org> wrote:
>
> Author: chandlerc
> Date: Thu Nov  3 12:42:32 2016
> New Revision: 285946
>
> URL: http://llvm.org/viewvc/llvm-project?rev=285946&view=rev
> Log:
> Using release to free memory is at best confusing -- one would expect
> that its result is in fact used. Instead, use reset.
>
>
> Perhaps I'm missing something/perhaps you could provide some more
> context/detail: release() wouldn't've free'd memory, it would've leaked it,
> right? (seems more than just confusing, but actually wrong - so I'm
> confused by your description)
>
>
>
> This was pointed out by PVS-Studio.
>
> Modified:
>     cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp
>
> Modified: cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp?rev=285946&r1=285945&r2=285946&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp (original)
> +++ cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp Thu Nov  3
> 12:42:32 2016
> @@ -43,7 +43,7 @@ VerifyDiagnosticConsumer::~VerifyDiagnos
>    assert(!CurrentPreprocessor && "CurrentPreprocessor should be
> invalid!");
>    SrcManager = nullptr;
>    CheckDiagnostics();
> -  Diags.takeClient().release();
> +  Diags.takeClient().reset();
>  }
>
>  #ifndef NDEBUG
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161108/d5f1b435/attachment.html>


More information about the cfe-commits mailing list