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

Argiris Kirtzidis akyrtzi at gmail.com
Sat Jun 21 03:17:15 PDT 2008

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 ?


More information about the cfe-dev mailing list