summaryrefslogtreecommitdiffstats
path: root/lib/ARCMigrate/ObjCMT.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2014-12-09 22:36:47 +0000
committerFariborz Jahanian <fjahanian@apple.com>2014-12-09 22:36:47 +0000
commit7894c14c006941684f6c8964ed71c9b14c3f0edb (patch)
treeee654ba17dc514a6572fcb05fc7fac67e5612578 /lib/ARCMigrate/ObjCMT.cpp
parent0fb730a9672c49efdbfb202ba1416806919c6589 (diff)
Objective-C SDK modernizer. Modernize to use
property-dot-syntax when receiver is 'super'. rdar://19140267 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223846 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ARCMigrate/ObjCMT.cpp')
-rw-r--r--lib/ARCMigrate/ObjCMT.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/ARCMigrate/ObjCMT.cpp b/lib/ARCMigrate/ObjCMT.cpp
index af9c472550..d017acf527 100644
--- a/lib/ARCMigrate/ObjCMT.cpp
+++ b/lib/ARCMigrate/ObjCMT.cpp
@@ -242,7 +242,8 @@ namespace {
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)
@@ -260,12 +261,17 @@ namespace {
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);
@@ -285,9 +291,8 @@ namespace {
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 += " =";
@@ -295,7 +300,8 @@ namespace {
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);