[cfe-dev] Parser Stmt/Expr Owning Pointer

Sebastian Redl sebastian.redl at getdesigned.at
Tue Dec 9 12:16:10 PST 2008


Howard Hinnant wrote:
> On Dec 9, 2008, at 2:39 PM, Sebastian Redl wrote:
>
>   
>> No. The return type is an ExprResult, which is initialized with the  
>> ASTMove. As long as no one gets the idea that using an ASTMove as a  
>> return type is a good thing (it *isn't*), there's no problem.
>>     
>
> Here's one way you can have the compiler enforce that good rule:
>   
While good in principle, I've got a very special case here, because of 
the Parser/Sema separation. To further process the stuff coming from the 
parser in the sema, I'll need another smart pointer there, one that 
actually deals in AST's Expr and Stmt, not just void typedefs. This 
smart pointer must be move-constructible *from ASTOwner*, i.e. have a 
constructor that takes an ASTMove. ASTMove thus must be accessible to 
this new smart pointer.

Further, because of the separation, ASTOwner cannot, in any way, know 
about this smart pointer (in order to make it a friend). This would be a 
serious layering violation.

So ASTMove will have to remain on namespace scope for the time being. 
But I'm considering moving it to a sub-namespace, so that it doesn't 
appear in the clang namespace directly.

Sebastian



More information about the cfe-dev mailing list