]> granicus.if.org Git - clang/commitdiff
[static analyzer] Don't flag nil storage into NSMutableDictionary.
authorAnna Zaks <ganna@apple.com>
Wed, 11 Nov 2015 00:49:22 +0000 (00:49 +0000)
committerAnna Zaks <ganna@apple.com>
Wed, 11 Nov 2015 00:49:22 +0000 (00:49 +0000)
This is now allowed and has the behavior of removing the mapping.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@252679 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
test/Analysis/NSContainers.m

index e157478433c4f83f3275a4ce94cd0b62a3ae2edf..fd08b0239b3711be26a823a3ce78023d85315c4c 100644 (file)
@@ -307,8 +307,7 @@ void NilArgChecker::checkPreObjCMessage(const ObjCMethodCall &msg,
       warnIfNilArg(C, msg, /* Arg */1, Class);
     } else if (S == SetObjectForKeyedSubscriptSel) {
       CanBeSubscript = true;
-      Arg = 0;
-      warnIfNilArg(C, msg, /* Arg */1, Class, CanBeSubscript);
+      Arg = 1;
     } else if (S == RemoveObjectForKeySel) {
       Arg = 0;
     }
index d04b331bf7f3895f1efa5d7659576c45fc3b99c0..c868459999da0d44dada16b6ac31639589d89c5c 100644 (file)
@@ -155,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) {