diff options
| -rw-r--r-- | clang/lib/ARCMigrate/ObjCMT.cpp | 16 | ||||
| -rw-r--r-- | clang/test/ARCMT/objcmt-instancetype.m | 4 | ||||
| -rw-r--r-- | clang/test/ARCMT/objcmt-instancetype.m.result | 4 |
3 files changed, 16 insertions, 8 deletions
diff --git a/clang/lib/ARCMigrate/ObjCMT.cpp b/clang/lib/ARCMigrate/ObjCMT.cpp index 5d538300228..bd6e97c781b 100644 --- a/clang/lib/ARCMigrate/ObjCMT.cpp +++ b/clang/lib/ARCMigrate/ObjCMT.cpp @@ -585,11 +585,19 @@ void ObjCMigrateASTConsumer::migrateMethodInstanceType(ASTContext &Ctx, !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); } diff --git a/clang/test/ARCMT/objcmt-instancetype.m b/clang/test/ARCMT/objcmt-instancetype.m index 5e4f886893a..32f84d52dbf 100644 --- a/clang/test/ARCMT/objcmt-instancetype.m +++ b/clang/test/ARCMT/objcmt-instancetype.m @@ -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; diff --git a/clang/test/ARCMT/objcmt-instancetype.m.result b/clang/test/ARCMT/objcmt-instancetype.m.result index 3b3ee8bcc69..af06e67e2ad 100644 --- a/clang/test/ARCMT/objcmt-instancetype.m.result +++ b/clang/test/ARCMT/objcmt-instancetype.m.result @@ -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; |

