[cfe-commits] r61885 - in /cfe/trunk: include/clang/AST/Expr.h lib/AST/StmtPrinter.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaInit.cpp

Douglas Gregor dgregor at apple.com
Wed Jan 7 13:59:55 PST 2009


On Jan 7, 2009, at 1:40 PM, Chris Lattner wrote:

>
> On Jan 7, 2009, at 1:26 PM, Douglas Gregor wrote:
>
>> Author: dgregor
>> Date: Wed Jan  7 15:26:07 2009
>> New Revision: 61885
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=61885&view=rev
>> Log:
>> Fix printing of member references to avoid displaying implicitly- 
>> generated member references, e.g., for anonymous struct/unions or  
>> implicit 'this' in member functions
>
> hi Doug,

> I think this is the wrong approach.  Given something like this:
>
> struct foo {
>  int X;
>  int Y() {
>    return X;
>  }
> };
>
> I think it would make more sense to model "X" as an  
> ImplicitThisFieldDeclRefExpr (or something like that) than as a  
> memberexpr with an implicit cxxthisexpr.  This more naturally  
> followed the source.  One specific problem is that MemberExpr would  
> have to know how to handle "implicit this" in getSourceRange() for  
> example.


I really think this should be some form of MemberExpr (or subclass  
thereof), because both semantic analysis and codegen need to treat  
these as member expressions, and we don't want to push those clients  
into dealing with ImplicitThisFieldDeclRefExpr or  
ImplicitAnonStructUnionFieldRefExpr separately. Plus, we may need to  
introduce implicit casts on "this" to turn it into a base class  
pointer, and we need somewhere in the AST to store them.

My patch isn't right, though. The "Implicit" flag should really only  
occur in MemberExpr, not all the way up in Expr, and MemberExpr can  
use that to get the source ranges correct.

	- Doug



More information about the cfe-commits mailing list