const NSAPI &NS, edit::Commit &commit,
const ParentMap *PMap) {
if (!Msg || Msg->isImplicit() ||
- Msg->getReceiverKind() != ObjCMessageExpr::Instance)
+ (Msg->getReceiverKind() != ObjCMessageExpr::Instance &&
+ Msg->getReceiverKind() != ObjCMessageExpr::SuperInstance))
return false;
const ObjCMethodDecl *Method = Msg->getMethodDecl();
if (!Method)
return false;
SourceRange MsgRange = Msg->getSourceRange();
+ bool ReceiverIsSuper =
+ (Msg->getReceiverKind() == ObjCMessageExpr::SuperInstance);
+ // for 'super' receiver is nullptr.
const Expr *receiver = Msg->getInstanceReceiver();
- bool NeedsParen = subscriptOperatorNeedsParens(receiver);
+ bool NeedsParen =
+ ReceiverIsSuper ? false : subscriptOperatorNeedsParens(receiver);
bool IsGetter = (Msg->getNumArgs() == 0);
if (IsGetter) {
// Find space location range between receiver expression and getter method.
- SourceLocation BegLoc = receiver->getLocEnd();
+ SourceLocation BegLoc =
+ ReceiverIsSuper ? Msg->getSuperLoc() : receiver->getLocEnd();
BegLoc = PP.getLocForEndOfToken(BegLoc);
SourceLocation EndLoc = Msg->getSelectorLoc(0);
SourceRange SpaceRange(BegLoc, EndLoc);
commit.replace(SourceRange(MsgRange.getBegin(), MsgRange.getBegin()), "");
commit.replace(SourceRange(MsgRange.getEnd(), MsgRange.getEnd()), "");
} else {
- SourceRange ReceiverRange = receiver->getSourceRange();
if (NeedsParen)
- commit.insertWrap("(", ReceiverRange, ")");
+ commit.insertWrap("(", receiver->getSourceRange(), ")");
std::string PropertyDotString = ".";
PropertyDotString += Prop->getName();
PropertyDotString += " =";
const Expr *RHS = Args[0];
if (!RHS)
return false;
- SourceLocation BegLoc = ReceiverRange.getEnd();
+ SourceLocation BegLoc =
+ ReceiverIsSuper ? Msg->getSuperLoc() : receiver->getLocEnd();
BegLoc = PP.getLocForEndOfToken(BegLoc);
SourceLocation EndLoc = RHS->getLocStart();
EndLoc = EndLoc.getLocWithOffset(-1);
- (P*) MethodReturnsPObj { return 0; }
@end
+
+// rdar://19140267
+@interface Sub : P
+@end
+
+@implementation Sub
+- (int) Meth : (P*)array {
+ [super setCount : 100];
+
+ [super setCount : [array count]];
+
+ [[super PropertyReturnsPObj] setCount : [array count]];
+
+ [super setCount : (i1+i2*i3 - 100)];
+
+ return [super count] -
+ [(P*)0 count] + [array count] +
+ [fun() count] -
+ [[super PropertyReturnsPObj] count] +
+ [self->obj count];
+}
+@end