diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-10-24 21:18:08 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-10-24 21:18:08 +0000 |
commit | 01acb6284e83623f5843d429466c85fab1e13c2c (patch) | |
tree | e2a14133c7fad5c9080abf9c5ee3979aabfb8857 /clang/lib | |
parent | 8d8a14a3fc509811f7f66b25e3c8eae450be658c (diff) | |
download | bcm5719-llvm-01acb6284e83623f5843d429466c85fab1e13c2c.tar.gz bcm5719-llvm-01acb6284e83623f5843d429466c85fab1e13c2c.zip |
followsFundamentalRule() returns true if "alloc" or "new" appear at the beginning of the string, not anywhere within it.
llvm-svn: 58112
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Analysis/CFRefCount.cpp | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/clang/lib/Analysis/CFRefCount.cpp b/clang/lib/Analysis/CFRefCount.cpp index 20897acb795..78c9a40eeca 100644 --- a/clang/lib/Analysis/CFRefCount.cpp +++ b/clang/lib/Analysis/CFRefCount.cpp @@ -34,8 +34,30 @@ #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, |