]> granicus.if.org Git - clang/commitdiff
Added skeleton checking for NSString's method initWithFormat: (do not pass nil)....
authorTed Kremenek <kremenek@apple.com>
Fri, 28 Mar 2008 16:09:38 +0000 (16:09 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 28 Mar 2008 16:09:38 +0000 (16:09 +0000)
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

lib/Analysis/BasicObjCFoundationChecks.cpp

index f6b4224f05a8539272b059917df91943d597c98b..82cabaf7a3fd4587a98182eae80c6f5e47497620 100644 (file)
@@ -209,12 +209,21 @@ bool BasicObjCFoundationChecks::AuditNSString(NodeTy* N,
   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 @@ bool BasicObjCFoundationChecks::AuditNSString(NodeTy* N,
         return CheckNilArg(N, 0);
       
       break;
-      
+
     case 29:
       if (!strcmp(cstr, "compare:options:range:locale:"))
         return CheckNilArg(N, 0);