diff --git a/clang/lib/ARCMigrate/ObjCMT.cpp b/clang/lib/ARCMigrate/ObjCMT.cpp index a6aa4c74024f..7efc81f18b18 100644 --- a/clang/lib/ARCMigrate/ObjCMT.cpp +++ b/clang/lib/ARCMigrate/ObjCMT.cpp @@ -48,7 +48,7 @@ class ObjCMigrateASTConsumer : public ASTConsumer { const ObjCImplementationDecl *ImpDecl); void migrateNSEnumDecl(ASTContext &Ctx, const EnumDecl *EnumDcl, const TypedefDecl *TypedefDcl); - void migrateMethods(ASTContext &Ctx, ObjCContainerDecl *CDecl); + void migrateAllMethodInstaceType(ASTContext &Ctx, ObjCContainerDecl *CDecl); void migrateMethodInstanceType(ASTContext &Ctx, ObjCContainerDecl *CDecl, ObjCMethodDecl *OM); bool migrateProperty(ASTContext &Ctx, ObjCContainerDecl *D, ObjCMethodDecl *OM); @@ -335,12 +335,14 @@ void ObjCMigrateASTConsumer::migrateObjCInterfaceDecl(ASTContext &Ctx, if (Method->isDeprecated()) continue; migrateProperty(Ctx, D, Method); - migrateNsReturnsInnerPointer(Ctx, Method); + if (ASTMigrateActions & FrontendOptions::ObjCMT_Annotation) + migrateNsReturnsInnerPointer(Ctx, Method); } for (ObjCContainerDecl::prop_iterator P = D->prop_begin(), E = D->prop_end(); P != E; ++P) { ObjCPropertyDecl *Prop = *P; - if (!P->isDeprecated()) + if ((ASTMigrateActions & FrontendOptions::ObjCMT_Annotation) && + !P->isDeprecated()) migratePropertyNsReturnsInnerPointer(Ctx, Prop); } } @@ -867,7 +869,7 @@ void ObjCMigrateASTConsumer::migratePropertyNsReturnsInnerPointer(ASTContext &Ct Editor->commit(commit); } -void ObjCMigrateASTConsumer::migrateMethods(ASTContext &Ctx, +void ObjCMigrateASTConsumer::migrateAllMethodInstaceType(ASTContext &Ctx, ObjCContainerDecl *CDecl) { if (CDecl->isDeprecated()) return; @@ -1331,9 +1333,11 @@ void ObjCMigrateASTConsumer::HandleTranslationUnit(ASTContext &Ctx) { D != DEnd; ++D) { if (unsigned FID = PP.getSourceManager().getFileID((*D)->getLocation()).getHashValue()) - if (FileId && FileId != FID) - AnnotateImplicitBridging(Ctx); - + if (FileId && FileId != FID) { + if (ASTMigrateActions & FrontendOptions::ObjCMT_Annotation) + AnnotateImplicitBridging(Ctx); + } + if (ObjCInterfaceDecl *CDecl = dyn_cast(*D)) migrateObjCInterfaceDecl(Ctx, CDecl); if (ObjCCategoryDecl *CatDecl = dyn_cast(*D)) @@ -1341,26 +1345,35 @@ void ObjCMigrateASTConsumer::HandleTranslationUnit(ASTContext &Ctx) { else if (ObjCProtocolDecl *PDecl = dyn_cast(*D)) ObjCProtocolDecls.insert(PDecl); else if (const ObjCImplementationDecl *ImpDecl = - dyn_cast(*D)) - migrateProtocolConformance(Ctx, ImpDecl); + dyn_cast(*D)) { + if (ASTMigrateActions & FrontendOptions::ObjCMT_ProtocolConformance) + migrateProtocolConformance(Ctx, ImpDecl); + } else if (const EnumDecl *ED = dyn_cast(*D)) { DeclContext::decl_iterator N = D; ++N; if (N != DEnd) - if (const TypedefDecl *TD = dyn_cast(*N)) - migrateNSEnumDecl(Ctx, ED, TD); + if (const TypedefDecl *TD = dyn_cast(*N)) { + if (ASTMigrateActions & FrontendOptions::ObjCMT_NsMacros) + migrateNSEnumDecl(Ctx, ED, TD); + } + } + else if (const FunctionDecl *FD = dyn_cast(*D)) { + if (ASTMigrateActions & FrontendOptions::ObjCMT_Annotation) + migrateCFAnnotation(Ctx, FD); } - else if (const FunctionDecl *FD = dyn_cast(*D)) - migrateCFAnnotation(Ctx, FD); if (ObjCContainerDecl *CDecl = dyn_cast(*D)) { // migrate methods which can have instancetype as their result type. - migrateMethods(Ctx, CDecl); + if (ASTMigrateActions & FrontendOptions::ObjCMT_Instancetype) + migrateAllMethodInstaceType(Ctx, CDecl); // annotate methods with CF annotations. - migrateARCSafeAnnotation(Ctx, CDecl); + if (ASTMigrateActions & FrontendOptions::ObjCMT_Annotation) + migrateARCSafeAnnotation(Ctx, CDecl); } } - AnnotateImplicitBridging(Ctx); + if (ASTMigrateActions & FrontendOptions::ObjCMT_Annotation) + AnnotateImplicitBridging(Ctx); } Rewriter rewriter(Ctx.getSourceManager(), Ctx.getLangOpts()); diff --git a/clang/test/ARCMT/objcmt-arc-cf-annotations.m b/clang/test/ARCMT/objcmt-arc-cf-annotations.m index 029eaaf7794c..9772825b2934 100644 --- a/clang/test/ARCMT/objcmt-arc-cf-annotations.m +++ b/clang/test/ARCMT/objcmt-arc-cf-annotations.m @@ -1,5 +1,5 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -fblocks -objcmt-migrate-readwrite-property -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11 +// RUN: %clang_cc1 -fblocks -objcmt-migrate-annotation -objcmt-migrate-instancetype -objcmt-migrate-readwrite-property -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11 // RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result // RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result diff --git a/clang/test/ARCMT/objcmt-arc-cf-annotations.m.result b/clang/test/ARCMT/objcmt-arc-cf-annotations.m.result index 45f4f8316bc1..1963d832ac0c 100644 --- a/clang/test/ARCMT/objcmt-arc-cf-annotations.m.result +++ b/clang/test/ARCMT/objcmt-arc-cf-annotations.m.result @@ -1,5 +1,5 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -fblocks -objcmt-migrate-readwrite-property -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11 +// RUN: %clang_cc1 -fblocks -objcmt-migrate-annotation -objcmt-migrate-instancetype -objcmt-migrate-readwrite-property -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11 // RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result // RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result diff --git a/clang/test/ARCMT/objcmt-instancetype-2.m b/clang/test/ARCMT/objcmt-instancetype-2.m index b19160e3dc49..93db1fdec8d4 100644 --- a/clang/test/ARCMT/objcmt-instancetype-2.m +++ b/clang/test/ARCMT/objcmt-instancetype-2.m @@ -1,5 +1,5 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-all -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 +// RUN: %clang_cc1 -objcmt-migrate-instancetype -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 // RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result // RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result diff --git a/clang/test/ARCMT/objcmt-instancetype-2.m.result b/clang/test/ARCMT/objcmt-instancetype-2.m.result index 90a3f5ec9aad..89ce243335be 100644 --- a/clang/test/ARCMT/objcmt-instancetype-2.m.result +++ b/clang/test/ARCMT/objcmt-instancetype-2.m.result @@ -1,5 +1,5 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-all -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 +// RUN: %clang_cc1 -objcmt-migrate-instancetype -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 // RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result // RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result diff --git a/clang/test/ARCMT/objcmt-instancetype.m b/clang/test/ARCMT/objcmt-instancetype.m index d8fc88a88a53..b25f9d884939 100644 --- a/clang/test/ARCMT/objcmt-instancetype.m +++ b/clang/test/ARCMT/objcmt-instancetype.m @@ -1,5 +1,5 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-all -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 +// RUN: %clang_cc1 -objcmt-migrate-instancetype -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 // RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result // RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result diff --git a/clang/test/ARCMT/objcmt-instancetype.m.result b/clang/test/ARCMT/objcmt-instancetype.m.result index 9f4091390543..a355d13c4241 100644 --- a/clang/test/ARCMT/objcmt-instancetype.m.result +++ b/clang/test/ARCMT/objcmt-instancetype.m.result @@ -1,5 +1,5 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-all -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 +// RUN: %clang_cc1 -objcmt-migrate-instancetype -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 // RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result // RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result diff --git a/clang/test/ARCMT/objcmt-ns-macros.m b/clang/test/ARCMT/objcmt-ns-macros.m index 14af8cbda17d..4ae42c496ef2 100644 --- a/clang/test/ARCMT/objcmt-ns-macros.m +++ b/clang/test/ARCMT/objcmt-ns-macros.m @@ -1,5 +1,5 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-all -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 +// RUN: %clang_cc1 -objcmt-migrate-ns-macros -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 // RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result diff --git a/clang/test/ARCMT/objcmt-ns-macros.m.result b/clang/test/ARCMT/objcmt-ns-macros.m.result index 2c3fcf8c34e1..2a99d4e13b24 100644 --- a/clang/test/ARCMT/objcmt-ns-macros.m.result +++ b/clang/test/ARCMT/objcmt-ns-macros.m.result @@ -1,5 +1,5 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-all -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 +// RUN: %clang_cc1 -objcmt-migrate-ns-macros -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 // RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result diff --git a/clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m b/clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m index ce8c2c65a49b..bec0c4b249d9 100644 --- a/clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m +++ b/clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m @@ -1,5 +1,5 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-readwrite-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 +// RUN: %clang_cc1 -objcmt-migrate-annotation -objcmt-migrate-readwrite-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 // RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result diff --git a/clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m.result b/clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m.result index 95df805ee4fe..438b5bd5a37c 100644 --- a/clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m.result +++ b/clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m.result @@ -1,5 +1,5 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-readwrite-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 +// RUN: %clang_cc1 -objcmt-migrate-annotation -objcmt-migrate-readwrite-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 // RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result diff --git a/clang/test/ARCMT/objcmt-protocol-conformance.m b/clang/test/ARCMT/objcmt-protocol-conformance.m index a0a160e917ff..7bc7d938177f 100644 --- a/clang/test/ARCMT/objcmt-protocol-conformance.m +++ b/clang/test/ARCMT/objcmt-protocol-conformance.m @@ -1,5 +1,5 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-all -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 +// RUN: %clang_cc1 -objcmt-migrate-protocol-conformance -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 // RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result diff --git a/clang/test/ARCMT/objcmt-protocol-conformance.m.result b/clang/test/ARCMT/objcmt-protocol-conformance.m.result index d6cd44483cbc..dc0874c88f22 100644 --- a/clang/test/ARCMT/objcmt-protocol-conformance.m.result +++ b/clang/test/ARCMT/objcmt-protocol-conformance.m.result @@ -1,5 +1,5 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-all -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 +// RUN: %clang_cc1 -objcmt-migrate-protocol-conformance -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 // RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result