brintos

brintos / llvm-project-archived public Read only

0
0
Text · 9.1 KiB · a0e6bf5 Raw
208 lines · plain
1// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify -Wno-objc-root-class %s2 3typedef long int NSUInteger;4#define nil 05@class NSString;6 7@interface NSMutableArray8 9- (void)addObject:(id)object;10- (void)insertObject:(id)object atIndex:(NSUInteger)index;11- (void)replaceObjectAtIndex:(NSUInteger)index withObject:(id)object;12- (void)setObject:(id)object atIndexedSubscript:(NSUInteger)index;13 14@end15 16@interface NSMutableDictionary17 18- (void)setObject:(id)object forKey:(id)key;19- (void)setObject:(id)object forKeyedSubscript:(id)key;20- (void)setValue:(id)value forKey:(NSString *)key;21 22@end23 24@interface NSMutableSet25 26- (void)addObject:(id)object;27 28@end29 30@interface NSCountedSet : NSMutableSet31 32@end33 34@interface NSMutableOrderedSet35 36- (void)addObject:(id)object;37- (void)insertObject:(id)object atIndex:(NSUInteger)index;38- (void)setObject:(id)object atIndexedSubscript:(NSUInteger)index;39- (void)replaceObjectAtIndex:(NSUInteger)index withObject:(id)object;40- (void)setObject:(id)object atIndex:(NSUInteger)index;41 42@end43 44@interface SelfRefClass45{46  NSMutableArray *_array; // expected-note {{'_array' declared here}}47  NSMutableDictionary *_dictionary; // expected-note {{'_dictionary' declared here}}48  NSMutableSet *_set; // expected-note {{'_set' declared here}}49  NSCountedSet *_countedSet; // expected-note {{'_countedSet' declared here}}50  NSMutableOrderedSet *_orderedSet; // expected-note {{'_orderedSet' declared here}}51}52@end53 54@implementation SelfRefClass55 56- (void)check {57  [_array addObject:_array]; // expected-warning {{adding '_array' to '_array' might cause circular dependency in container}}58  [_dictionary setObject:_dictionary forKey:@"key"]; // expected-warning {{adding '_dictionary' to '_dictionary' might cause circular dependency in container}}59  [_set addObject:_set]; // expected-warning {{adding '_set' to '_set' might cause circular dependency in container}}60  [_countedSet addObject:_countedSet]; // expected-warning {{adding '_countedSet' to '_countedSet' might cause circular dependency in container}}61  [_orderedSet addObject:_orderedSet]; // expected-warning {{adding '_orderedSet' to '_orderedSet' might cause circular dependency in container}}62}63 64- (void)checkNSMutableArray:(NSMutableArray *)a { // expected-note {{'a' declared here}}65  [a addObject:a]; // expected-warning {{adding 'a' to 'a' might cause circular dependency in container}}66}67 68- (void)checkNSMutableDictionary:(NSMutableDictionary *)d { // expected-note {{'d' declared here}}69  [d setObject:d forKey:@"key"]; // expected-warning {{adding 'd' to 'd' might cause circular dependency in container}}70}71 72- (void)checkNSMutableSet:(NSMutableSet *)s { // expected-note {{'s' declared here}}73  [s addObject:s]; // expected-warning {{adding 's' to 's' might cause circular dependency in container}}74}75 76- (void)checkNSCountedSet:(NSCountedSet *)s { // expected-note {{'s' declared here}}77  [s addObject:s]; // expected-warning {{adding 's' to 's' might cause circular dependency in container}}78}79 80- (void)checkNSMutableOrderedSet:(NSMutableOrderedSet *)s { // expected-note {{'s' declared here}}81  [s addObject:s]; // expected-warning {{adding 's' to 's' might cause circular dependency in container}}82}83 84@end85 86void checkNSMutableArrayParam(NSMutableArray *a) { // expected-note {{'a' declared here}}87  [a addObject:a]; // expected-warning {{adding 'a' to 'a' might cause circular dependency in container}}88}89 90void checkNSMutableDictionaryParam(NSMutableDictionary *d) { // expected-note {{'d' declared here}}91  [d setObject:d forKey:@"key"]; // expected-warning {{adding 'd' to 'd' might cause circular dependency in container}}92}93 94void checkNSMutableSetParam(NSMutableSet *s) { // expected-note {{'s' declared here}}95  [s addObject:s]; // expected-warning {{adding 's' to 's' might cause circular dependency in container}}96}97 98void checkNSCountedSetParam(NSCountedSet *s) { // expected-note {{'s' declared here}}99  [s addObject:s]; // expected-warning {{adding 's' to 's' might cause circular dependency in container}}100}101 102void checkNSMutableOrderedSetParam(NSMutableOrderedSet *s) { // expected-note {{'s' declared here}}103  [s addObject:s]; // expected-warning {{adding 's' to 's' might cause circular dependency in container}}104}105 106void checkNSMutableArray(void) {107  NSMutableArray *a = nil; // expected-note 5 {{'a' declared here}} 5108 109  [a addObject:a]; // expected-warning {{adding 'a' to 'a' might cause circular dependency in container}}110  [a insertObject:a atIndex:0]; // expected-warning {{adding 'a' to 'a' might cause circular dependency in container}}111  [a replaceObjectAtIndex:0 withObject:a]; // expected-warning {{adding 'a' to 'a' might cause circular dependency in container}}112  [a setObject:a atIndexedSubscript:0]; // expected-warning {{adding 'a' to 'a' might cause circular dependency in container}}113  a[0] = a; // expected-warning {{adding 'a' to 'a' might cause circular dependency in container}}114}115 116void checkNSMutableDictionary(void) {117  NSMutableDictionary *d = nil; // expected-note 4 {{'d' declared here}}118 119  [d setObject:d forKey:@"key"]; // expected-warning {{adding 'd' to 'd' might cause circular dependency in container}}120  [d setObject:d forKeyedSubscript:@"key"]; // expected-warning {{adding 'd' to 'd' might cause circular dependency in container}}121  [d setValue:d forKey:@"key"]; // expected-warning {{adding 'd' to 'd' might cause circular dependency in container}}122  d[@"key"] = d; // expected-warning {{adding 'd' to 'd' might cause circular dependency in container}}123}124 125void checkNSMutableSet(void) {126  NSMutableSet *s = nil; // expected-note {{'s' declared here}}127 128  [s addObject:s]; // expected-warning {{adding 's' to 's' might cause circular dependency in container}}129}130 131void checkNSCountedSet(void) {132  NSCountedSet *s = nil; // expected-note {{'s' declared here}}133 134  [s addObject:s]; // expected-warning {{adding 's' to 's' might cause circular dependency in container}}135}136 137void checkNSMutableOrderedSet(void) {138  NSMutableOrderedSet *s = nil; // expected-note 5 {{'s' declared here}}139 140  [s addObject:s]; // expected-warning {{adding 's' to 's' might cause circular dependency in container}}141  [s insertObject:s atIndex:0]; // expected-warning {{adding 's' to 's' might cause circular dependency in container}}142  [s setObject:s atIndex:0]; // expected-warning {{adding 's' to 's' might cause circular dependency in container}}143  [s setObject:s atIndexedSubscript:0]; // expected-warning {{adding 's' to 's' might cause circular dependency in container}}144  [s replaceObjectAtIndex:0 withObject:s]; // expected-warning {{adding 's' to 's' might cause circular dependency in container}}145}146 147// Test subclassing148 149@interface FootableSet : NSMutableSet150@end151 152@implementation FootableSet153- (void)meth {154  [super addObject:self]; // expected-warning {{adding 'self' to 'super' might cause circular dependency in container}}155  [super addObject:nil]; // no-warning156  [self addObject:self]; // expected-warning {{adding 'self' to 'self' might cause circular dependency in container}}157}158@end159 160@interface FootableArray : NSMutableArray161@end162 163@implementation FootableArray164- (void)meth {165  [super addObject:self]; // expected-warning {{adding 'self' to 'super' might cause circular dependency in container}}166  [super addObject:nil]; // no-warning167  [self addObject:self]; // expected-warning {{adding 'self' to 'self' might cause circular dependency in container}}168}169@end170 171@interface FootableDictionary : NSMutableDictionary172@end173 174@implementation FootableDictionary175- (void)meth {176  [super setObject:self forKey:@"key"]; // expected-warning {{adding 'self' to 'super' might cause circular dependency in container}}177  [super setObject:nil forKey:@"key"]; // no-warning178  [self setObject:self forKey:@"key"]; // expected-warning {{adding 'self' to 'self' might cause circular dependency in container}}179}180@end181 182 183void subclassingNSMutableArray(void) {184  FootableArray *a = nil; // expected-note 5 {{'a' declared here}} 5185 186  [a addObject:a]; // expected-warning {{adding 'a' to 'a' might cause circular dependency in container}}187  [a insertObject:a atIndex:0]; // expected-warning {{adding 'a' to 'a' might cause circular dependency in container}}188  [a replaceObjectAtIndex:0 withObject:a]; // expected-warning {{adding 'a' to 'a' might cause circular dependency in container}}189  [a setObject:a atIndexedSubscript:0]; // expected-warning {{adding 'a' to 'a' might cause circular dependency in container}}190  a[0] = a; // expected-warning {{adding 'a' to 'a' might cause circular dependency in container}}191}192 193void subclassingNSMutableDictionary(void) {194  FootableDictionary *d = nil; // expected-note 4 {{'d' declared here}}195 196  [d setObject:d forKey:@"key"]; // expected-warning {{adding 'd' to 'd' might cause circular dependency in container}}197  [d setObject:d forKeyedSubscript:@"key"]; // expected-warning {{adding 'd' to 'd' might cause circular dependency in container}}198  [d setValue:d forKey:@"key"]; // expected-warning {{adding 'd' to 'd' might cause circular dependency in container}}199  d[@"key"] = d; // expected-warning {{adding 'd' to 'd' might cause circular dependency in container}}200}201 202void subclassingNSMutableSet(void) {203  FootableSet *s = nil; // expected-note {{'s' declared here}}204 205  [s addObject:s]; // expected-warning {{adding 's' to 's' might cause circular dependency in container}}206}207 208