summaryrefslogtreecommitdiffstats
path: root/clang/lib/ARCMigrate/ObjCMT.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2013-08-02 20:54:18 +0000
committerFariborz Jahanian <fjahanian@apple.com>2013-08-02 20:54:18 +0000
commit9275c688ea050b0a2be88cf8b1b038051e7c9085 (patch)
treee1f677381195326f62a1e9eb64ad7d5000ae1898 /clang/lib/ARCMigrate/ObjCMT.cpp
parentfcf67781726d052158bacdbb13e271be5c8c5a94 (diff)
downloadbcm5719-llvm-9275c688ea050b0a2be88cf8b1b038051e7c9085.tar.gz
bcm5719-llvm-9275c688ea050b0a2be88cf8b1b038051e7c9085.zip
ObjectiveC migrator: Add another family of factory
methods which can be migrated to instancetype. llvm-svn: 187672
Diffstat (limited to 'clang/lib/ARCMigrate/ObjCMT.cpp')
-rw-r--r--clang/lib/ARCMigrate/ObjCMT.cpp30
1 files changed, 23 insertions, 7 deletions
diff --git a/clang/lib/ARCMigrate/ObjCMT.cpp b/clang/lib/ARCMigrate/ObjCMT.cpp
index bd1f57f9f8a..706a4ec1065 100644
--- a/clang/lib/ARCMigrate/ObjCMT.cpp
+++ b/clang/lib/ARCMigrate/ObjCMT.cpp
@@ -42,7 +42,8 @@ class ObjCMigrateASTConsumer : public ASTConsumer {
void migrateMethodInstanceType(ASTContext &Ctx, ObjCContainerDecl *CDecl,
ObjCMethodDecl *OM);
void migrateFactoryMethod(ASTContext &Ctx, ObjCContainerDecl *CDecl,
- ObjCMethodDecl *OM);
+ ObjCMethodDecl *OM,
+ ObjCInstanceTypeFamily OIT_Family = OIT_None);
public:
std::string MigrateDir;
@@ -575,12 +576,12 @@ void ObjCMigrateASTConsumer::migrateMethodInstanceType(ASTContext &Ctx,
ObjCMethodDecl *OM) {
ObjCInstanceTypeFamily OIT_Family =
Selector::getInstTypeMethodFamily(OM->getSelector());
- if (OIT_Family == OIT_None) {
- migrateFactoryMethod(Ctx, CDecl, OM);
- return;
- }
+
std::string ClassName;
switch (OIT_Family) {
+ case OIT_None:
+ migrateFactoryMethod(Ctx, CDecl, OM);
+ return;
case OIT_Array:
ClassName = "NSArray";
break;
@@ -590,7 +591,8 @@ void ObjCMigrateASTConsumer::migrateMethodInstanceType(ASTContext &Ctx,
case OIT_MemManage:
ClassName = "NSObject";
break;
- default:
+ case OIT_Singleton:
+ migrateFactoryMethod(Ctx, CDecl, OM, OIT_Singleton);
return;
}
if (!OM->getResultType()->isObjCIdType())
@@ -624,7 +626,8 @@ void ObjCMigrateASTConsumer::migrateInstanceType(ASTContext &Ctx,
void ObjCMigrateASTConsumer::migrateFactoryMethod(ASTContext &Ctx,
ObjCContainerDecl *CDecl,
- ObjCMethodDecl *OM) {
+ ObjCMethodDecl *OM,
+ ObjCInstanceTypeFamily OIT_Family) {
if (OM->isInstanceMethod() || !OM->getResultType()->isObjCIdType())
return;
@@ -647,6 +650,19 @@ void ObjCMigrateASTConsumer::migrateFactoryMethod(ASTContext &Ctx,
IdentifierInfo *MethodIdName = OM->getSelector().getIdentifierInfoForSlot(0);
std::string MethodName = MethodIdName->getName();
+ if (OIT_Family == OIT_Singleton) {
+ StringRef STRefMethodName(MethodName);
+ size_t len = 0;
+ if (STRefMethodName.startswith("standard"))
+ len = strlen("standard");
+ else if (STRefMethodName.startswith("shared"))
+ len = strlen("shared");
+ else if (STRefMethodName.startswith("default"))
+ len = strlen("default");
+ else
+ return;
+ MethodName = STRefMethodName.substr(len);
+ }
std::string MethodNameSubStr = MethodName.substr(0, 3);
StringRef MethodNamePrefix(MethodNameSubStr);
std::string StringLoweredMethodNamePrefix = MethodNamePrefix.lower();
OpenPOWER on IntegriCloud