[cfe-dev] C++ Constructors & Destructors in the AST
Anders Carlsson
andersca at me.com
Sun Apr 26 13:30:48 PDT 2009
26 apr 2009 kl. 12.42 skrev Chris Lattner:
>
> On Apr 26, 2009, at 12:37 PM, Anders Carlsson wrote:
>
>>
>> (CXXExprWithCleanup
>> (CXXTemporaryObjectExpr("temp", "T::T")
>> ("temp"))
>>
>> In the first design that we came up with, we would have explicit
>> CXXDestroyExprs that would be inserted after statements, but that
>> won't work with things like the for loop condition expr. I plan to
>> remove the CXXDestroyExpr node.
>>
>> Does this sound OK? Maybe we should rename CXXExprWithCleanup to
>> CXXExprWithTemporaries? I'll add some documentation shortly.
>
> Hi Anders,
>
> I thought the idea was to make CXXDestroyExpr be an expression, and
> use a comma expression (or its moral equivalent) where needed. This
> allows temporaries to occur anywhere an expressions does (including
> the initializer for a global, etc).
>
Would a comma expression really work? Isn't the type of a comma
expression the type of its second argument? How would you represent
if (T().f()) { ... }
in that case? We could add a separate expr node but then we'd end up
with something very similar to CXXExprWithTemporaries :)
Anders
More information about the cfe-dev
mailing list