From 5eef59ee77456640a2d03bb90fc717d5a43e175d Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Fri, 17 Dec 2010 07:11:57 +0000 Subject: [PATCH] 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 --- lib/Analysis/CocoaConventions.cpp | 10 ++++++---- test/Analysis/refcnt_naming.m | 4 ++++ 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 -- 2.40.0