[cfe-dev] CFG temporary objects destructors

Zhongxing Xu xuzhongxing at gmail.com
Fri Oct 22 21:02:59 PDT 2010


2010/10/23 Marcin Świderski <marcin.sfider at gmail.com>

> W dniu 22 października 2010 11:22 użytkownik Zhongxing Xu <
> xuzhongxing at gmail.com> napisał:
>
> When the binary operator is logical operator, why we need to replicate the
>> control flow when adding the dtors in LHS and RHS? Could we just add the
>> dtor right after where the LHS and RHS are evaluated?
>>
>> That is, for code
>>
>> A && B
>>
>> we generate CFG like this:
>>
>> A && B
>> ~A()
>> |      \
>> |       B
>> |       ~B()
>> |        |
>> A && B
>>
>> Since in logical binary operator, we only need the boolean value. The
>> temporary object can be destroyed right after it is evaluated.
>>
>> This depends on how much we want to simulate real control flow of
> expression. C++ standard states that destructors of temporaries should be
> called at the end of full expression and in reverse order of their
> construction. Your example does not satisfy this. It only guaranties that
> destructor for temporary will be called.
>

I know it does not conform to the standard. I just proposed it to see if it
is a viable alternative for CFG construction. But extending the CFG
terminator could be a good idea. I'll think about it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20101023/425793c7/attachment.html>


More information about the cfe-dev mailing list