<div dir="ltr"><div style>On Wed, Jun 19, 2013 at 3:01 PM, John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>></span> wrote:<br></div><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 style="word-wrap:break-word"><div><div>If the cleanup doesn't actually get popped off the cleanup stack, it will still be around for later code in the full-expression.</div>
<div><br></div><div>Here, I think this test case should work:</div><div><br></div><div>  struct A { A(); ~A(); };</div><div>  int foo(A a, const A &a);</div><div>  int bar();</div><div>  ...</div><div>  int baz(bool cond) {</div>
<div>    return (cond ? foo(A(), A()) : bar());</div><div>  }</div><div><br></div><div>Also, you should pop your cleanups in reverse order to make it more likely that they actually pop off.</div></div></div></blockquote><div>
<br></div><div style>Now that I deactivate in reverse order, the cleanups are getting popped, and everything is much cleaner.  I had to add more tests to cover the case where I actually deactivate a cleanup in a conditional.</div>
<div style><br></div><div style>I think the placeholder DominatingIP is OK as is because of this code in SetupCleanupBlockActivation:</div><div style><br></div><div style><div>    // If we're in a conditional block, ignore the dominating IP and</div>
<div>    // use the outermost conditional branch.</div><div>    if (CGF.isInConditionalBranch()) {</div><div>      CGF.setBeforeOutermostConditional(value, var);</div><div>    } else {</div><div>      new llvm::StoreInst(value, var, dominatingIP);</div>
<div>    }</div><div><br></div><div style>Does that make sense?  Basically, the conditional case is already handled for me.  The cleanup is created in a deactivated state, activated when I push it, and then deactivated before the call.</div>
<div style><br></div><div style>Anyway, this has tests now.  I wasn't sure how carefully I should match the labels from the landing pads in the lit tests, but they look correct from inspection.</div></div><div style><br>
</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 style="word-wrap:break-word"><div><div class="im">
<div><span style="color:rgb(34,34,34)">Contrariwise, MSVC presumably accepts this closely-related test case, which we would reject:</span><br></div></div></div><div>  class A {</div><div>    ~A();</div><div>    friend void bar(A *);</div>
<div class="im"><div>  };</div><div>  void bar(A a) { }</div><div>  void foo(A *a) { bar(*a); }</div><div><br></div></div><div>This is not just an ABI difference;  it is a significant change to the language, and we should implement its rules correctly.</div>
</div></blockquote><div><br></div><div style>OK, sounds good.</div></div></div></div>