[cfe-dev] C++ Constructors & Destructors in the AST
Anders Carlsson
andersca at me.com
Mon Apr 27 14:40:19 PDT 2009
26 apr 2009 kl. 13.41 skrev Anders Carlsson:
>
> Cool, I'll change that!
>
>> So basically, we give Sema a SmallVector of temporaries that we've
>> created. All statement actions check this buffer, and if it's not
>> empty,
>> a CXXExprWithTemporaries is created and wrapped around the current
>> statement, and gets all the temporaries added. Then the buffer is
>> cleared.
>> Is this right?
>>
> We also need to come up with a solid design where it's next to
> impossible to forget to
> have this callback invoked, I'm toying with the idea of adding a new
> FullExprArg type,
> and where the only way to create a FullExprArg from an ExprArg is to
> go through this callback.
>
Here's what I've come up with. A FullExprArg right now is a very
simple wrapper around ExprArg:
class FullExprArg {
ExprArg &Arg;
friend class Action;
FullExprArg(ExprArg& a) : Arg(a) {}
public:
FullExprArg& operator=(void *raw) {
Arg.operator=(raw);
return *this;
}
void* release() { return Arg.release(); }
void* get() { return Arg.get(); }
template<typename T>
T *takeAs() {
return static_cast<T*>(Arg.take());
}
};
Its constructor is private, and the Action class is a friend, so the
only way to make one is to call
FullExprArg Action::FullExpr(ExprArg&);
which will make sure to call ActOnFinishFullExpr.
I'm not entirely happy with this solution since it sidesteps all the
move security we have in the smart pointer classes. Sebastian, do you
have a better idea?
Anders
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090427/88a76562/attachment.html>
More information about the cfe-dev
mailing list