Objective-C patches

Hi Everyone,

Sorry for the patch size...

Please find attached:

sema.diff includes small changes required to make constant strings and message sends to super work. It fixes the AST so super is now a built in decl and it eliminates the warning if NSConstantString is not declared (which, it turns out, it isn't in most real code by the time the first constant string is found). This is not a completely sensible check anyway, since most people cast them to NSString* at creation time. If NSConstantString is declared, it is used, otherwise constant strings are of type id.

ccc.diff includes improved option parsing for a couple of things in ccc that apparently are need to build a lot of real ObjC programs.

isa.diff fixes a small bug where the implicit isa pointer was added to instance variable lists twice (I think this is caused by someone fixing the bug where it wasn't added to the AST at all, but it might just be that I'm incompetent...)

objc.diff is a big diff (sorry!) which tidies up most of Objective-C code generation, provides working implementations for the GNU runtime and mostly-working implementations for the √Čtoil√© runtime. Feel free to edit out anything from GCObjCEtoile.cpp (there are a few changes to match the updated interfaces, but the implementation can all be left out for now since it isn't very heavily tested). This includes support for classes, categories, protocols, selector caching, message sends to the superclass, and constant Objective-C strings.


sema.diff (2.63 KB)

ccc.diff (676 Bytes)

isa.diff (713 Bytes)

objc.diff (83.7 KB)

As a result of off-list comments, I have fixed a number of 'if(' formatting issues and a couple of line-wrap problems, typedef'd llvm::SmallVector<llvm::Constant*, 16> to ConstantVector, and removed the StructGEP helper function which is left over from before that functionality was added to IRBuilder. I don't want to spam everyone, so I'll hold off sending an updated patch until I've received more comments.


Please don't name it ConstantVector. llvm::ConstantVector is something very different. What's wrong with using SmallVector explicitly?

The sema, CCC, isa, looks great, plz apply but remove this line:

+ //IdentifierInfo *NSIdent = &Context.Idents.get("NSConstantString");

and indent this properly:

+ ExprResult ReceiverExpr = new PreDefinedExpr(SourceLocation(), superTy,
+ PreDefinedExpr::ObjCSuper);

Please resend the updated sema patch. Code review is kinda hard if not reviewing the actual code :slight_smile:

Thanks David,