From 631925fe62cf5e24e59fdd5de27c6c43986366b8 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Tue, 23 Jul 2013 23:55:55 +0000 Subject: [PATCH] ObjectiveC migration: more migration to instancetype of NSDictionary methods. llvm-svn: 187008 --- clang/lib/ARCMigrate/ObjCMT.cpp | 19 ++++++++++++++++--- clang/test/ARCMT/objcmt-instancetype.m.result | 12 ++++++------ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/clang/lib/ARCMigrate/ObjCMT.cpp b/clang/lib/ARCMigrate/ObjCMT.cpp index 9048e54..5d53830 100644 --- a/clang/lib/ARCMigrate/ObjCMT.cpp +++ b/clang/lib/ARCMigrate/ObjCMT.cpp @@ -557,8 +557,14 @@ void ObjCMigrateASTConsumer::migrateMethodInstanceType(ASTContext &Ctx, if (OIT_Family == OIT_None) return; // TODO. Many more to come - if (OIT_Family != OIT_Array) - return; + switch (OIT_Family) { + case OIT_Array: + break; + case OIT_Dictionary: + break; + default: + return; + } if (!OM->getResultType()->isObjCIdType()) return; @@ -569,7 +575,14 @@ void ObjCMigrateASTConsumer::migrateMethodInstanceType(ASTContext &Ctx, else if (ObjCImplDecl *ImpDecl = dyn_cast(CDecl)) IDecl = ImpDecl->getClassInterface(); } - if (!IDecl || !IDecl->lookupInheritedClass(&Ctx.Idents.get("NSArray"))) + if (!IDecl) + return; + + if (OIT_Family == OIT_Array && + !IDecl->lookupInheritedClass(&Ctx.Idents.get("NSArray"))) + return; + else if (OIT_Family == OIT_Dictionary && + !IDecl->lookupInheritedClass(&Ctx.Idents.get("NSDictionary"))) return; TypeSourceInfo *TSInfo = OM->getResultTypeSourceInfo(); diff --git a/clang/test/ARCMT/objcmt-instancetype.m.result b/clang/test/ARCMT/objcmt-instancetype.m.result index 00b875f..3b3ee8b 100644 --- a/clang/test/ARCMT/objcmt-instancetype.m.result +++ b/clang/test/ARCMT/objcmt-instancetype.m.result @@ -44,12 +44,12 @@ typedef signed char BOOL; @end @interface NSDictionary (NSDictionaryCreation) -+ (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, ...; -+ (id)dictionaryWithDictionary:(NSDictionary *)dict; -+ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; ++ (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)dictionaryWithDictionary:(NSDictionary *)dict; ++ (instancetype)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - (id)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; - (id)initWithObjectsAndKeys:(id)firstObject, ...; -- 2.7.4