<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Jul 7, 2014 at 10:15 PM, Jordan Rose <span dir="ltr"><<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>Ah...then I'm glad we added the assertion. :-) Lifetime-extended temporaries aren't quite implemented correctly yet, but we should probably be removing or not even adding the state when the temporary is lifetime-extended.</div>
<div><br></div><div>Unfortunately I don't have this paged in, but there's logic in processing auto destructors to handle this, and a bug (<a href="http://llvm.org/bugs/show_bug.cgi?id=19539" target="_blank">http://llvm.org/bugs/show_bug.cgi?id=19539</a>) about how it's wrong.</div>
</div></blockquote><div><br></div><div>Ok, I dug into this a bit, and if I'm not missing something I think it's not possible to switch this off without implementing lifetime-extended temporaries correctly (or at least a similarly sized implementation effort):</div>
<div>The only link between the MaterializeTempooraryExpr (which has the information whether the lifetime was extended) and the CXXBindTemporaryExpr is the underlying object storage. I looked into CodeGen, and if I understand it correctly, it looks like it basically stores for the destination whether the destructor was already handled (for example from the MaterializeTemporary flow). To get that information, I'd guess we need to do something similar in the static analyzer.</div>
<div><br></div><div>I hope that my analysis is wrong and you tell me a better way to fix this :)</div><div><br></div><div>Thanks!</div><div>/Manuel</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><span class="HOEnZb"><font color="#888888"><div><br></div><div>Jordan</div></font></span><div><div class="h5"><div><br></div><br><div><div>On Jul 7, 2014, at 13:13 , Manuel Klimek <<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>> wrote:</div>
<br><blockquote type="cite"><div dir="ltr">Sigh. That triggers in Analysis/dtor.cpp for this CXXBindTemporaryExpr:<div><div>CXXBindTemporaryExpr 0x3c195d8 'class LifetimeExtension::SaveOnVirtualDestruct' (CXXTemporary 0x3c195d0)</div>
<div>
`-CXXTemporaryObjectExpr 0x3c19590 'class LifetimeExtension::SaveOnVirtualDestruct' 'void (void)'</div></div><div><br></div><div>I assume something fishy is going on for lifetime extended temporaries...</div>

</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jul 7, 2014 at 8:38 PM, Jordan Rose <span dir="ltr"><<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div><br><div><div>On Jul 7, 2014, at 11:37 , Manuel Klimek <<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>> wrote:</div>

<br><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Jul 7, 2014 at 8:05 PM, Jordan Rose <span dir="ltr"><<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><br><div><div>On Jul 7, 2014, at 10:50 , Manuel Klimek <<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>> wrote:</div>


<br><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Jul 7, 2014 at 7:42 PM, Jordan Rose <span dir="ltr"><<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>></span> wrote:<br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><br><div><div>On Jul 7, 2014, at 10:41 , Manuel Klimek <<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>> wrote:</div>



<br><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Jul 7, 2014 at 7:38 PM, Jordan Rose <span dir="ltr"><<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>></span> wrote:<br>




<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><br><div><div>On Jul 7, 2014, at 10:37 , Manuel Klimek <<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>> wrote:</div>




<br><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Jul 7, 2014 at 7:29 PM, Jordan Rose <span dir="ltr"><<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>></span> wrote:<br>





<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><br><div><div>On Jul 7, 2014, at 10:28 , Manuel Klimek <<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>> wrote:</div>





<br><blockquote type="cite"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">On Mon, Jul 7, 2014 at 6:48 PM, Jordan Rose<span> </span></span><span dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>></span><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important"><span> </span>wrote:</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">





<blockquote class="gmail_quote" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">





Can you add an assertion at the end of a block that there are no outstanding temporary destructors in the current stack frame? That seems useful.<br></blockquote><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">





<br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">





Do you mean at the end of a VisitBlockDecl?</div></blockquote></div><br></div><div>No, during the path-sensitive run, so handleBlockExit.</div></div></blockquote><div><br></div><div>So you mean at the end of a CFG block? But here we might have outstanding temporary dtors open (?) </div>





</div></div></div></blockquote></div><br></div><div>Oops, right. Was thinking too much in terms of AST structure. How about at the end of a function (inlined or not)?</div></div></blockquote></div><br></div><div class="gmail_extra">




Could we say every time we transition from a block with a temp dtor terminator to a block that does not have a temp dtor terminator (or an unconditional terminator) we check?</div></div>
</blockquote></div><br></div><div>That sounds correct, but misses the case where we built the CFG wrong (forgetting to add the branch in the correct place and thus never getting to the temp dtor block at all).</div>

</div></blockquote></div><br></div><div class="gmail_extra">Makes sense. Do you have a hint where the right place on function exit to check it would be? :)</div></div>
</blockquote></div><br></div><div>*checks* ExprEngine::processEndOfFunction.</div></div></blockquote></div><br></div><div class="gmail_extra">Hm, so we'll need to adjust the data structure to be indexed by stack frame somehow (use a map) instead of the pair<expr, stack-frame>?</div>


</div>
</blockquote></div><br></div></div><div>Eh, since it's an assertion I'd be fine with just iterating over it in a helper function. Or better, using std::find_if (if it has proper begin/end members).</div></div></blockquote>

</div><br></div>
</blockquote></div><br></div></div></div></blockquote></div><br></div></div>