ObjectiveC migrator: start migrating to
instancetype methods.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187004 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/ARCMigrate/ObjCMT.cpp b/lib/ARCMigrate/ObjCMT.cpp
index b5aaa3b..9048e54 100644
--- a/lib/ARCMigrate/ObjCMT.cpp
+++ b/lib/ARCMigrate/ObjCMT.cpp
@@ -39,6 +39,8 @@
   void migrateNSEnumDecl(ASTContext &Ctx, const EnumDecl *EnumDcl,
                      const TypedefDecl *TypedefDcl);
   void migrateInstanceType(ASTContext &Ctx, ObjCContainerDecl *CDecl);
+  void migrateMethodInstanceType(ASTContext &Ctx, ObjCContainerDecl *CDecl,
+                                 ObjCMethodDecl *OM);
 
 public:
   std::string MigrateDir;
@@ -547,10 +549,9 @@
   Editor->commit(commit);
 }
 
-static void
-migrateMethodInstanceType(ASTContext &Ctx,
-                          ObjCContainerDecl *CDecl,
-                          ObjCMethodDecl *OM) {
+void ObjCMigrateASTConsumer::migrateMethodInstanceType(ASTContext &Ctx,
+                                                       ObjCContainerDecl *CDecl,
+                                                       ObjCMethodDecl *OM) {
   ObjCInstanceTypeFamily OIT_Family =
     Selector::getInstTypeMethodFamily(OM->getSelector());
   if (OIT_Family == OIT_None)
@@ -571,6 +572,13 @@
   if (!IDecl || !IDecl->lookupInheritedClass(&Ctx.Idents.get("NSArray")))
     return;
   
+  TypeSourceInfo *TSInfo =  OM->getResultTypeSourceInfo();
+  TypeLoc TL = TSInfo->getTypeLoc();
+  SourceRange R = SourceRange(TL.getBeginLoc(), TL.getEndLoc());
+  edit::Commit commit(*Editor);
+  std::string ClassString = "instancetype";
+  commit.replace(R, ClassString);
+  Editor->commit(commit);
 }
 
 void ObjCMigrateASTConsumer::migrateInstanceType(ASTContext &Ctx,