| 1 |
// RUN: rm -rf %t |
| 2 |
// RUN: %clang_cc1 -objcmt-migrate-instancetype -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -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 %s.result |
| 5 |
|
| 6 |
typedef signed char BOOL; |
| 7 |
#define nil ((void*) 0) |
| 8 |
|
| 9 |
@interface NSObject |
| 10 |
+ (id)alloc; |
| 11 |
@end |
| 12 |
|
| 13 |
@interface NSString : NSObject |
| 14 |
+ (instancetype)stringWithString:(NSString *)string; |
| 15 |
- (instancetype)initWithString:(NSString *)aString; |
| 16 |
@end |
| 17 |
|
| 18 |
@implementation NSString : NSObject |
| 19 |
+ (instancetype)stringWithString:(NSString *)string { return 0; }; |
| 20 |
- (instancetype)initWithString:(NSString *)aString { return 0; }; |
| 21 |
@end |
| 22 |
|
| 23 |
@interface NSArray : NSObject |
| 24 |
- (id)objectAtIndex:(unsigned long)index; |
| 25 |
- (id)objectAtIndexedSubscript:(int)index; |
| 26 |
@end |
| 27 |
|
| 28 |
@interface NSArray (NSArrayCreation) |
| 29 |
+ (instancetype)array; |
| 30 |
+ (instancetype)arrayWithObject:(id)anObject; |
| 31 |
+ (instancetype)arrayWithObjects:(const id [])objects count:(unsigned long)cnt; |
| 32 |
+ (instancetype)arrayWithObjects:(id)firstObj, ...; |
| 33 |
+ (instancetype) arrayWithArray:(NSArray *)array; |
| 34 |
|
| 35 |
- (instancetype)initWithObjects:(const id [])objects count:(unsigned long)cnt; |
| 36 |
- (instancetype)initWithObjects:(id)firstObj, ...; |
| 37 |
- (instancetype)initWithArray:(NSArray *)array; |
| 38 |
|
| 39 |
- (id)objectAtIndex:(unsigned long)index; |
| 40 |
@end |
| 41 |
|
| 42 |
@implementation NSArray (NSArrayCreation) |
| 43 |
+ (instancetype)array { return 0; } |
| 44 |
+ (instancetype)arrayWithObject:(id)anObject { |
| 45 |
return anObject; |
| 46 |
} |
| 47 |
+ (instancetype)arrayWithObjects:(const id [])objects count:(unsigned long)cnt { return 0; } |
| 48 |
+ (instancetype)arrayWithObjects:(id)firstObj, ... { |
| 49 |
return 0; } |
| 50 |
+ (instancetype) arrayWithArray:(NSArray *)array { |
| 51 |
return 0; |
| 52 |
} |
| 53 |
|
| 54 |
- (instancetype)initWithObjects:(const id [])objects count:(unsigned long)cnt { return 0; } |
| 55 |
- (instancetype)initWithObjects:(id)firstObj, ... { return 0; } |
| 56 |
- (instancetype)initWithArray:(NSArray *)array { return 0; } |
| 57 |
|
| 58 |
- (id)objectAtIndex:(unsigned long)index { return 0; } |
| 59 |
@end |
| 60 |
|
| 61 |
@interface NSMutableArray : NSArray |
| 62 |
- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; |
| 63 |
- (void)setObject:(id)object atIndexedSubscript:(int)index; |
| 64 |
@end |
| 65 |
|
| 66 |
@interface NSDictionary : NSObject |
| 67 |
- (id)objectForKeyedSubscript:(id)key; |
| 68 |
@end |
| 69 |
|
| 70 |
@interface NSDictionary (NSDictionaryCreation) |
| 71 |
+ (instancetype)dictionary; |
| 72 |
+ (instancetype)dictionaryWithObject:(id)object forKey:(id)key; |
| 73 |
+ (instancetype)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; |
| 74 |
+ (instancetype) dictionaryWithObjectsAndKeys:(id)firstObject, ...; |
| 75 |
+ (instancetype)dictionaryWithDictionary:(NSDictionary *)dict; |
| 76 |
+ (instancetype)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; |
| 77 |
|
| 78 |
- (instancetype)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; |
| 79 |
- (instancetype)initWithObjectsAndKeys:(id)firstObject, ...; |
| 80 |
- (instancetype)initWithDictionary:(NSDictionary *)otherDictionary; |
| 81 |
- (instancetype)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; |
| 82 |
|
| 83 |
- (id)objectForKey:(id)aKey; |
| 84 |
@end |
| 85 |
|
| 86 |
@interface NSMutableDictionary : NSDictionary |
| 87 |
- (void)setObject:(id)anObject forKey:(id)aKey; |
| 88 |
- (void)setObject:(id)object forKeyedSubscript:(id)key; |
| 89 |
@end |
| 90 |
|
| 91 |
@interface NSNumber : NSObject |
| 92 |
@end |
| 93 |
|
| 94 |
@interface NSNumber (NSNumberCreation) |
| 95 |
+ (NSNumber *)numberWithInt:(int)value; |
| 96 |
@end |
| 97 |
|
| 98 |
@implementation NSNumber (NSNumberCreation) |
| 99 |
+ (NSNumber *)numberWithInt:(int)value { return 0; } |
| 100 |
@end |
| 101 |
|
| 102 |
#define M(x) (x) |
| 103 |
#define PAIR(x) @#x, [NSNumber numberWithInt:(x)] |
| 104 |
#define TWO(x) ((x), (x)) |
| 105 |
|
| 106 |
void foo(void) { |
| 107 |
NSString *str = M([NSString stringWithString:@"foo"]); // expected-warning {{redundant}} |
| 108 |
str = [[NSString alloc] initWithString:@"foo"]; // expected-warning {{redundant}} |
| 109 |
NSArray *arr = [NSArray arrayWithArray:@[str]]; // expected-warning {{redundant}} |
| 110 |
NSDictionary *dict = [NSDictionary dictionaryWithDictionary:@{str: arr}]; // expected-warning {{redundant}} |
| 111 |
} |