[llvm-branch-commits] [cfe-branch] r71867 - in /cfe/branches/Apple/Dib: lib/Analysis/CFRefCount.cpp test/Analysis/retain-release.m

Mike Stump mrs at apple.com
Fri May 15 09:20:18 PDT 2009


Author: mrs
Date: Fri May 15 11:20:17 2009
New Revision: 71867

URL: http://llvm.org/viewvc/llvm-project?rev=71867&view=rev
Log:
Merge in 71857:

Fix crash when deriving the enclosing summary of a method whose first selector slot has a null IdentifierInfo*.  This happens when analyzing Growl.

Modified:
    cfe/branches/Apple/Dib/lib/Analysis/CFRefCount.cpp
    cfe/branches/Apple/Dib/test/Analysis/retain-release.m

Modified: cfe/branches/Apple/Dib/lib/Analysis/CFRefCount.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/lib/Analysis/CFRefCount.cpp?rev=71867&r1=71866&r2=71867&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/branches/Apple/Dib/lib/Analysis/CFRefCount.cpp Fri May 15 11:20:17 2009
@@ -76,7 +76,14 @@
   return s;
 }
 
-static NamingConvention deriveNamingConvention(const char* s) {
+static NamingConvention deriveNamingConvention(Selector S) {
+  IdentifierInfo *II = S.getIdentifierInfoForSlot(0);
+  
+  if (!II)
+    return NoConvention;
+  
+  const char *s = II->getName();
+  
   // A method/function name may contain a prefix.  We don't know it is there,
   // however, until we encounter the first '_'.
   bool InPossiblePrefix = true;
@@ -145,8 +152,8 @@
   return C;
 }
 
-static bool followsFundamentalRule(const char* s) {
-  return deriveNamingConvention(s) == CreateRule;
+static bool followsFundamentalRule(Selector S) {
+  return deriveNamingConvention(S) == CreateRule;
 }
 
 static const ObjCMethodDecl*
@@ -1218,19 +1225,17 @@
   if (isTrackedObjCObjectType(RetTy)) {    
     // EXPERIMENTAL: Assume the Cocoa conventions for all objects returned
     //  by instance methods.
-    RetEffect E =
-      followsFundamentalRule(S.getIdentifierInfoForSlot(0)->getName())
-        ? ObjCAllocRetE : RetEffect::MakeNotOwned(RetEffect::ObjC);
+    RetEffect E = followsFundamentalRule(S)
+                  ? ObjCAllocRetE : RetEffect::MakeNotOwned(RetEffect::ObjC);
     
     return getPersistentSummary(E, ReceiverEff, MayEscape);    
   }
   
   // Look for methods that return an owned core foundation object.
   if (isTrackedCFObjectType(RetTy)) {
-    RetEffect E =
-      followsFundamentalRule(S.getIdentifierInfoForSlot(0)->getName())
-    ? RetEffect::MakeOwned(RetEffect::CF, true)
-    : RetEffect::MakeNotOwned(RetEffect::CF);
+    RetEffect E = followsFundamentalRule(S)
+      ? RetEffect::MakeOwned(RetEffect::CF, true)
+      : RetEffect::MakeNotOwned(RetEffect::CF);
     
     return getPersistentSummary(E, ReceiverEff, MayEscape);
   }
@@ -1258,8 +1263,7 @@
   RetainSummary *Summ = 0;
   
   // "initXXX": pass-through for receiver.
-  if (deriveNamingConvention(S.getIdentifierInfoForSlot(0)->getName()) 
-      == InitRule)
+  if (deriveNamingConvention(S) == InitRule)
     Summ = getInitMethodSummary(RetTy);
   else
     Summ = getCommonMethodSummary(MD, S, RetTy);

Modified: cfe/branches/Apple/Dib/test/Analysis/retain-release.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/test/Analysis/retain-release.m?rev=71867&r1=71866&r2=71867&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/test/Analysis/retain-release.m (original)
+++ cfe/branches/Apple/Dib/test/Analysis/retain-release.m Fri May 15 11:20:17 2009
@@ -619,6 +619,19 @@
 }
 
 //===----------------------------------------------------------------------===//
+// Method name that has a null IdentifierInfo* for its first selector slot.
+// This test just makes sure that we handle it.
+//===----------------------------------------------------------------------===//
+
+ at interface TestNullIdentifier
+ at end
+
+ at implementation TestNullIdentifier
++ (id):(int)x, ... {
+  return [[NSString alloc] init]; // expected-warning{{leak}}
+}
+
+//===----------------------------------------------------------------------===//
 // Tests of ownership attributes.
 //===----------------------------------------------------------------------===//
 





More information about the llvm-branch-commits mailing list