]> granicus.if.org Git - clang/commitdiff
ObjectiveC migrator. Ignore migrating 'deprecated'
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 17 Sep 2013 21:56:04 +0000 (21:56 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 17 Sep 2013 21:56:04 +0000 (21:56 +0000)
entities. // rdar://14989365

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190890 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ARCMigrate/ObjCMT.cpp
test/ARCMT/objcmt-arc-cf-annotations.m.result
test/ARCMT/objcmt-instancetype-2.m
test/ARCMT/objcmt-instancetype-2.m.result
test/ARCMT/objcmt-ns-macros.m
test/ARCMT/objcmt-ns-macros.m.result
test/ARCMT/objcmt-property.m
test/ARCMT/objcmt-property.m.result

index b51f8bb4938486f710eab0746aa1b2db9b5a24ab..d0d6b8794fe26eeed54266b6a37f30455eef8e6e 100644 (file)
@@ -340,9 +340,14 @@ static bool rewriteToObjCProperty(const ObjCMethodDecl *Getter,
 
 void ObjCMigrateASTConsumer::migrateObjCInterfaceDecl(ASTContext &Ctx,
                                                       ObjCContainerDecl *D) {
+  if (D->isDeprecated())
+    return;
+  
   for (ObjCContainerDecl::method_iterator M = D->meth_begin(), MEnd = D->meth_end();
        M != MEnd; ++M) {
     ObjCMethodDecl *Method = (*M);
+    if (Method->isDeprecated())
+      continue;
     if (!migrateProperty(Ctx, D, Method))
       migrateNsReturnsInnerPointer(Ctx, Method);
   }
@@ -532,7 +537,7 @@ static bool UseNSOptionsMacro(Preprocessor &PP, ASTContext &Ctx,
 void ObjCMigrateASTConsumer::migrateProtocolConformance(ASTContext &Ctx,   
                                             const ObjCImplementationDecl *ImpDecl) {
   const ObjCInterfaceDecl *IDecl = ImpDecl->getClassInterface();
-  if (!IDecl || ObjCProtocolDecls.empty())
+  if (!IDecl || ObjCProtocolDecls.empty() || IDecl->isDeprecated())
     return;
   // Find all implicit conforming protocols for this class
   // and make them explicit.
@@ -590,7 +595,8 @@ void ObjCMigrateASTConsumer::migrateNSEnumDecl(ASTContext &Ctx,
                                            const EnumDecl *EnumDcl,
                                            const TypedefDecl *TypedefDcl) {
   if (!EnumDcl->isCompleteDefinition() || EnumDcl->getIdentifier() ||
-      !TypedefDcl->getIdentifier())
+      !TypedefDcl->getIdentifier() ||
+      EnumDcl->isDeprecated() || TypedefDcl->isDeprecated())
     return;
   
   QualType qt = TypedefDcl->getTypeSourceInfo()->getType();
@@ -813,6 +819,8 @@ void ObjCMigrateASTConsumer::migrateMethods(ASTContext &Ctx,
        MEnd = CDecl->meth_end();
        M != MEnd; ++M) {
     ObjCMethodDecl *Method = (*M);
+    if (Method->isDeprecated())
+      continue;
     migrateMethodInstanceType(Ctx, CDecl, Method);
   }
 }
@@ -944,6 +952,9 @@ void ObjCMigrateASTConsumer::AnnotateImplicitBridging(ASTContext &Ctx) {
 }
 
 void ObjCMigrateASTConsumer::migrateCFAnnotation(ASTContext &Ctx, const Decl *Decl) {
+  if (Decl->isDeprecated())
+    return;
+  
   if (Decl->hasAttr<CFAuditedTransferAttr>()) {
     assert(CFFunctionIBCandidates.empty() &&
            "Cannot have audited functions/methods inside user "
@@ -1084,7 +1095,7 @@ ObjCMigrateASTConsumer::CF_BRIDGING_KIND
 
 void ObjCMigrateASTConsumer::migrateARCSafeAnnotation(ASTContext &Ctx,
                                                  ObjCContainerDecl *CDecl) {
-  if (!isa<ObjCInterfaceDecl>(CDecl))
+  if (!isa<ObjCInterfaceDecl>(CDecl) || CDecl->isDeprecated())
     return;
   
   // migrate methods which can have instancetype as their result type.
@@ -1234,10 +1245,8 @@ void ObjCMigrateASTConsumer::HandleTranslationUnit(ASTContext &Ctx) {
          D != DEnd; ++D) {
       if (unsigned FID =
             PP.getSourceManager().getFileID((*D)->getLocation()).getHashValue())
-        if (FileId && FileId != FID) {
-          assert(!CFFunctionIBCandidates.empty());
+        if (FileId && FileId != FID)
           AnnotateImplicitBridging(Ctx);
-        }
           
       if (ObjCInterfaceDecl *CDecl = dyn_cast<ObjCInterfaceDecl>(*D))
         migrateObjCInterfaceDecl(Ctx, CDecl);
index e55b0b3712c589f74e4ee0b7417bc34a037cc0cc..43537c85d84b02e64c87e2350c183e0d52d126c9 100644 (file)
@@ -231,10 +231,10 @@ CF_IMPLICIT_BRIDGING_ENABLED
 
 io_service_t IOServiceGetMatchingService(  mach_port_t masterPort,  CFDictionaryRef matching );
 kern_return_t IOServiceGetMatchingServices(  mach_port_t masterPort,  CFDictionaryRef matching,  io_iterator_t * existing );
-kern_return_t IOServiceAddNotification(  mach_port_t masterPort,  const io_name_t notificationType,  CFDictionaryRef matching,  mach_port_t wakePort,  uintptr_t reference,  io_iterator_t * notification ) __attribute__((deprecated));
 
 CF_IMPLICIT_BRIDGING_DISABLED
- // expected-note {{'IOServiceAddNotification' declared here}}
+
+kern_return_t IOServiceAddNotification(  mach_port_t masterPort,  const io_name_t notificationType,  CFDictionaryRef matching,  mach_port_t wakePort,  uintptr_t reference,  io_iterator_t * notification ) __attribute__((deprecated)); // expected-note {{'IOServiceAddNotification' declared here}}
 kern_return_t IOServiceAddMatchingNotification(  IONotificationPortRef notifyPort,  const io_name_t notificationType,  CFDictionaryRef CF_CONSUMED matching,         IOServiceMatchingCallback callback,         void * refCon,  io_iterator_t * notification );
 
 CF_IMPLICIT_BRIDGING_ENABLED
index 2fdbcf9cca33025dc917bb12d89281a5b9fb28c9..4f1a509c4f3e0e686cfb5c6d23afb45ef562b391 100644 (file)
@@ -16,10 +16,10 @@ typedef char BOOL;
 
 @class NSString, NSURL;
 @interface NSString (NSStringDeprecated)
-+ (id)stringWithContentsOfFile:(NSString *)path __attribute__((availability(macosx,introduced=10.0 ,deprecated=10.4,message="" )));
-+ (id)stringWithContentsOfURL:(NSURL *)url __attribute__((availability(macosx,introduced=10.0 ,deprecated=10.4,message="" )));
-+ (id)stringWithCString:(const char *)bytes length:(NSUInteger)length __attribute__((availability(macosx,introduced=10.0 ,deprecated=10.4,message="" )));
-+ (id)stringWithCString:(const char *)bytes __attribute__((availability(macosx,introduced=10.0 ,deprecated=10.4,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
 
 
index b6bd05adeb66735d19d87d3e9fae47c910380f33..e9ca594ed0437e3f694019baa6fc2f00f6aea893 100644 (file)
@@ -16,10 +16,10 @@ typedef char BOOL;
 
 @class NSString, NSURL;
 @interface NSString (NSStringDeprecated)
-+ (instancetype)stringWithContentsOfFile:(NSString *)path __attribute__((availability(macosx,introduced=10.0 ,deprecated=10.4,message="" )));
-+ (instancetype)stringWithContentsOfURL:(NSURL *)url __attribute__((availability(macosx,introduced=10.0 ,deprecated=10.4,message="" )));
-+ (instancetype)stringWithCString:(const char *)bytes length:(NSUInteger)length __attribute__((availability(macosx,introduced=10.0 ,deprecated=10.4,message="" )));
-+ (instancetype)stringWithCString:(const char *)bytes __attribute__((availability(macosx,introduced=10.0 ,deprecated=10.4,message="" )));
++ (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="" )));
 @end
 
 
index ec6e3d44c7367705bdc8f93a13aa7cd9084844ba..ccf666c1e0c1857521815ed3d3fe8f9f10c8936d 100644 (file)
@@ -8,6 +8,7 @@ typedef unsigned long NSUInteger;
 
 #define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
 #define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
+#define DEPRECATED  __attribute__((deprecated))
 
 enum {
   blah,
@@ -110,3 +111,18 @@ enum {
 };
 typedef NSUInteger NSAlertStyle;
 
+enum {
+    D_NSTIFFFileType,
+    D_NSBMPFileType,
+    D_NSGIFFileType,
+    D_NSJPEGFileType,
+    D_NSPNGFileType,
+    D_NSJPEG2000FileType
+};
+typedef NSUInteger D_NSBitmapImageFileType DEPRECATED;
+
+typedef enum  {
+    D_NSTickMarkBelow = 0,
+    D_NSTickMarkAbove = 1
+} D_NSTickMarkPosition DEPRECATED;
+
index 80c84bdfbea8ad7cc7efd8975f347b99ea8f4f67..b94b31b88203ddc6a4df2a8deb3b6edc39334746 100644 (file)
@@ -8,6 +8,7 @@ typedef unsigned long NSUInteger;
 
 #define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
 #define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
+#define DEPRECATED  __attribute__((deprecated))
 
 typedef NS_ENUM(NSInteger, wibble) {
   blah,
@@ -110,3 +111,18 @@ typedef NS_ENUM(NSUInteger, NSAlertStyle) {
 };
 
 
+enum {
+    D_NSTIFFFileType,
+    D_NSBMPFileType,
+    D_NSGIFFileType,
+    D_NSJPEGFileType,
+    D_NSPNGFileType,
+    D_NSJPEG2000FileType
+};
+typedef NSUInteger D_NSBitmapImageFileType DEPRECATED;
+
+typedef enum  {
+    D_NSTickMarkBelow = 0,
+    D_NSTickMarkAbove = 1
+} D_NSTickMarkPosition DEPRECATED;
+
index 9ddd9edb9b321adada07639366e9ac25514c891f..5b11c4aa3a75cee1741fc50ba4295f72b6703a98 100644 (file)
@@ -6,6 +6,7 @@
 #define WEBKIT_OBJC_METHOD_ANNOTATION(ANNOTATION) ANNOTATION
 #define WEAK_IMPORT_ATTRIBUTE __attribute__((objc_arc_weak_reference_unavailable))
 #define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER
+#define DEPRECATED  __attribute__((deprecated)) 
 
 typedef char BOOL;
 @class NSString;
@@ -158,3 +159,20 @@ typedef char BOOL;
 - (BOOL) getMANY;
 - (BOOL) getSome;
 @end
+
+DEPRECATED
+@interface I_DEP
+- (BOOL) isinValid;
+- (void) setInValid : (BOOL) arg;
+@end
+
+@interface AnotherOne
+- (BOOL) isinValid DEPRECATED;
+- (void) setInValid : (BOOL) arg;
+- (id)MYtarget;
+- (void)setMYtarget: (id)target DEPRECATED;
+- (BOOL) getM DEPRECATED;
+
+- (id)xxxdelegateYYY DEPRECATED;
+- (void)setXxxdelegateYYY:(id)delegate DEPRECATED;
+@end
index 355a8c124cca351da7f1c1c59d408f1dd06b4bcf..39b0a8740f26300d493b23cf693af2f5b819dfbc 100644 (file)
@@ -6,6 +6,7 @@
 #define WEBKIT_OBJC_METHOD_ANNOTATION(ANNOTATION) ANNOTATION
 #define WEAK_IMPORT_ATTRIBUTE __attribute__((objc_arc_weak_reference_unavailable))
 #define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER
+#define DEPRECATED  __attribute__((deprecated)) 
 
 typedef char BOOL;
 @class NSString;
@@ -158,3 +159,20 @@ typedef char BOOL;
 @property(nonatomic, getter=getMANY, readonly) BOOL MANY;
 @property(nonatomic, getter=getSome, readonly) BOOL some;
 @end
+
+DEPRECATED
+@interface I_DEP
+- (BOOL) isinValid;
+- (void) setInValid : (BOOL) arg;
+@end
+
+@interface AnotherOne
+- (BOOL) isinValid DEPRECATED;
+- (void) setInValid : (BOOL) arg;
+- (id)MYtarget;
+- (void)setMYtarget: (id)target DEPRECATED;
+- (BOOL) getM DEPRECATED;
+
+- (id)xxxdelegateYYY DEPRECATED;
+- (void)setXxxdelegateYYY:(id)delegate DEPRECATED;
+@end