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

John McCall rjmccall at apple.com
Wed Dec 8 14:16:54 PST 2010


On Dec 8, 2010, at 1:47 PM, Douglas Gregor wrote:
> On Dec 8, 2010, at 11:53 AM, Eric Niebler <eric at boostpro.com> wrote:
>>>> 3) Where should the rewrite happen? Is it OK to leave in
>>>> references to the pseudo-field in the AST, or should the AST
>>>> reflect what will actually be executed -- invocations of the
>>>> getters and setters? My instinct tells me that the AST should have
>>>> the pseudo-field, not the getters and setters. Anything else might 
>>>> confuse things like IDEs.
>>> 
>>> The AST should have the pseudo-field (possibly with a special 
>>> "MSPropertyRefExpr" expression type to reference them), and we
>>> should introduce implicit AST nodes (e.g., an ImplicitCastExpr
>>> wrapping a call) to handle the get and put calls. 
>> 
>> I'm afraid I didn't follow that.
> 
> Somehow, you need to represent an expression
> 
>  foo.property
> 
> That probably means creating a new expression node type. This expression node type may be used in an assignment (calling the put operation) or via an lvalue-to-rvalue conversion (calling the get operation), which will be represented via implicitly-generated AST nodes.

I'm a little worried about adopting our current representation for a C++-oriented feature.  Presumably we'd need to allow filling in default arguments, etc., plus a wide range of stuff that we technically have to support with ObjC++ properties but actually haven't gotten around to yet, like what happens when we're doing a compound assignment on an implicit property reference and the getter and setter have really different types.  Really I think this is an argument for improving the representation of all property expressions.

My intuition here is to just rename OK_ObjCProperty to OK_Property instead of differentiating the two cases.  It can mean "this is an entity which can be both read and written to, but requires special code to do so".  The existing hook in Sema for loads (ConvertPropertyForRValue) can easily be modified to handle the MS properties, and we can make BuildBinOp check for OK_Property LHS's and just immediately defer to some better hook.

John.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20101208/627bdff0/attachment.html>


More information about the cfe-dev mailing list