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);
}
}
+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);
}
}
-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,
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.
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);
+++ /dev/null
-// 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))
-
-@interface NSArray
-- (int)one;
-@end
-
-@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;
-
-@end
-
-@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;
-@property int P1;
-@property int P2 DEPRECATED;
-@end
-
-@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;
-@property int P1;
-@property int P2 DEPRECATED;
-
-@end
-
-@interface NSArray (Deprecated)
-- (void)getObjects:(id __unsafe_unretained [])objects;
-- (void)dep_getObjects:(id __unsafe_unretained [])dep_objects DEPRECATED;
-@property int P1;
-@property int P2 DEPRECATED;
-@end
+++ /dev/null
-// 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))
-
-@interface NSArray
-- (int)one;
-@end
-
-@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;
-
-@end
-
-@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;
-@property int P1 DEPRECATED;
-@property int P2 DEPRECATED;
-@end
-
-@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;
-@property int P1 DEPRECATED;
-@property int P2 DEPRECATED;
-
-@end
-
-@interface NSArray (Deprecated)
-- (void)getObjects:(id __unsafe_unretained [])objects DEPRECATED;
-- (void)dep_getObjects:(id __unsafe_unretained [])dep_objects DEPRECATED;
-@property int P1 DEPRECATED;
-@property int P2 DEPRECATED;
-@end
@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