[cfe-dev] [PATCH]: Parsing for C++ classes

Chris Lattner clattner at apple.com
Sat Jun 21 11:58:46 PDT 2008

On Jun 21, 2008, at 3:17 AM, Argiris Kirtzidis wrote:

> Chris Lattner wrote:
>> On Jun 20, 2008, at 11:13 AM, Eli Friedman wrote:
>>> In Sema::ActOnIdentifierExpr:
>>> +      // FIXME: Should this use a new expr for a direct  
>>> reference, instead of
>>> +      // turning it into "this->field" ? Or else a MemberExpr  
>>> with null base ?
>>> +      ExprResult ThisExpr = ActOnCXXThis(Loc);
>>> +      return new MemberExpr(static_cast<Expr*>(ThisExpr.Val),
>>> +                            true, FD, Loc, FD->getType());
>>> I'd say this is fine, except that you should use an empty
>>> SourceLocation for the artificial "this" so it's distinguishable  
>>> from
>>> a real MemberExpr.  clang currently uses this technique for
>>> initializer lists.
>> Great catch.  I'd strongly prefer to represent "field" and "this- 
>> >field" differently.  The former should be a DeclRefExpr and the  
>> later should be a member expr.  We are still trying to untangle the  
>> ObjC front-end from this early mistake.
> DeclRefExpr is "A reference to a declared variable, function, enum,  
> etc." and accepts a ValueDecl. Is it appropriate to change it to  
> accept a NamedDecl so that a CXXFieldDecl can be passed ?

Yeah, I think that's ok.  If you think a new *Expr is appropriate,  
that would also be fine with me too.

Thanks Argiris,


More information about the cfe-dev mailing list