Added skeleton checking for NSString's method initWithFormat: (do not pass nil). This won't be useful in most cases right now
because the analyzer isn't tracking expected types for an object, and [NSString alloc] just runs "id".
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48917 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/BasicObjCFoundationChecks.cpp b/lib/Analysis/BasicObjCFoundationChecks.cpp
index f6b4224..82cabaf 100644
--- a/lib/Analysis/BasicObjCFoundationChecks.cpp
+++ b/lib/Analysis/BasicObjCFoundationChecks.cpp
@@ -209,12 +209,21 @@
switch (len) {
default:
break;
- case 8:
-
+ case 8:
if (!strcmp(cstr, "compare:"))
return CheckNilArg(N, 0);
break;
+
+ case 15:
+ // FIXME: Checking for initWithFormat: will not work in most cases
+ // yet because [NSString alloc] returns id, not NSString*. We will
+ // need support for tracking expected-type information in the analyzer
+ // to find these errors.
+ if (!strcmp(cstr, "initWithFormat:"))
+ return CheckNilArg(N, 0);
+
+ break;
case 16:
if (!strcmp(cstr, "compare:options:"))
@@ -234,7 +243,7 @@
return CheckNilArg(N, 0);
break;
-
+
case 29:
if (!strcmp(cstr, "compare:options:range:locale:"))
return CheckNilArg(N, 0);