r195137 - ObjectiveC migrator. Do not migrate categories with
Fariborz Jahanian
fjahanian at apple.com
Tue Nov 19 10:17:31 PST 2013
Author: fjahanian
Date: Tue Nov 19 12:17:31 2013
New Revision: 195137
URL: http://llvm.org/viewvc/llvm-project?rev=195137&view=rev
Log:
ObjectiveC migrator. Do not migrate categories with
'Deprecated' name suffix.
Removed:
cfe/trunk/test/ARCMT/objcmt-deprecated-category.m
cfe/trunk/test/ARCMT/objcmt-deprecated-category.m.result
Modified:
cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
cfe/trunk/test/ARCMT/objcmt-instancetype-2.m.result
Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=195137&r1=195136&r2=195137&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Tue Nov 19 12:17:31 2013
@@ -45,7 +45,6 @@ class ObjCMigrateASTConsumer : public AS
void migrateDecl(Decl *D);
void migrateObjCInterfaceDecl(ASTContext &Ctx, ObjCContainerDecl *D);
- void migrateDeprecatedAnnotation(ASTContext &Ctx, ObjCCategoryDecl *CatDecl);
void migrateProtocolConformance(ASTContext &Ctx,
const ObjCImplementationDecl *ImpDecl);
void CacheObjCNSIntegerTypedefed(const TypedefDecl *TypedefDcl);
@@ -426,11 +425,19 @@ static void rewriteToObjCProperty(const
}
}
+static bool IsCategoryNameWithDeprecatedSuffix(ObjCContainerDecl *D) {
+ if (ObjCCategoryDecl *CatDecl = dyn_cast<ObjCCategoryDecl>(D)) {
+ StringRef Name = CatDecl->getName();
+ return Name.endswith("Deprecated");
+ }
+ return false;
+}
+
void ObjCMigrateASTConsumer::migrateObjCInterfaceDecl(ASTContext &Ctx,
ObjCContainerDecl *D) {
- if (D->isDeprecated())
+ if (D->isDeprecated() || IsCategoryNameWithDeprecatedSuffix(D))
return;
-
+
for (ObjCContainerDecl::method_iterator M = D->meth_begin(), MEnd = D->meth_end();
M != MEnd; ++M) {
ObjCMethodDecl *Method = (*M);
@@ -457,39 +464,6 @@ void ObjCMigrateASTConsumer::migrateObjC
}
}
-void ObjCMigrateASTConsumer::migrateDeprecatedAnnotation(ASTContext &Ctx,
- ObjCCategoryDecl *CatDecl) {
- StringRef Name = CatDecl->getName();
- if (!Name.endswith("Deprecated"))
- return;
-
- if (!Ctx.Idents.get("DEPRECATED").hasMacroDefinition())
- return;
-
- ObjCContainerDecl *D = cast<ObjCContainerDecl>(CatDecl);
-
- for (ObjCContainerDecl::method_iterator M = D->meth_begin(), MEnd = D->meth_end();
- M != MEnd; ++M) {
- ObjCMethodDecl *Method = (*M);
- if (Method->isDeprecated() || Method->isImplicit())
- continue;
- // Annotate with DEPRECATED
- edit::Commit commit(*Editor);
- commit.insertBefore(Method->getLocEnd(), " DEPRECATED");
- Editor->commit(commit);
- }
- for (ObjCContainerDecl::prop_iterator P = D->prop_begin(),
- E = D->prop_end(); P != E; ++P) {
- ObjCPropertyDecl *Prop = *P;
- if (Prop->isDeprecated())
- continue;
- // Annotate with DEPRECATED
- edit::Commit commit(*Editor);
- commit.insertAfterToken(Prop->getLocEnd(), " DEPRECATED");
- Editor->commit(commit);
- }
-}
-
static bool
ClassImplementsAllMethodsAndProperties(ASTContext &Ctx,
const ObjCImplementationDecl *ImpDecl,
@@ -1153,7 +1127,7 @@ void ObjCMigrateASTConsumer::migrateProp
void ObjCMigrateASTConsumer::migrateAllMethodInstaceType(ASTContext &Ctx,
ObjCContainerDecl *CDecl) {
- if (CDecl->isDeprecated())
+ if (CDecl->isDeprecated() || IsCategoryNameWithDeprecatedSuffix(CDecl))
return;
// migrate methods which can have instancetype as their result type.
@@ -1627,8 +1601,6 @@ void ObjCMigrateASTConsumer::HandleTrans
migrateObjCInterfaceDecl(Ctx, CDecl);
if (ObjCCategoryDecl *CatDecl = dyn_cast<ObjCCategoryDecl>(*D)) {
migrateObjCInterfaceDecl(Ctx, CatDecl);
- if (ASTMigrateActions & FrontendOptions::ObjCMT_Annotation)
- migrateDeprecatedAnnotation(Ctx, CatDecl);
}
else if (ObjCProtocolDecl *PDecl = dyn_cast<ObjCProtocolDecl>(*D))
ObjCProtocolDecls.insert(PDecl);
Removed: cfe/trunk/test/ARCMT/objcmt-deprecated-category.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-deprecated-category.m?rev=195136&view=auto
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-deprecated-category.m (original)
+++ cfe/trunk/test/ARCMT/objcmt-deprecated-category.m (removed)
@@ -1,48 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-migrate-annotation -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 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result
-// rdar://15337661
-
-#define DEPRECATED __attribute__((deprecated))
-
- at interface NSArray
-- (int)one;
- at end
-
- at interface NSArray (NSDraggingSourceDeprecated)
-
-/* This method is unsafe because it could potentially cause buffer overruns. You should use -getObjects:range: instead.
-*/
-- (void)getObjects:(id __unsafe_unretained [])objects;
-- (void)dep_getObjects:(id __unsafe_unretained [])dep_objects DEPRECATED;
-
- at end
-
- at interface NSArray (NSDeprecated)
-
-/* This method is unsafe because it could potentially cause buffer overruns. You should use -getObjects:range: instead.
-*/
-- (void)dep_getObjects:(id __unsafe_unretained [])dep_objects DEPRECATED;
-- (void)getObjects:(id __unsafe_unretained [])objects;
- at property int P1;
- at property int P2 DEPRECATED;
- at end
-
- at interface NSArray (DraggingSourceDeprecated)
-
-/* This method is unsafe because it could potentially cause buffer overruns. You should use -getObjects:range: instead.
-*/
-- (void)getObjects:(id __unsafe_unretained [])objects;
-- (void)dep_getObjects:(id __unsafe_unretained [])dep_objects DEPRECATED;
- at property int P1;
- at property int P2 DEPRECATED;
-
- at end
-
- at interface NSArray (Deprecated)
-- (void)getObjects:(id __unsafe_unretained [])objects;
-- (void)dep_getObjects:(id __unsafe_unretained [])dep_objects DEPRECATED;
- at property int P1;
- at property int P2 DEPRECATED;
- at end
Removed: cfe/trunk/test/ARCMT/objcmt-deprecated-category.m.result
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-deprecated-category.m.result?rev=195136&view=auto
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-deprecated-category.m.result (original)
+++ cfe/trunk/test/ARCMT/objcmt-deprecated-category.m.result (removed)
@@ -1,48 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-migrate-annotation -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 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result
-// rdar://15337661
-
-#define DEPRECATED __attribute__((deprecated))
-
- at interface NSArray
-- (int)one;
- at end
-
- at interface NSArray (NSDraggingSourceDeprecated)
-
-/* This method is unsafe because it could potentially cause buffer overruns. You should use -getObjects:range: instead.
-*/
-- (void)getObjects:(id __unsafe_unretained [])objects DEPRECATED;
-- (void)dep_getObjects:(id __unsafe_unretained [])dep_objects DEPRECATED;
-
- at end
-
- at interface NSArray (NSDeprecated)
-
-/* This method is unsafe because it could potentially cause buffer overruns. You should use -getObjects:range: instead.
-*/
-- (void)dep_getObjects:(id __unsafe_unretained [])dep_objects DEPRECATED;
-- (void)getObjects:(id __unsafe_unretained [])objects DEPRECATED;
- at property int P1 DEPRECATED;
- at property int P2 DEPRECATED;
- at end
-
- at interface NSArray (DraggingSourceDeprecated)
-
-/* This method is unsafe because it could potentially cause buffer overruns. You should use -getObjects:range: instead.
-*/
-- (void)getObjects:(id __unsafe_unretained [])objects DEPRECATED;
-- (void)dep_getObjects:(id __unsafe_unretained [])dep_objects DEPRECATED;
- at property int P1 DEPRECATED;
- at property int P2 DEPRECATED;
-
- at end
-
- at interface NSArray (Deprecated)
-- (void)getObjects:(id __unsafe_unretained [])objects DEPRECATED;
-- (void)dep_getObjects:(id __unsafe_unretained [])dep_objects DEPRECATED;
- at property int P1 DEPRECATED;
- at property int P2 DEPRECATED;
- at end
Modified: cfe/trunk/test/ARCMT/objcmt-instancetype-2.m.result
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-instancetype-2.m.result?rev=195137&r1=195136&r2=195137&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-instancetype-2.m.result (original)
+++ cfe/trunk/test/ARCMT/objcmt-instancetype-2.m.result Tue Nov 19 12:17:31 2013
@@ -16,10 +16,10 @@ typedef char BOOL;
@class NSString, NSURL;
@interface NSString (NSStringDeprecated)
-+ (instancetype)stringWithContentsOfFile:(NSString *)path __attribute__((availability(macosx,introduced=10.0 ,message="" )));
-+ (instancetype)stringWithContentsOfURL:(NSURL *)url __attribute__((availability(macosx,introduced=10.0 ,message="" )));
-+ (instancetype)stringWithCString:(const char *)bytes length:(NSUInteger)length __attribute__((availability(macosx,introduced=10.0 ,message="" )));
-+ (instancetype)stringWithCString:(const char *)bytes __attribute__((availability(macosx,introduced=10.0 ,message="" )));
++ (id)stringWithContentsOfFile:(NSString *)path __attribute__((availability(macosx,introduced=10.0 ,message="" )));
++ (id)stringWithContentsOfURL:(NSURL *)url __attribute__((availability(macosx,introduced=10.0 ,message="" )));
++ (id)stringWithCString:(const char *)bytes length:(NSUInteger)length __attribute__((availability(macosx,introduced=10.0 ,message="" )));
++ (id)stringWithCString:(const char *)bytes __attribute__((availability(macosx,introduced=10.0 ,message="" )));
@end
More information about the cfe-commits
mailing list