ObjectiveC migration. NS_RETURNS_NOT_RETAINED is the default for

unknown methods which return Cocoa objects. No need to annotate
such methods.

llvm-svn: 190555
This commit is contained in:
Fariborz Jahanian 2013-09-11 22:46:09 +00:00
parent 2ff9d70ac4
commit 47502c11f5
2 changed files with 19 additions and 25 deletions

View File

@ -991,9 +991,6 @@ void ObjCMigrateASTConsumer::AddCFAnnotations(ASTContext &Ctx,
if (Ret.isOwned() &&
Ctx.Idents.get("NS_RETURNS_RETAINED").hasMacroDefinition())
AnnotationString = " NS_RETURNS_RETAINED";
else if (Ret.notOwned() &&
Ctx.Idents.get("NS_RETURNS_NOT_RETAINED").hasMacroDefinition())
AnnotationString = " NS_RETURNS_NOT_RETAINED";
}
if (AnnotationString) {
@ -1125,9 +1122,6 @@ void ObjCMigrateASTConsumer::AddCFAnnotations(ASTContext &Ctx,
if (Ret.isOwned() &&
Ctx.Idents.get("NS_RETURNS_RETAINED").hasMacroDefinition())
AnnotationString = " NS_RETURNS_RETAINED";
else if (Ret.notOwned() &&
Ctx.Idents.get("NS_RETURNS_NOT_RETAINED").hasMacroDefinition())
AnnotationString = " NS_RETURNS_NOT_RETAINED";
break;
}
}

View File

@ -175,15 +175,15 @@ NSFastEnumerationState;
@interface NSNumber : NSValue
- (char)charValue;
- (id)initWithInt:(int)value;
+ (NSNumber *)numberWithInt:(int)value NS_RETURNS_NOT_RETAINED;
+ (NSNumber *)numberWithInt:(int)value;
@end
@class NSString;
@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
- (NSUInteger)count;
- (id)initWithObjects:(const id [])objects count:(NSUInteger)cnt;
+ (instancetype)arrayWithObject:(id)anObject NS_RETURNS_NOT_RETAINED;
+ (instancetype)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt NS_RETURNS_NOT_RETAINED;
+ (instancetype)arrayWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1))) NS_RETURNS_NOT_RETAINED;
+ (instancetype)arrayWithObject:(id)anObject;
+ (instancetype)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt;
+ (instancetype)arrayWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
- (id)initWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
- (id)initWithArray:(NSArray *)array;
@end @interface NSArray (NSArrayCreation) + (instancetype)array;
@ -196,19 +196,19 @@ typedef double NSTimeInterval;
@end typedef unsigned short unichar;
@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>
- (NSUInteger)length;
- (NSString *)stringByAppendingString:(NSString *)aString NS_RETURNS_NOT_RETAINED;
- (NSString *)stringByAppendingString:(NSString *)aString;
- ( const char *)UTF8String;
- (id)initWithUTF8String:(const char *)nullTerminatedCString;
+ (instancetype)stringWithUTF8String:(const char *)nullTerminatedCString NS_RETURNS_NOT_RETAINED;
+ (instancetype)stringWithUTF8String:(const char *)nullTerminatedCString;
@end @class NSString, NSURL, NSError;
@interface NSData : NSObject <NSCopying, NSMutableCopying, NSCoding> - (NSUInteger)length;
+ (instancetype)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length NS_RETURNS_NOT_RETAINED;
+ (instancetype)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length freeWhenDone:(BOOL)b NS_RETURNS_NOT_RETAINED;
+ (instancetype)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length;
+ (instancetype)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length freeWhenDone:(BOOL)b;
@end @class NSLocale, NSDate, NSCalendar, NSTimeZone, NSError, NSArray, NSMutableDictionary;
@interface NSDictionary : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
- (NSUInteger)count;
+ (instancetype)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys NS_RETURNS_NOT_RETAINED;
+ (instancetype)dictionaryWithObjects:(const id [])objects forKeys:(const id <NSCopying> [])keys count:(NSUInteger)cnt NS_RETURNS_NOT_RETAINED;
+ (instancetype)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
+ (instancetype)dictionaryWithObjects:(const id [])objects forKeys:(const id <NSCopying> [])keys count:(NSUInteger)cnt;
@end
@interface NSMutableDictionary : NSDictionary - (void)removeObjectForKey:(id)aKey;
- (void)setObject:(id)anObject forKey:(id)aKey;
@ -350,7 +350,7 @@ CF_IMPLICIT_BRIDGING_DISABLED
@interface NSMutableArray : NSObject
- (void)addObject:(id)object;
+ (instancetype)array NS_RETURNS_NOT_RETAINED;
+ (instancetype)array;
@end
// This is how NSMakeCollectable is declared in the OS X 10.8 headers.
@ -895,8 +895,8 @@ int RDar6320065_test() {
//===----------------------------------------------------------------------===//
@interface RDar6859457 : NSObject {}
- (NSString*) NoCopyString NS_RETURNS_NOT_RETAINED;
- (NSString*) noCopyString NS_RETURNS_NOT_RETAINED;
- (NSString*) NoCopyString;
- (NSString*) noCopyString;
@end
@implementation RDar6859457
@ -1332,7 +1332,7 @@ void rdar7265711_b(RDar7265711 *x) {
//===----------------------------------------------------------------------===//
@interface NSCursor : NSObject
+ (NSCursor *)dragCopyCursor NS_RETURNS_NOT_RETAINED;
+ (NSCursor *)dragCopyCursor;
@end
void rdar7306898(void) {
@ -1443,7 +1443,7 @@ void testattr4() {
- (CFDateRef) returnsCFRetainedAsCF CF_RETURNS_RETAINED;
- (CFDateRef) newCFRetainedAsCF CF_RETURNS_NOT_RETAINED;
- (CFDateRef) newCFRetainedAsCFNoAttr CF_RETURNS_RETAINED;
- (NSDate*) alsoReturnsRetained NS_RETURNS_NOT_RETAINED;
- (NSDate*) alsoReturnsRetained;
- (CFDateRef) alsoReturnsRetainedAsCF CF_RETURNS_NOT_RETAINED;
- (NSDate*) returnsNSRetained NS_RETURNS_RETAINED;
@end
@ -1579,7 +1579,7 @@ void r8272168() {
// Test case for <rdar://problem/8356342>, which in the past triggered
// a false positive.
@interface RDar8356342
- (NSDate*) rdar8356342:(NSDate *)inValue NS_RETURNS_NOT_RETAINED;
- (NSDate*) rdar8356342:(NSDate *)inValue;
@end
@implementation RDar8356342
@ -1806,7 +1806,7 @@ int IOClose(void *context);
@end
@interface radar10973977 : NSObject
- (id<SInS>)inputS NS_RETURNS_NOT_RETAINED;
- (id<SInS>)inputS;
- (void)reader;
@end
@ -1825,7 +1825,7 @@ int IOClose(void *context);
// Object escapes through a selector callback: radar://11398514
extern id NSApp;
@interface MySheetController
- (id<SInS>)inputS NS_RETURNS_NOT_RETAINED;
- (id<SInS>)inputS;
- (void)showDoSomethingSheetAction:(id)action;
- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo;
@end
@ -2090,6 +2090,6 @@ CFAttributedStringRef CFAttributedCreate(void *CFObj CF_CONSUMED) CF_RETURNS_RET
@interface Action
@property(nonatomic) SEL action;
@property(nonatomic, unsafe_unretained) id target NS_RETURNS_NOT_RETAINED;
@property(nonatomic, unsafe_unretained) id target;
@end