<br><br><div class="gmail_quote">W dniu 14 listopada 2010 14:00 użytkownik Zhongxing Xu <span dir="ltr"><<a href="mailto:xuzhongxing@gmail.com">xuzhongxing@gmail.com</a>></span> napisał:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br><br><div class="gmail_quote"><div><div></div><div class="h5">2010/11/14 Marcin Świderski <span dir="ltr"><<a href="mailto:marcin.sfider@gmail.com" target="_blank">marcin.sfider@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">

<div class="gmail_quote">W dniu 14 listopada 2010 03:15 użytkownik Zhongxing Xu <span dir="ltr"><<a href="mailto:xuzhongxing@gmail.com" target="_blank">xuzhongxing@gmail.com</a>></span> napisał:<div><div></div><div>

<br><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
<div><div></div><div><br><br><div class="gmail_quote">2010/11/14 Marcin Świderski <span dir="ltr"><<a href="mailto:marcin.sfider@gmail.com" target="_blank">marcin.sfider@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">



<div class="gmail_quote">W dniu 14 listopada 2010 00:48 użytkownik Zhongxing Xu <span dir="ltr"><<a href="mailto:xuzhongxing@gmail.com" target="_blank">xuzhongxing@gmail.com</a>></span> napisał:<div><div></div><div>



<br><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
<br><br><div class="gmail_quote">2010/11/14 Marcin Świderski <span dir="ltr"><<a href="mailto:marcin.sfider@gmail.com" target="_blank">marcin.sfider@gmail.com</a>></span><div><div></div><div><br><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">





<div class="gmail_quote">W dniu 13 listopada 2010 12:37 użytkownik Zhongxing Xu <span dir="ltr"><<a href="mailto:xuzhongxing@gmail.com" target="_blank">xuzhongxing@gmail.com</a>></span> napisał:<div><br><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">






I see some unbalancing before this patch. (See the test case that was modified.) Could you provide an example that is unbalanced by this patch?<br><br><div class="gmail_quote">2010/11/13 Marcin Świderski <span dir="ltr"><<a href="mailto:marcin.sfider@gmail.com" target="_blank">marcin.sfider@gmail.com</a>></span><div>






<div></div><div><br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">Hi Zhongxing<div><br></div><div>Won't it lead to unbalancing ctors/dtors like I've written in discusion after commit r118159?<br>







<br><div class="gmail_quote"><br></div></div></blockquote></div></div></div></blockquote></div><div>When I wrote about unbalancing I meant that removing elidable CXXConstructExpr and then removing destructors for temporaries that where created with those expressions will unbalance ctors/dtors calls. Because not every call to the ctor is a block level statement this is not visualised in the CFG.</div>






<div><br></div><div>Example of this is simple:</div><div><br></div><div><div>class A {</div><div>public:</div><div>  A() {}</div><div>  ~A() {}</div><div>};</div><div><br></div><div>A foo() { return A(); }</div><div><br>





</div>
</div><div>AST for function foo() looks like this:</div><div><br></div><div><div>A foo() (CompoundStmt 0x105048b98 <main.cpp:7:9, col:23></div><div>  (ReturnStmt 0x105048b70 <col:11, col:20></div><div>    (CXXExprWithTemporaries 0x105048b38 <col:18, col:20> 'class A'</div>






<div>      (CXXTemporary 0x105048a80)</div><div>      (CXXConstructExpr 0x105048af0 <col:18, col:20> 'class A''void (const class A &) throw()' elidable</div><div>        (ImplicitCastExpr 0x105048ad0 <col:18, col:20> 'const class A' <NoOp></div>






<div>          (CXXBindTemporaryExpr 0x105048a88 <col:18, col:20> 'class A' (CXXTemporary 0x105048a80)</div><div>            (CXXTemporaryObjectExpr 0x105048a38 <col:18, col:20> 'class A''void (void)')))))))</div>






</div><div><br></div><div>If we want to <span style="font-family:arial,sans-serif;font-size:13px;white-space:nowrap">ensure that the CFG is constructed from AST with all elidable constructors elided, </span><span style="font-family:arial,sans-serif;font-size:13px;white-space:nowrap">for above example </span><span style="font-family:arial,sans-serif;font-size:13px;white-space:nowrap">we would have to ignore both CXXConstructExpr and CXXBindTemporaryExpr. In your implementation only the first will be elided.</span></div>






</div>
</blockquote></div></div></div><br><div>Hi Marcin,</div><div><br></div><div>I still do not understand your point. The current implementation works well for the above example. One block-level expr for CXXTemporaryObjectExpr. One temporary dtor for CXXBindTemporaryExpr.</div>





</blockquote></div></div></div><br><div>If CXXConstructExpr that constructs the return value will be elided, object created with CXXTemporaryObjectExpr</div><div>will be the return value and should not be destroyed. So eliding copy constructor should also prevent destroying</div>




<div>temporary from which it would copy, not the other way around.</div>
</blockquote></div><br></div></div>I see your point. This could be prevented by other means, for example, in CodeGen there is a LifetimeFlag in AggValueSlot, which controls whether the temporary would be cleaned up.<br><br>


But this reminds me that probably we should not include dtors for temporaries in the CFG, since not all temporaries require destruction.<br>
<br>Another option is to create a dtor for every CXXBindTemporaryExpr and let the client decide whether to ignore it. What do you think?<br><br></blockquote></div></div><div>Which temporaries, other than those elided, don't require destruction?</div>

</div></blockquote></div></div><div><br> A foo() (CompoundStmt 0x3826c48 <ret.cpp:7:9, col:23><br>  (ReturnStmt 0x3826c20 <col:11, col:20><br>    (CXXExprWithTemporaries 0x3826be8 <col:18, col:20> 'class A'<br>

      (CXXTemporary 0x3826b30)<br>      (CXXConstructExpr 0x3826ba0 <col:18, col:20> 'class A''void (const class A &) throw()' elidable<br>        (ImplicitCastExpr 0x3826b80 <col:18, col:20> 'const class A' <NoOp><br>

          (CXXBindTemporaryExpr 0x3826b38 <col:18, col:20> 'class A' (CXXTemporary 0x3826b30)<br>            (CXXTemporaryObjectExpr 0x3826ae8 <col:18, col:20> 'class A''void (void)')))))))<br>

<br>CXXTemporaryObjectExpr 0x3826ae8 is constructed directly into the return value slot, which does not require destruction.<br></div></div>
</blockquote></div><br><div>That's why I think we shouldn't try to optimize CFG but leave destructors for temporaries as an option.</div>