aboutsummaryrefslogtreecommitdiff
path: root/test/Analysis/NSContainers.m
diff options
context:
space:
mode:
Diffstat (limited to 'test/Analysis/NSContainers.m')
-rw-r--r--test/Analysis/NSContainers.m22
1 files changed, 20 insertions, 2 deletions
diff --git a/test/Analysis/NSContainers.m b/test/Analysis/NSContainers.m
index 402ce2c90a17..c868459999da 100644
--- a/test/Analysis/NSContainers.m
+++ b/test/Analysis/NSContainers.m
@@ -24,6 +24,8 @@ typedef struct _NSZone NSZone;
@interface NSObject <NSObject> {}
- (id)init;
+ (id)alloc;
+
+- (id)mutableCopy;
@end
typedef struct {
@@ -153,13 +155,12 @@ void testNilArgNSMutableDictionary3(NSMutableDictionary *d) {
}
void testNilArgNSMutableDictionary5(NSMutableDictionary *d, NSString* key) {
- d[key] = 0; // expected-warning {{Value stored into 'NSMutableDictionary' cannot be nil}}
+ d[key] = 0; // no-warning - removing the mapping for the given key
}
void testNilArgNSMutableDictionary6(NSMutableDictionary *d, NSString *key) {
if (key)
;
d[key] = 0; // expected-warning {{'NSMutableDictionary' key cannot be nil}}
- // expected-warning@-1 {{Value stored into 'NSMutableDictionary' cannot be nil}}
}
NSDictionary *testNilArgNSDictionary1(NSString* key) {
@@ -292,3 +293,20 @@ void testArrayCategory(NSMutableArray *arr) {
[arr addObject:0 safe:1]; // no-warning
}
+@interface MyView : NSObject
+-(NSArray *)subviews;
+@end
+
+void testNoReportWhenReceiverNil(NSMutableArray *array, int b) {
+ // Don't warn about adding nil to a container when the receiver is also
+ // definitely nil.
+ if (array == 0) {
+ [array addObject:0]; // no-warning
+ }
+
+ MyView *view = b ? [[MyView alloc] init] : 0;
+ NSMutableArray *subviews = [[view subviews] mutableCopy];
+ // When view is nil, subviews is also nil so there should be no warning
+ // here either.
+ [subviews addObject:view]; // no-warning
+}