[cfe-dev] [clang] declspec(property...) advice

Eric Niebler eric at boostpro.com
Sun Feb 6 20:54:27 PST 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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
> inc/dec.

In my thinking, we have this hierarchy:

PropertyRefExpr
  |
  +-----CXXMSPropertyRefExpr
  |
  +-----CXXBorlandPropertyRefExpr
  |
  +-----ObjCPropertyRefExpr

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.

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
codegen.

Thoughts?

- -- 
Eric Niebler
BoostPro Computing
http://www.boostpro.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJNT3sCAAoJEAeJsEDfjLbXBysH/RcFR39ddMOXKicW8yK/hEnU
mVIIjma9zGZcyJlmTDGHcb9+BUkMQrDwpvFLlSTSYHJf9aaOOwNJt/az5sefOJDL
xib7D6lWJ4lMfmVpiszI/WET9TGOD5bxgXZPKaoED58xcboiWNy8X2QrZV2C1utg
XIoKKRo6/cWJ/ZG6Hm/I9Lbo5z6Hh24b9AhbNqgRiCAe62k+n0bzl8ELUCUohvX/
A8rs6s8lSgranGFDIfRje1vrgdgtbUpEJ0PmymkA1Beub5IIUS7jS0yPNpKilOMC
9YkyNPs+MO48mcDUPUKNyCdXbFntrEJWudmPjRoZ+FJxzee2IieyaPByp+0hYXg=
=ucZ0
-----END PGP SIGNATURE-----



More information about the cfe-dev mailing list