Fix assertion failure in cocoa::deriveNamingConvention()

when the selector is the string 'mutable'.

llvm-svn: 122046
This commit is contained in:
Ted Kremenek 2010-12-17 07:11:57 +00:00
parent d14b0f1db7
commit b44f0f9abe
2 changed files with 10 additions and 4 deletions

View 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;
}

View 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