<div dir="ltr">As I recall, the capture of the LookupResult (which was believed to be safe) was a convenient way of capturing the lookup-parameter state of the LookupResult--the identifier being looked up, it's location, the lookup kind, etc--instead of breaking them out into a bunch of separate local variables to be captured by the lambda and used to rebuild a LookupResult suitable for passing into SemaRef.BuildMemberReferenceExpr (which IIRC depends on the LookupResult telling it whether overload resolution is necessary).</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 18, 2015 at 8:52 PM, David Blaikie via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Perhaps I should remove the old lists from my contacts...<div><div class="h5"><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">David Blaikie</b> <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span><br>Date: Tue, Aug 18, 2015 at 8:39 PM<br>Subject: Code carefully copying LookupResults which aren't exactly copyable<br>To: Richard Smith <<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>>, Kaelyn Takata <<a href="mailto:rikka@google.com" target="_blank">rikka@google.com</a>>, cfe-dev Developers <<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a>><br><br><br><div dir="ltr">More -Wdeprecated cleanup.<br><br>Turns out LookupResults are copied in at least one place:<br><br>SemaExprMember.cpp:651<br><br>Essentially this function takes a LookupResult, captures it by value into a lambda, within the body of the lambda it suppresses diagnostics on the LookupResult and then does some other stuff.<br><br>LookupResult's dtor does a couple of things - it emits diagnostics, if needed. And it destroys the CXXBasePaths in the LookupResult. As luck/design would have it, the LookupResult that is copied here never has a non-null CXXBasePaths and, as mentioned, always disables diagnostics (if the lambda is actually called - if it is not, maybe bad things could happen? It could emit diagnostics unintentionally?).<br><br>Having LookupResult be copyable in general seems problematic - if extra care is not taken it could easily double delete and/or emit excess diagnostics.<br><br>Any ideas how this might be improved?<br><br>Honestly I seem to recall being involved in the code review, and maybe I even suggested this approach, not knowing what monsters lurked beneath. Maybe the original code ferried just the right LookupResult parameters across the capture boundary? That would be safe & then we could make LookupResult non-copyable again. (& can unique_ptr the CXXBasePaths (or even Optional<CXXBasePaths>) eventually)<br><br>- Dave</div>
</div><br></div></div></div>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>