aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-12-17 07:11:57 +0000
committerTed Kremenek <kremenek@apple.com>2010-12-17 07:11:57 +0000
commit5eef59ee77456640a2d03bb90fc717d5a43e175d (patch)
tree5531cce17fdb5eb108666097cc143eb09367386b
parentb321c0c0ba957d78475e72cebde4028fdaa00f8f (diff)
Fix assertion failure in cocoa::deriveNamingConvention()
when the selector is the string 'mutable'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122046 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Analysis/CocoaConventions.cpp10
-rw-r--r--test/Analysis/refcnt_naming.m4
2 files changed, 10 insertions, 4 deletions
diff --git a/lib/Analysis/CocoaConventions.cpp b/lib/Analysis/CocoaConventions.cpp
index 9a1be3ee05..ad359aad25 100644
--- a/lib/Analysis/CocoaConventions.cpp
+++ b/lib/Analysis/CocoaConventions.cpp
@@ -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;
}
diff --git a/test/Analysis/refcnt_naming.m b/test/Analysis/refcnt_naming.m
index f84dd6e054..f30ae10654 100644
--- a/test/Analysis/refcnt_naming.m
+++ b/test/Analysis/refcnt_naming.m
@@ -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