]> granicus.if.org Git - clang/commitdiff
Fix assertion failure in cocoa::deriveNamingConvention()
authorTed Kremenek <kremenek@apple.com>
Fri, 17 Dec 2010 07:11:57 +0000 (07:11 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 17 Dec 2010 07:11:57 +0000 (07:11 +0000)
when the selector is the string 'mutable'.

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

lib/Analysis/CocoaConventions.cpp
test/Analysis/refcnt_naming.m

index 9a1be3ee05995c201f471ebabfc793e5f483a73d..ad359aad258f04437c5aadcab119d5871126005e 100644 (file)
@@ -98,10 +98,12 @@ cocoa::NamingConvention cocoa::deriveNamingConvention(Selector S) {
       if (memcmp(s, "mutable", 7) == 0) {
         // Look at the next word to see if it is "Copy".
         s = wordEnd;
-        wordEnd = parseWord(s);
-        len = wordEnd - s;
-        if (len == 4 && memcmp(s, "Copy", 4) == 0)
-          return CreateRule;
+        if (*s != '\0') {
+          wordEnd = parseWord(s);
+          len = wordEnd - s;
+          if (len == 4 && memcmp(s, "Copy", 4) == 0)
+            return CreateRule;
+        }
       }
       return NoConvention;
   }
index f84dd6e054365f381a189beb8cb352a72de0b151..f30ae1065469a4cb60342fe2ebaa0f254750a59c 100644 (file)
@@ -13,6 +13,8 @@ typedef signed char BOOL;
 @interface NamingTest : NSObject {}
 -(NSObject*)copyPhoto;
 -(NSObject*)mutableCopyPhoto;
+-(NSObject*)mutable;
+-(NSObject*)mutableCopying;
 -(NSObject*)photocopy;    // read as "photocopy"
 -(NSObject*)photoCopy;    // read as "photo Copy"
 -(NSObject*)__blebPRCopy; // read as "bleb PRCopy"
@@ -49,6 +51,8 @@ typedef signed char BOOL;
 void testNames(NamingTest* x) {
   [x copyPhoto]; // expected-warning{{leak}}
   [x mutableCopyPhoto]; // expected-warning{{leak}}
+  [x mutable]; // no-warning
+  [x mutableCopying]; // no-warning
   [x photocopy]; // no-warning
   [x photoCopy]; // no-warning
   [x __blebPRCopy]; // no-warning