[cfe-dev] CFG temporary objects destructors

Ted Kremenek kremenek at apple.com
Wed Oct 20 21:36:03 PDT 2010


On Oct 20, 2010, at 9:29 PM, Ted Kremenek wrote:

> 
> On Oct 17, 2010, at 3:06 PM, Marcin Świderski wrote:
> 
>> I'm currently working on modeling destructors of temporary objects in CFG. I've attached patch with prototype implementation and some tests.
>> 
> 
> Hi Marcin,
> 
> Aside from your other comment (which I will get to later), I had a question about the following:
> 
> +CFGBlock *CFGBuilder::VisitBinaryOperatorForTemporaryDtors(BinaryOperator *E) {
> +  if (E->isLogicalOp()) {
> +    // Destructors for temporaries in LHS expression should be called after
> +    // those for RHS expression. Even if this will unnecessarily create a block,
> +    // this block will be used at least by the full expression.
> 
> In the CFG, where we must represent control-flow between the LHS and RHS subexpressions, we actually have the RHS appear first in the CFG.  I believe, however, that the compiler chooses the reverse direction.  Should we reverse it to match?  I think your logic here assumes that the LHS temporaries are created first.
> 
> Ted

More specifically, my comment applies to the following code:

+CFGBlock *CFGBuilder::VisitBinaryOperatorForTemporaryDtors(BinaryOperator *E) {
+  if (E->isLogicalOp()) {
+    // Destructors for temporaries in LHS expression should be called after
+    // those for RHS expression. Even if this will unnecessarily create a block,
+    // this block will be used at least by the full expression.

Basically this assumption doesn't match how we treat binary operators in the CFG.  We should probably fix having the LHS always precessed first.  Any objections?



More information about the cfe-dev mailing list