[cfe-dev] Objective-C top-level constructs code generation

David Chisnall csdavec at swansea.ac.uk
Mon Aug 11 15:48:50 PDT 2008

Hi Mike,

On 11 Aug 2008, at 23:41, Mike Stump wrote:

> On May 24, 2008, at 10:56 AM, David Chisnall wrote:
>> I've started splitting the Objective-C code generation stuff up  
>> into smaller diffs.

Sadly, I haven't had a chance to do much with this lately.  I still  
have a huge pile of clang diffs sitting on my machine waiting to be  
submitted, and I've made a number of bug fixes in the copy of  
CGObjCGNU that we're using in the back end of a Smalltalk compiler,  
but the copy I'm using there pre-dates Chris introducing clang  
dependencies into this file and I haven't had time to back-port the  
fixes to clang.

> So, this generates:
> CodeGenModule.cpp: In member function ‘void  
> clang::CodeGen::CodeGenModule::EmitObjCClassImplementation(const  
> clang::ObjCImplementationDecl*)’:
> CodeGenModule.cpp:334: warning: ‘ObjTy’ may be used uninitialized  
> in this function
> the code looks like:
>   const llvm::Type *ObjTy;
>   if (!Runtime->LateBoundIVars()) {
>     ObjTy = getTypes().ConvertType(Context.getObjCInterfaceType 
> (ClassDecl));
>     instanceSize = TheTargetData.getABITypeSize(ObjTy);
>   }
>   // Collect information about instance variables.
>   llvm::SmallVector<llvm::Constant*, 16> IvarNames;
>   llvm::SmallVector<llvm::Constant*, 16> IvarTypes;
>   llvm::SmallVector<llvm::Constant*, 16> IvarOffsets;
>   const llvm::StructLayout *Layout =
>     TheTargetData.getStructLayout(cast<llvm::StructType>(ObjTy));
> So, would initializing this to 0 be appropriate?

This would make the warning go away.  It would also be worth adding  
an 'assert(0 && "Late-bound instance variables not yet supported);'  
in an else block here, since there is not yet any code for this,  
which is required by newer ObjC runtimes.


More information about the cfe-dev mailing list