[cfe-commits] r122046 - in /cfe/trunk: lib/Analysis/CocoaConventions.cpp test/Analysis/refcnt_naming.m

Chris Lattner clattner at apple.com
Fri Dec 17 09:41:46 PST 2010


On Dec 16, 2010, at 11:11 PM, Ted Kremenek wrote:

> Author: kremenek
> Date: Fri Dec 17 01:11:57 2010
> New Revision: 122046
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=122046&view=rev
> Log:
> Fix assertion failure in cocoa::deriveNamingConvention()
> when the selector is the string 'mutable'.

Hi Ted,

Would it make more sense to use stringref for stuff like this? StringRef is efficient and much more convenient for slicing strings up like this.  You can do things like:

if (s.substr(0, 7) == "mutable")
  ...

-Chris

> 
> Modified:
>    cfe/trunk/lib/Analysis/CocoaConventions.cpp
>    cfe/trunk/test/Analysis/refcnt_naming.m
> 
> Modified: cfe/trunk/lib/Analysis/CocoaConventions.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CocoaConventions.cpp?rev=122046&r1=122045&r2=122046&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Analysis/CocoaConventions.cpp (original)
> +++ cfe/trunk/lib/Analysis/CocoaConventions.cpp Fri Dec 17 01:11:57 2010
> @@ -98,10 +98,12 @@
>       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;
>   }
> 
> Modified: cfe/trunk/test/Analysis/refcnt_naming.m
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/refcnt_naming.m?rev=122046&r1=122045&r2=122046&view=diff
> ==============================================================================
> --- cfe/trunk/test/Analysis/refcnt_naming.m (original)
> +++ cfe/trunk/test/Analysis/refcnt_naming.m Fri Dec 17 01:11:57 2010
> @@ -13,6 +13,8 @@
> @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 @@
> 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
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits





More information about the cfe-commits mailing list