[cfe-commits] r53994 - in /cfe/trunk: Driver/RewriteObjC.cpp include/clang/AST/ExprObjC.h lib/Sema/SemaExprObjC.cpp

Steve Naroff snaroff at apple.com
Fri Jul 25 11:39:30 PDT 2008


On Jul 25, 2008, at 12:53 PM, Chris Lattner wrote:

>
> On Jul 24, 2008, at 12:44 PM, Steve Naroff wrote:
>
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> --- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Thu Jul 24 14:44:33 2008
>> @@ -147,7 +147,10 @@
>>
>>  Expr **ArgExprs = reinterpret_cast<Expr **>(Args);
>>  ObjCInterfaceDecl* ClassDecl = 0;
>> +  bool isSuper = false;
>> +
>>  if (!strcmp(receiverName->getName(), "super") &&  
>> getCurMethodDecl()) {
>> +    isSuper = true;
>>    ClassDecl = getCurMethodDecl()->getClassInterface()- 
>> >getSuperClass();
>>    if (!ClassDecl)
>>      return Diag(lbrac, diag::error_no_super_class,
>> @@ -206,11 +209,14 @@
>>  // If we have the ObjCInterfaceDecl* for the class that is receiving
>>  // the message, use that to construct the ObjCMessageExpr.   
>> Otherwise
>>  // pass on the IdentifierInfo* for the class.
>> -  if (ClassDecl)
>> -    return new ObjCMessageExpr(ClassDecl, Sel, returnType, Method,
>> +  // FIXME: need to do a better job handling 'super' usage within  
>> a class
>> +  // For now, we simply pass the "super" identifier through (which  
>> isn't
>> +  // consistent with instance methods.
>> +  if (isSuper || !ClassDecl)
>> +    return new ObjCMessageExpr(receiverName, Sel, returnType,  
>> Method,
>>                               lbrac, rbrac, ArgExprs, NumArgs);
>>  else
>> -    return new ObjCMessageExpr(receiverName, Sel, returnType,  
>> Method,
>> +    return new ObjCMessageExpr(ClassDecl, Sel, returnType, Method,
>>                               lbrac, rbrac, ArgExprs, NumArgs);
>> }
>
> Steve, what is the right fix here?
>

Not sure (which I why I added the FIXME's).

> I wasn't aware that ObjCMessageExpr bit mangles in an identifier  
> into the receiver slot in certain cases.  When is this used?  It  
> sounds like we're missing an appropriate Expr node here.
>
> In the case of Super, instead of bitmangling in the "super"  
> identifier, you should make a new PreDefinedExpr(ObjCSuper) node,  
> and it should be the receiver.
>

I believe I tried this and it didn't fit.

I will dig into this and try and clean it up. It's a tricky area and I  
might as well invest some time (while it's fairly fresh in my mind).

> Also, can you please add some comments above the ObjCMessageExpr  
> class explaining what it is all about and giving an example?
>

I'll do this as part of the cleanup...

snaroff

> -Chris




More information about the cfe-commits mailing list