[cfe-dev] Objective-C tidy up

David Chisnall theraven at sucs.org
Tue Jun 3 04:39:49 PDT 2008

On 3 Jun 2008, at 07:33, Chris Lattner wrote:

> On Jun 1, 2008, at 10:07 AM, David Chisnall wrote:
>> Hi,
>> Here's the next installment of my ObjC changes.  This is fairly  
>> minor, although the diff is quite large.  The biggest change is  
>> that I've moved common code used to generate Objective-C methods  
>> and C functions out into a separate method in CodeGenFunction and  
>> I've moved GenerateObjCMethod from CodeGenFunction.cpp into  
>> CGObjC.cpp where it should probably have been from the start.
>> This diff also includes small changes to Sema to make self and _cmd  
>> implicit parameters.  At some point, I imagine these will be pulled  
>> out into a superclass for method decls that can be used for both  
>> Objective-C and C++ methods.
> Why should self and _cmd be ParmVarDecls?  Shouldn't they be  
> PredefinedExprs?

That's what I did to start with, but PredefinedExprs need special  
handling in codegen, while ParmVarDecls are automatically turned into  
loads of %var.addr.  Since they are parameters, and since it  
simplifies the rest of the implementation, it seemed like a  
ParmVarDecl would be the right thing to choose.

> +++ include/clang/AST/DeclObjC.h	(working copy)
> @@ -91,7 +91,8 @@
>   // The following are only used for method definitions, null  
> otherwise.
>   // FIXME: space savings opportunity, consider a sub-class.
>   Stmt *Body;
> -  ParmVarDecl *SelfDecl;
> +  // Decls for implicit parameters
> +  llvm::SmallVector<ParmVarDecl *, 2> ImplicitParamInfo;
> If there are always exactly two of these, just use:
> ParmVarDecl *ImplicitParamInfo[2];

There will be three for the √Čtoil√© runtime.  Someone expressed  
interest in porting Objective-C to the COLA runtime from the  
Viewpoints Research Institute as well, and this would have somewhere  
between one and four depending on how they did it.


More information about the cfe-dev mailing list