[cfe-dev] module.diff [Re: Continuing Adventures with Objective-C]

Devang Patel dpatel at apple.com
Fri May 16 13:39:18 PDT 2008


On May 13, 2008, at 9:22 AM, David Chisnall wrote:

> module.diff contains the runtime-agnostic code for generating module- 
> level ObjC constructs (classes, categories and protocols).  This  
> depends on the new runtime interface since the old one did not have  
> methods for doing any of this.

> +void CodeGenModule::EmitObjCProtocolImplementation(const  
> ObjCProtocolDecl *PD){
> +  llvm::SmallVector<std::string, 16> Protocols;
> +  for(unsigned i=0 ; i<PD->getNumReferencedProtocols() ; i++)
> +  {
> +    Protocols.push_back(PD->getReferencedProtocols()[i]->getName());
> +  }

Preferred coding style here is
	for (unsigned i = 0, e = PD->getNumReferencedProtocols(); i != e; i++)
	  Protocols.push_back(PD->getReferencedProtocols()[i]->getName());

> +  for(ObjCProtocolDecl::instmeth_iterator iter = PD- 
> >instmeth_begin() ;
> +      iter != PD->instmeth_end() ; iter++) {

   for(ObjCProtocolDecl::instmeth_iterator iter = PD->instmeth_begin(),
       iterEnd = PD->instmeth_end() ; iter != iterEnd  iter++) {

This avoids invoking end() after each iteration.
-
Devang




More information about the cfe-dev mailing list