r180127 - [libclang] Introduce a CXCursor_ObjCSelfExpr cursor, which is the equivalent of CXCursor_CXXThisExpr for C++ code.
Argyrios Kyrtzidis
akyrtzi at gmail.com
Tue Apr 23 13:46:05 PDT 2013
On Apr 23, 2013, at 12:37 PM, Jordan Rose <jordan_rose at apple.com> wrote:
>
> On Apr 23, 2013, at 12:16 , Argyrios Kyrtzidis <akyrtzi at gmail.com> wrote:
>
>> On Apr 23, 2013, at 12:03 PM, Jordan Rose <jordan_rose at apple.com> wrote:
>>
>>> Sorry, why is this right way to implement this? 'self' is very deliberately not a special kind of expression in Objective-C. Why not expose this on the associated ParmVarDecl instead?
>>
>> What is the advantage with that approach ? Whether there is a ParmVarDecl or not seems like an implementation detail of the AST. If you are worried that there is one more cursor to consider, I'd argue the same applies for CXCursor_CXXThisExpr.
>
> CXXThisExpr matches the AST, which matches the C++ standard. There is no Objective-C standard, but certainly 'self' is not treated specially in most cases.
Hmm, since 'self' is not declared anywhere in the source, I consider it somewhat "special".
>
> I can't put my finger on it, but it makes a lot more sense to me to say "is this variable 'self'?"
What are you suggesting exactly, have "self" be a reference of a CXCursor_ParmDecl and introduce a libclang function to answer "is this parameter 'self'" ?
AFAIK you'd only get such a variable via a "'self' ref expression"; there is no other case where libclang is going to return such a thing, so such a function has limited utility.
And unless we start exposing "self" as a CXCursor_ParmDecl "child" of a method (which I don't like) it seems inconsistent that we would report as referenced a ParmDecl that we never reported before in the source.
> than "is this expression 'self'?", especially in init methods where 'self' can be reassigned. 'this' can never be reassigned.
Not sure why CXCursor_ObjCSelfExpr conflicts with 'self' getting reassigned ?
>
> Jordan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130423/d3101287/attachment.html>
More information about the cfe-commits
mailing list