1 // RUN: rm -rf %t 2 // RUN: %clang_cc1 -objcmt-migrate-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -fobjc-default-synthesize-properties -triple x86_64-apple-darwin11 3 // RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result 4 // RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc -fobjc-default-synthesize-properties %s.result 5 6 typedef signed char BOOL; 7 #define nil ((void*) 0) 8 9 @interface NSObject 10 + (instancetype)alloc; 11 @end 12 13 @interface NSString : NSObject 14 + (instancetype)stringWithString:(NSString *)string; 15 - (instancetype)initWithString:(NSString *)aString; 16 @end 17 18 @interface NSArray : NSObject 19 - (id)objectAtIndex:(unsigned long)index; 20 - (id)objectAtIndexedSubscript:(int)index; 21 @end 22 23 @interface NSArray (NSArrayCreation) 24 + (instancetype)array; 25 + (instancetype)arrayWithObject:(id)anObject; 26 + (instancetype)arrayWithObjects:(const id [])objects count:(unsigned long)cnt; 27 + (instancetype)arrayWithObjects:(id)firstObj, ...; 28 + (instancetype) arrayWithArray:(NSArray *)array; 29 30 - (instancetype)initWithObjects:(const id [])objects count:(unsigned long)cnt; 31 - (instancetype)initWithObjects:(id)firstObj, ...; 32 - (instancetype)initWithArray:(NSArray *)array; 33 34 - (id)objectAtIndex:(unsigned long)index; 35 @end 36 37 @interface NSMutableArray : NSArray 38 - (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; 39 - (void)setObject:(id)object atIndexedSubscript:(int)index; 40 @end 41 42 @interface NSDictionary : NSObject 43 - (id)objectForKeyedSubscript:(id)key; 44 @end 45 46 @interface NSDictionary (NSDictionaryCreation) 47 + (instancetype)dictionary; 48 + (instancetype)dictionaryWithObject:(id)object forKey:(id)key; 49 + (instancetype)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; 50 + (instancetype) dictionaryWithObjectsAndKeys:(id)firstObject, ...; 51 + (instancetype)dictionaryWithDictionary:(NSDictionary *)dict; 52 + (instancetype)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; 53 54 - (instancetype)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; 55 - (instancetype)initWithObjectsAndKeys:(id)firstObject, ...; 56 - (instancetype)initWithDictionary:(NSDictionary *)otherDictionary; 57 - (instancetype)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; 58 59 - (id)objectForKey:(id)aKey; 60 @end 61 62 @interface NSMutableDictionary : NSDictionary 63 - (void)setObject:(id)anObject forKey:(id)aKey; 64 - (void)setObject:(id)object forKeyedSubscript:(id)key; 65 @end 66 67 @interface NSNumber : NSObject 68 @end 69 70 @interface NSNumber (NSNumberCreation) 71 + (NSNumber *)numberWithInt:(int)value; 72 @end 73 74 #define M(x) (x) 75 #define PAIR(x) @#x, [NSNumber numberWithInt:(x)] 76 #define TWO(x) ((x), (x)) 77 78 void foo() { 79 NSString *str = M([NSString stringWithString:@"foo"]); // expected-warning {{redundant}} 80 str = [[NSString alloc] initWithString:@"foo"]; // expected-warning {{redundant}} 81 NSArray *arr = [NSArray arrayWithArray:@[str]]; // expected-warning {{redundant}} 82 NSDictionary *dict = [NSDictionary dictionaryWithDictionary:@{str: arr}]; // expected-warning {{redundant}} 83 } 84