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

Chris Lattner clattner at apple.com
Fri Jul 25 09:53:19 PDT 2008


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?

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.

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

-Chris



More information about the cfe-commits mailing list