<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Could we consider moving the things you listed to shared pointer semantics ? It will be a simple and clear model; unless someone justifies that it will be a performance concern to use shared pointers there I don’t think we need a new and more complex to reason about smart pointer.</div><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 13, 2014, at 9:42 AM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Ping - we've hit another of these (propagating Diagnostic::OwnsDiagClient into other places) in<br class=""><br class=""><a href="http://llvm.org/viewvc/llvm-project?view=revision&revision=221884" class="">http://llvm.org/viewvc/llvm-project?view=revision&revision=221884</a><br class=""><br class="">Any ideas how we should be tackling this overall? I'm not entirely convinced these are fixable by design and I think we might honestly want a conditional-ownership smart pointer... <br class=""><br class="">But I'm happy to hold off on that a while longer if we're going to make a concerted effort to avoid propagating these half-baked solutions and actually try to remove them when we come up against problems with/around them.<br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Oct 8, 2014 at 1:01 PM, David Blaikie <span dir="ltr" class=""><<a href="mailto:dblaikie@gmail.com" target="_blank" class="">dblaikie@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr" class="">& repeating for the benefit of cfe-dev, here's the list of known cases of conditional ownership (I'm sure there are others that don't fit the exact naming convention I grep'd for):<br class=""><br class=""><div class="">In Clang, simply grepping for "Owns" comes up with the following boolean members:</div><span class=""><div class=""><br class=""></div><div class="">CodeGenAction::OwnsVMContext</div><div class="">ASTReader::OwnsDeserializationListener</div><div class="">Diagnostic::OwnsDiagClient</div><div class="">Preprocessor::OwnsHeaderSearch</div><div class="">TokenLexer::OwnsTokens</div><div class="">Action::OwnsInputs (this ones trickier - it's a boolean that indicates whether all the elements of a vector<T*> are owned or unowned)</div><div class="">ASTUnit::OwnsRemappedFileBuffers</div><div class="">VerifyDiagnosticConsumer::OwnsPrimaryClient</div><div class="">TextDiagnosticPrinter::OwnsOutputStream</div><div class="">FixItRewriter::OwnsClient</div><div class="">Tooling::OwnsAction</div><div class=""><br class=""></div><div class="">Some in LLVM:</div><div class=""><br class=""></div><div class="">circular_raw_ostream::OwnsStream</div><div class="">Arg::OwnsValues (another tricky one with a bool flag and a vector of raw pointers, if I recall correctly)</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">And a couple that I changed {T*, bool} to {T*, unique_ptr<T>}:</div><div class=""><br class=""></div><div class="">LogDiagnosticPrinter::StreamOwner</div><div class="">ASTUnit::ComputedPreamble::Owner</div></span></div><div class=""><div class="h5"><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Oct 8, 2014 at 1:00 PM, David Blaikie <span dir="ltr" class=""><<a href="mailto:dblaikie@gmail.com" target="_blank" class="">dblaikie@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr" class="">[+cfe-dev]<br class=""><br class="">This conversation has already been happening on llvm-dev so there's no good way for me to capture the entire existing discussion (so I'm jumping you in part-way) & the subject line could be more descriptive, but I wanted to add Clang developers since many of the interesting cases of conditional ownership I've seen were in Clang.<br class=""><br class="">I know some of you are also on llvm-dev but not active readers, so it might be worth using this as a jumping off point to go & find the full llvm-dev thread, read that and, when replying, add cfe-dev.<br class=""><br class="">If anyone not on llvm-dev wants some more context there's the email archive here ( <a href="http://lists.cs.uiuc.edu/pipermail/llvmdev/2014-September/thread.html#77136" target="_blank" class="">http://lists.cs.uiuc.edu/pipermail/llvmdev/2014-September/thread.html#77136</a> ) and/or I'm happy to provide more context/summary myself.<div class=""><div class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, Oct 2, 2014 at 9:44 AM, David Blaikie <span dir="ltr" class=""><<a href="mailto:dblaikie@gmail.com" target="_blank" class="">dblaikie@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote"><span class="">On Thu, Oct 2, 2014 at 2:43 AM, Anton Yartsev <span dir="ltr" class=""><<a href="mailto:anton.yartsev@gmail.com" target="_blank" class="">anton.yartsev@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF" class="">
<div class="">Thanks for the feedback!<br class="">
</div><span class="">
<blockquote type="cite" class="">
<div dir="ltr" class="">
<div class="gmail_extra"><br class="">
<div class="gmail_quote">On Wed, Oct 1, 2014 at 3:36 PM, David
Blaikie <span dir="ltr" class=""><<a href="mailto:dblaikie@gmail.com" target="_blank" class="">dblaikie@gmail.com</a>></span>
wrote:<br class="">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">On Wed, Oct 1, 2014 at 3:14 PM, Anton Yartsev <span dir="ltr" class=""><<a href="mailto:anton.yartsev@gmail.com" target="_blank" class="">anton.yartsev@gmail.com</a>></span>
wrote:<br class="">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF" class="">
<div class="">Ping!<span class=""><br class="">
</span><br class="">
Suggested is a wrapper over a raw pointer that is
intended for freeing wrapped memory at the end of
wrappers lifetime if ownership of a raw pointer
was not taken away during the lifetime of the
wrapper. <br class="">
The main difference from unique_ptr is an ability
to access the wrapped pointer after the ownership
is transferred.<br class="">
To make the ownership clearer the wrapper is
designed for local-scope usage only.<br class="">
</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
</span>
<div class="">I'm still concerned this isn't the right direction,
and that we instead want a more formal "maybe owning
pointer". The specific use case you've designed for
here, in my experience, doesn't seem to come up often
enough to justify a custom ADT - but the more general
tool of sometimes-owning smart pointer seems common
enough (& problematic enough) to warrant a generic
data structure (and such a structure would also be
appliable to the TGParser use case where this came up).<br class="">
</div>
</blockquote>
</div>
</div>
</div>
</blockquote></span>
David, could you, please, clarify the concept of the "maybe owning
pointer"?</div></blockquote><div class=""><br class=""></div></span><div class="">See my reply to Chandler with a list of classes that hold {T*, bool} members where the bool indicates whether the T* needs to be deleted or not. My original goal here was to provide an API to make those more robust (more precisely: to remove the need to call "release()" and allow us to stay in a clear(er) owning domain).</div><span class=""><div class=""> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF" class=""><span class=""><br class="">
<br class="">
<blockquote type="cite" class="">
<div dir="ltr" class="">
<div class="gmail_extra">
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class=""><br class="">
I'd love to hear some more opinions, but maybe we're not
going to get them... </div>
</blockquote>
</div>
<br class="">
I strongly agree that the example here isn't compelling.</div>
<div class="gmail_extra"><br class="">
</div>
<div class="gmail_extra">I think it is a very fundamental design
problem when there is a need for a pointer value after it has
been deallocated...</div>
</div>
</blockquote></span>
Not deallocated but stored to the long-living storage. I agree, the
problem is in design, the suggested wrapper is an intermediate
solution, it was just designed to replace the existing ugly fixes.<span class=""><br class="">
<br class="">
<blockquote type="cite" class="">
<div dir="ltr" class="">
<div class="gmail_extra">I even question whether we need a
"maybe owning" smart pointer, or whether this is just an
indication that the underlying data structure is *wrong*. The
idea of "maybe" and "owning" going to gether, in any sense,
seems flat out broken to me from a design perspective, and so
I'm not enthused about providing abstractions that make it
easier to build systems with unclear ownership semantics.</div>
</div>
</blockquote>
<br class="">
</span><span class=""><font color="#888888" class=""><pre cols="72" class="">--
Anton</pre>
</font></span></div>
</blockquote></span></div><br class=""></div></div>
</blockquote></div><br class=""></div></div></div></div>
</blockquote></div><br class=""></div>
</div></div></blockquote></div><br class=""></div></div>
_______________________________________________<br class="">cfe-dev mailing list<br class=""><a href="mailto:cfe-dev@cs.uiuc.edu" class="">cfe-dev@cs.uiuc.edu</a><br class="">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev<br class=""></div></blockquote></div><br class=""></body></html>