[cfe-commits] r58114 - /cfe/trunk/lib/Analysis/CFRefCount.cpp

Ted Kremenek kremenek at apple.com
Fri Oct 24 14:22:44 PDT 2008


Author: kremenek
Date: Fri Oct 24 16:22:44 2008
New Revision: 58114

URL: http://llvm.org/viewvc/llvm-project?rev=58114&view=rev
Log:
Use "followsFundamentalRule" to determine if an instance method allocates memory.

Modified:
    cfe/trunk/lib/Analysis/CFRefCount.cpp

Modified: cfe/trunk/lib/Analysis/CFRefCount.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFRefCount.cpp?rev=58114&r1=58113&r2=58114&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Fri Oct 24 16:22:44 2008
@@ -951,8 +951,7 @@
   if (!isNSType(ME->getReceiver()->getType()))
     return 0;
   
-  if (CStrInCStrNoCase(s, "create") || CStrInCStrNoCase(s, "copy")  || 
-      CStrInCStrNoCase(s, "new")) {
+  if (followsFundamentalRule(s)) {
     
     RetEffect E = isGCEnabled() ? RetEffect::MakeNoRet()
                                 : RetEffect::MakeOwned(true);  
@@ -2226,13 +2225,14 @@
       }
       else {
         if (getTF().isGCEnabled())
-          return "leak of returned object (GC)";
+          return "[naming convention] leak of returned object (GC)";
         
         if (getTF().getLangOptions().getGCMode() == LangOptions::HybridGC)
-          return "leak of returned object (hybrid MM, non-GC)";
+          return "[naming convention] leak of returned object (hybrid MM, "
+                 "non-GC)";
         
         assert (getTF().getLangOptions().getGCMode() == LangOptions::NonGC);
-        return "leak of returned object";        
+        return "[naming convention] leak of returned object";        
       }
     }
     
@@ -2617,12 +2617,13 @@
     ObjCMethodDecl& MD = cast<ObjCMethodDecl>(BR.getGraph().getCodeDecl());
     os << " is returned from a method whose name ('"
        << MD.getSelector().getName()
-       << "') does not contain 'create', "
-          "'copy', or 'new'.  This violates the naming convention rules given"
+       << "') does not contain 'create' or 'copy' or otherwise starts with"
+          " 'new' or 'alloc'.  This violates the naming convention rules given"
           " in the Memory Management Guide for Cocoa (object leaked).";
   }
   else
-    os << " is no longer referenced after this point and has a retain count of +"
+    os << " is no longer referenced after this point and has a retain count of"
+          " +"
        << RV->getCount() << " (object leaked).";
   
   return new PathDiagnosticPiece(L, os.str(), Hint);





More information about the cfe-commits mailing list