]> granicus.if.org Git - clang/commitdiff
followsFundamentalRule() returns true if "alloc" or "new" appear at the beginning...
authorTed Kremenek <kremenek@apple.com>
Fri, 24 Oct 2008 21:18:08 +0000 (21:18 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 24 Oct 2008 21:18:08 +0000 (21:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58112 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/CFRefCount.cpp

index 20897acb7955273829caf039a699549ab67568ff..78c9a40eeca4fb2f6be08d47db578c39b2802765 100644 (file)
 #include <stdarg.h>
 
 using namespace clang;
+
+//===----------------------------------------------------------------------===//
+// Utility functions.
+//===----------------------------------------------------------------------===//
+
 using llvm::CStrInCStrNoCase;
 
+// The "fundamental rule" for naming conventions of methods:
+//  (url broken into two lines)
+//  http://developer.apple.com/documentation/Cocoa/Conceptual/
+//     MemoryMgmt/Tasks/MemoryManagementRules.html
+//
+// "You take ownership of an object if you create it using a method whose name
+//  begins with “alloc” or “new” or contains “copy” (for example, alloc, 
+//  newObject, or mutableCopy), or if you send it a retain message. You are
+//  responsible for relinquishing ownership of objects you own using release
+//  or autorelease. Any other time you receive an object, you must
+//  not release it."
+//
+static bool followsFundamentalRule(const char* s) {
+  return CStrInCStrNoCase(s, "create") || CStrInCStrNoCase(s, "copy")  || 
+  CStrInCStrNoCase(s, "new") == s || CStrInCStrNoCase(s, "alloc") == s;
+}  
+
 //===----------------------------------------------------------------------===//
 // Selector creation functions.
 //===----------------------------------------------------------------------===//
@@ -1834,22 +1856,6 @@ void CFRefCount::EvalStore(ExplodedNodeSet<GRState>& Dst,
 
 // End-of-path.
 
-// The "fundamental rule" for naming conventions of methods:
-//  (url broken into two lines)
-//  http://developer.apple.com/documentation/Cocoa/Conceptual/
-//     MemoryMgmt/Tasks/MemoryManagementRules.html
-//
-// "You take ownership of an object if you create it using a method whose name
-//  begins with “alloc” or “new” or contains “copy” (for example, alloc, 
-//  newObject, or mutableCopy), or if you send it a retain message. You are
-//  responsible for relinquishing ownership of objects you own using release
-//  or autorelease. Any other time you receive an object, you must
-//  not release it."
-//
-static bool followsFundamentalRule(const char* s) {
-  return CStrInCStrNoCase(s, "create") || CStrInCStrNoCase(s, "copy")  || 
-         CStrInCStrNoCase(s, "new");
-}  
 
 std::pair<GRStateRef,bool>
 CFRefCount::HandleSymbolDeath(GRStateManager& VMgr,