[llvm] r208293 - Use a vector of unique_ptrs to fix a memory leak introduced in r208179.

Daniel Sanders Daniel.Sanders at imgtec.com
Mon May 12 02:18:35 PDT 2014


> -----Original Message-----
> From: David Blaikie [mailto:dblaikie at gmail.com]
> Sent: 08 May 2014 19:56
> To: Daniel Sanders
> Cc: llvm-commits at cs.uiuc.edu
> Subject: Re: [llvm] r208293 - Use a vector of unique_ptrs to fix a memory leak
> introduced in r208179.
> 
> On Thu, May 8, 2014 at 11:35 AM, Daniel Sanders
> <Daniel.Sanders at imgtec.com> wrote:
> >> -----Original Message-----
> >> From: David Blaikie [mailto:dblaikie at gmail.com]
> >> Sent: 08 May 2014 19:14
> >> To: Daniel Sanders
> >> Cc: llvm-commits at cs.uiuc.edu
> >> Subject: Re: [llvm] r208293 - Use a vector of unique_ptrs to fix a
> >> memory leak introduced in r208179.
> >>
> >> On Thu, May 8, 2014 at 2:29 AM, Daniel Sanders
> >> <daniel.sanders at imgtec.com> wrote:
> >> > Author: dsanders
> >> > Date: Thu May  8 04:29:28 2014
> >> > New Revision: 208293
> >> >
> >> > URL: http://llvm.org/viewvc/llvm-project?rev=208293&view=rev
> >> > Log:
> >> > Use a vector of unique_ptrs to fix a memory leak introduced in r208179.
> >> >
> >> > Also removed an inaccurate comment that stated that a DenseMap was
> >> > used as storage for the ListInit*'s. It's currently using a FoldingSet.
> >>
> >> So FoldingSet<T> is really a set of raw, non-owning, T*? Should we
> >> make it FoldingSet<pointer-like-thing> (that would require updating
> >> all existing uses from T to explicitly specify T*) and allow it to
> >> handle unique_ptr<T> correctly as another "pointer-like-thing" so it can
> hold ownership?
> >
> > That's right, it holds T*'s but doesn't own them. For some reason it didn't
> occur to me to try FoldingSet<unique_ptr<T>> even though I thought of a
> container of unique_ptr's. I'll rework the commit in the morning.
> 
> I doubt that'll work - I'd wager you'll just get non-owning "unique_ptr<T>*"
> (pointers to smart pointers... ).

Yes, that what it tries to do. It then fails to compile due to invalid static_casts between unique_ptr<T> and FoldingSetImpl::Node *.





More information about the llvm-commits mailing list