r187062 - ObjectiveC migration: Method candidates for

Fariborz Jahanian fjahanian at apple.com
Wed Jul 24 11:31:42 PDT 2013


Author: fjahanian
Date: Wed Jul 24 13:31:42 2013
New Revision: 187062

URL: http://llvm.org/viewvc/llvm-project?rev=187062&view=rev
Log:
ObjectiveC migration: Method candidates for 
migrating to instancetype can have implicit 'id'
type too.

Modified:
    cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
    cfe/trunk/test/ARCMT/objcmt-instancetype.m
    cfe/trunk/test/ARCMT/objcmt-instancetype.m.result

Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=187062&r1=187061&r2=187062&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Wed Jul 24 13:31:42 2013
@@ -585,11 +585,19 @@ void ObjCMigrateASTConsumer::migrateMeth
            !IDecl->lookupInheritedClass(&Ctx.Idents.get("NSDictionary")))
     return;
   
-  TypeSourceInfo *TSInfo =  OM->getResultTypeSourceInfo();
-  TypeLoc TL = TSInfo->getTypeLoc();
-  SourceRange R = SourceRange(TL.getBeginLoc(), TL.getEndLoc());
+  SourceRange R;
+  std::string ClassString;
+  if (TypeSourceInfo *TSInfo =  OM->getResultTypeSourceInfo()) {
+    TypeLoc TL = TSInfo->getTypeLoc();
+    R = SourceRange(TL.getBeginLoc(), TL.getEndLoc());
+    ClassString = "instancetype";
+  }
+  else {
+    R = SourceRange(OM->getLocStart(), OM->getLocStart());
+    ClassString = OM->isInstanceMethod() ? '-' : '+';
+    ClassString += " (instancetype)";
+  }
   edit::Commit commit(*Editor);
-  std::string ClassString = "instancetype";
   commit.replace(R, ClassString);
   Editor->commit(commit);
 }

Modified: cfe/trunk/test/ARCMT/objcmt-instancetype.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-instancetype.m?rev=187062&r1=187061&r2=187062&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-instancetype.m (original)
+++ cfe/trunk/test/ARCMT/objcmt-instancetype.m Wed Jul 24 13:31:42 2013
@@ -25,7 +25,7 @@ typedef signed char BOOL;
 + (id)arrayWithObject:(id)anObject;
 + (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
 + (id)arrayWithObjects:(id)firstObj, ...;
-+ (id)arrayWithArray:(NSArray *)array;
++ arrayWithArray:(NSArray *)array;
 
 - (id)initWithObjects:(const id [])objects count:(unsigned long)cnt;
 - (id)initWithObjects:(id)firstObj, ...;
@@ -47,7 +47,7 @@ typedef signed char BOOL;
 + (id)dictionary;
 + (id)dictionaryWithObject:(id)object forKey:(id)key;
 + (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
-+ (id)dictionaryWithObjectsAndKeys:(id)firstObject, ...;
++ dictionaryWithObjectsAndKeys:(id)firstObject, ...;
 + (id)dictionaryWithDictionary:(NSDictionary *)dict;
 + (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
 

Modified: cfe/trunk/test/ARCMT/objcmt-instancetype.m.result
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-instancetype.m.result?rev=187062&r1=187061&r2=187062&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-instancetype.m.result (original)
+++ cfe/trunk/test/ARCMT/objcmt-instancetype.m.result Wed Jul 24 13:31:42 2013
@@ -25,7 +25,7 @@ typedef signed char BOOL;
 + (instancetype)arrayWithObject:(id)anObject;
 + (instancetype)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
 + (instancetype)arrayWithObjects:(id)firstObj, ...;
-+ (instancetype)arrayWithArray:(NSArray *)array;
++ (instancetype) arrayWithArray:(NSArray *)array;
 
 - (id)initWithObjects:(const id [])objects count:(unsigned long)cnt;
 - (id)initWithObjects:(id)firstObj, ...;
@@ -47,7 +47,7 @@ typedef signed char BOOL;
 + (instancetype)dictionary;
 + (instancetype)dictionaryWithObject:(id)object forKey:(id)key;
 + (instancetype)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
-+ (instancetype)dictionaryWithObjectsAndKeys:(id)firstObject, ...;
++ (instancetype) dictionaryWithObjectsAndKeys:(id)firstObject, ...;
 + (instancetype)dictionaryWithDictionary:(NSDictionary *)dict;
 + (instancetype)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
 





More information about the cfe-commits mailing list