[cfe-dev] [clang] declspec(property...) advice
eric at boostpro.com
Sun Feb 6 20:54:27 PST 2011
-----BEGIN PGP SIGNED MESSAGE-----
On 2/7/2011 5:16 AM, John McCall wrote:
> On Feb 6, 2011, at 8:40 AM, Eric Niebler wrote:
>> I've been looking into how to generate those AST nodes. First,
>> obj.setProperty gets parsed into a MemberExpr, then, the paren and the
>> arguments are parsed, and the whole thing gets passed to
>> BuildCallToMemberFunction. I figure if we do all of that in the right
>> places and it type checks, we're golden. Stuff the result into the AST
>> somewhere reasonable and that should do it.
> Right. It should probably just call the appropriate functions on Sema
> to do all this.
>> So that's my current thinking. This, however, is a radical departure
>> from how properties are currently handled in clang, and will require
>> some pretty invasive surgery.
> I think that's basically right. It probably deserves its own expression
> node to wrap the innards, which hopefully would encompass
> compound assignments, non-compound assignments, and unary
In my thinking, we have this hierarchy:
PropertyRefExpr defines pure virtuals for BuildBinaryOp and
BuildUnaryOp, as well as (maybe) ConvertToRValue and ConvertToLValue.
These return an Expr* that points to a new type of expression:
RewrittenExpr is really just a pair of Expr*. The first is the AST
corresponding to what the user actually wrote, e.g. ++obj.prop. The
second is the AST for the rewritten expression:
obj.setProp(obj.getProp()+1). The second is what actually gets used for
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
-----END PGP SIGNATURE-----
More information about the cfe-dev