'super' nailed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44025 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Parse/ParseObjc.cpp b/Parse/ParseObjc.cpp
index c3dae85..19d32bd 100644
--- a/Parse/ParseObjc.cpp
+++ b/Parse/ParseObjc.cpp
@@ -1237,7 +1237,8 @@
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 {
@@ -1308,7 +1309,8 @@
// 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]);
diff --git a/Sema/Sema.h b/Sema/Sema.h
index 4c66e10..a443c94 100644
--- a/Sema/Sema.h
+++ b/Sema/Sema.h
@@ -565,6 +565,7 @@
// 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);
diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp
index 124eb14..643f586 100644
--- a/Sema/SemaExpr.cpp
+++ b/Sema/SemaExpr.cpp
@@ -2060,13 +2060,34 @@
// 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;
diff --git a/include/clang/Parse/Action.h b/include/clang/Parse/Action.h
index 7f2ca69..bfbcfb9 100644
--- a/include/clang/Parse/Action.h
+++ b/include/clang/Parse/Action.h
@@ -591,6 +591,7 @@
// 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,