[cfe-dev] [RFC] Preliminary patch to support MSVC __declspec(property)

John McCall rjmccall at apple.com
Mon Dec 17 10:40:23 PST 2012


On Dec 17, 2012, at 6:51 AM, endlessroad1991 at gmail.com wrote:
> Here's a try to summarize implementation detail about __decpspec(property):
> 1. Add a MSPropertyDecl, because:
>     - Property can be private, as long as getter/setter is public. This is different from regular members.
>     - Type of property can be imcomplete, like return type of a member function. This is different from regular members.
>     - We can use it to store how many parameters should be used for getter/setter

All this, plus we don't want code that's scanning for fields to find properties — for example, class layout.  It's just not semantically the same as a field.

> 2. Add a MSPropertyRefExpr, like ObjCPropertyRefExpr. Preserve all (index) parameters for getter/setter calls in ast. This is necessary because (a.v)[1][2] and (a.v[1])[2] are both legal.

This shouldn't be necessary;  I think re-using MemberExpr is fine.  Otherwise you'll have to clone MemberExpr in order to store all the possible type-sugar and base variants (or hoist things into a parent class).

John.



More information about the cfe-dev mailing list