From: Fariborz Jahanian Date: Thu, 2 Apr 2015 21:36:03 +0000 (+0000) Subject: [Objective-C SDK modernizer]. Patch to convert setter/getter X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b8c44fb363c122cfb9ad55ac06db34dd357e46fa;p=clang [Objective-C SDK modernizer]. Patch to convert setter/getter methods in protocols to their respective property declarations. rdar://19372798 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233977 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/ARCMigrate/ObjCMT.cpp b/lib/ARCMigrate/ObjCMT.cpp index 38ff72a576..c24558f9fa 100644 --- a/lib/ARCMigrate/ObjCMT.cpp +++ b/lib/ARCMigrate/ObjCMT.cpp @@ -48,7 +48,7 @@ class ObjCMigrateASTConsumer : public ASTConsumer { }; void migrateDecl(Decl *D); - void migrateObjCInterfaceDecl(ASTContext &Ctx, ObjCContainerDecl *D); + void migrateObjCContainerDecl(ASTContext &Ctx, ObjCContainerDecl *D); void migrateProtocolConformance(ASTContext &Ctx, const ObjCImplementationDecl *ImpDecl); void CacheObjCNSIntegerTypedefed(const TypedefDecl *TypedefDcl); @@ -578,7 +578,7 @@ static bool IsCategoryNameWithDeprecatedSuffix(ObjCContainerDecl *D) { return false; } -void ObjCMigrateASTConsumer::migrateObjCInterfaceDecl(ASTContext &Ctx, +void ObjCMigrateASTConsumer::migrateObjCContainerDecl(ASTContext &Ctx, ObjCContainerDecl *D) { if (D->isDeprecated() || IsCategoryNameWithDeprecatedSuffix(D)) return; @@ -1876,13 +1876,16 @@ void ObjCMigrateASTConsumer::HandleTranslationUnit(ASTContext &Ctx) { if (ObjCInterfaceDecl *CDecl = dyn_cast(*D)) if (canModify(CDecl)) - migrateObjCInterfaceDecl(Ctx, CDecl); + migrateObjCContainerDecl(Ctx, CDecl); if (ObjCCategoryDecl *CatDecl = dyn_cast(*D)) { if (canModify(CatDecl)) - migrateObjCInterfaceDecl(Ctx, CatDecl); + migrateObjCContainerDecl(Ctx, CatDecl); } - else if (ObjCProtocolDecl *PDecl = dyn_cast(*D)) + else if (ObjCProtocolDecl *PDecl = dyn_cast(*D)) { ObjCProtocolDecls.insert(PDecl->getCanonicalDecl()); + if (canModify(PDecl)) + migrateObjCContainerDecl(Ctx, PDecl); + } else if (const ObjCImplementationDecl *ImpDecl = dyn_cast(*D)) { if ((ASTMigrateActions & FrontendOptions::ObjCMT_ProtocolConformance) && diff --git a/test/ARCMT/objcmt-property.m b/test/ARCMT/objcmt-property.m index 61739efe0a..1ea4109385 100644 --- a/test/ARCMT/objcmt-property.m +++ b/test/ARCMT/objcmt-property.m @@ -238,3 +238,11 @@ DEPRECATED @property (nonatomic, readonly) int Idelegate; @property (nonatomic, readonly) BOOL Bdelegate; @end + +// rdar://19372798 +@protocol NSObject @end +@protocol MyProtocol +- (id)readonlyProperty; +- (id)readWriteProperty; +- (void)setReadWriteProperty:(id)readWriteProperty; +@end diff --git a/test/ARCMT/objcmt-property.m.result b/test/ARCMT/objcmt-property.m.result index ec4ac85127..58f8ce2e07 100644 --- a/test/ARCMT/objcmt-property.m.result +++ b/test/ARCMT/objcmt-property.m.result @@ -211,3 +211,10 @@ DEPRECATED @property (nonatomic, readonly) int Idelegate; @property (nonatomic, readonly) BOOL Bdelegate; @end + +// rdar://19372798 +@protocol NSObject @end +@protocol MyProtocol +@property (nonatomic, readonly, strong) id readonlyProperty; +@property (nonatomic, strong) id readWriteProperty; +@end