Message send to super

Hi,

It appears that, in generating the AST, the following expression:

[super msg];

is being translated to:

[(superclass*)self msg];

Running clang -ast-print confirms this. These two expressions have completely different semantics in Objective-C, and since there appears to be no way of determining whether the user actually performed a cast on self (which is uncommon, but does happen in real code) or sent a message to super (which happens a lot more frequently).

Can anyone suggest a way of distinguishing these two? If not, is it possible to introduce a separate kind of AST node, or a flag in the ObjCMessageExpr indicating if super is the receiver? I have now written the code to produce the correct output for the GNU runtime with this kind of expression, but am currently unable to connect it to anything.

David

Hi,

It appears that, in generating the AST, the following expression:

[super msg];

is being translated to:

[(superclass*)self msg];

This is bad. 'super' 'self' '_cmd' as well as 'this' in C++ etc should all be handled with PreDefinedExpr, just like __func__ is.

Running clang -ast-print confirms this. These two expressions have
completely different semantics in Objective-C, and since there appears
to be no way of determining whether the user actually performed a cast
on self (which is uncommon, but does happen in real code) or sent a
message to super (which happens a lot more frequently).

Right. Use of PreDefinedExpr would be be much more explicit and better in general for clients.

-Chris

Hi David,

As Chris said, this isn't great. The AST reflects a "quick hack" to avoid making API changes (which required more thought). I should have put a FIXME in the code.

Are you going to clean this up? If not, I am happy to put it on my todo list.

Let me know,

snaroff