ExprTy *ReceiverExpr = 0;
// Parse receiver
if (Tok.is(tok::identifier) &&
- Actions.isTypeName(*Tok.getIdentifierInfo(), CurScope)) {
+ (Actions.isTypeName(*Tok.getIdentifierInfo(), CurScope)
+ || !strcmp(Tok.getIdentifierInfo()->getName(), "super"))) {
ReceiverName = Tok.getIdentifierInfo();
ConsumeToken();
} else {
// We've just parsed a keyword message.
if (ReceiverName)
- return Actions.ActOnClassMessage(ReceiverName, Sel, LBracloc, RBracloc,
+ return Actions.ActOnClassMessage(CurScope,
+ ReceiverName, Sel, LBracloc, RBracloc,
&KeyExprs[0]);
return Actions.ActOnInstanceMessage(ReceiverExpr, Sel, LBracloc, RBracloc,
&KeyExprs[0]);
// ArgExprs is optional - if it is present, the number of expressions
// is obtained from Sel.getNumArgs().
virtual ExprResult ActOnClassMessage(
+ Scope *S,
IdentifierInfo *receivingClassName, Selector Sel,
SourceLocation lbrac, SourceLocation rbrac, ExprTy **ArgExprs);
// ArgExprs is optional - if it is present, the number of expressions
// is obtained from Sel.getNumArgs().
Sema::ExprResult Sema::ActOnClassMessage(
+ Scope *S,
IdentifierInfo *receiverName, Selector Sel,
SourceLocation lbrac, SourceLocation rbrac, ExprTy **Args)
{
assert(receiverName && "missing receiver class name");
Expr **ArgExprs = reinterpret_cast<Expr **>(Args);
- ObjcInterfaceDecl* ClassDecl = getObjCInterfaceDecl(receiverName);
+ ObjcInterfaceDecl* ClassDecl = 0;
+ if (!strcmp(receiverName->getName(), "super") && CurMethodDecl) {
+ ClassDecl = CurMethodDecl->getClassInterface()->getSuperClass();
+ if (CurMethodDecl->isInstance()) {
+ IdentifierInfo &II = Context.Idents.get("self");
+ ExprResult ReceiverExpr = ActOnIdentifierExpr(S, lbrac, II,
+ false);
+ QualType superTy = Context.getObjcInterfaceType(ClassDecl);
+ superTy = Context.getPointerType(superTy);
+ ReceiverExpr = ActOnCastExpr(SourceLocation(), superTy.getAsOpaquePtr(),
+ SourceLocation(), ReceiverExpr.Val);
+
+ return ActOnInstanceMessage(ReceiverExpr.Val, Sel, lbrac, rbrac,
+ Args);
+ }
+ // class method
+ if (ClassDecl)
+ receiverName = ClassDecl->getIdentifier();
+ }
+ else
+ ClassDecl = getObjCInterfaceDecl(receiverName);
ObjcMethodDecl *Method = ClassDecl->lookupClassMethod(Sel);
QualType returnType;