From: Anna Zaks Date: Wed, 11 Nov 2015 00:49:22 +0000 (+0000) Subject: [static analyzer] Don't flag nil storage into NSMutableDictionary. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b59606171d93d85f64406b7e7d31996d381a5f14;p=clang [static analyzer] Don't flag nil storage into NSMutableDictionary. 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 --- diff --git a/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp b/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp index e157478433..fd08b0239b 100644 --- a/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp +++ b/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp @@ -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; } diff --git a/test/Analysis/NSContainers.m b/test/Analysis/NSContainers.m index d04b331bf7..c868459999 100644 --- a/test/Analysis/NSContainers.m +++ b/test/Analysis/NSContainers.m @@ -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) {