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