[cfe-commits] r58758 - /cfe/trunk/lib/Analysis/CFRefCount.cpp
Ted Kremenek
kremenek at apple.com
Wed Nov 5 08:54:46 PST 2008
Author: kremenek
Date: Wed Nov 5 10:54:44 2008
New Revision: 58758
URL: http://llvm.org/viewvc/llvm-project?rev=58758&view=rev
Log:
initXXX methods can return owned objects
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=58758&r1=58757&r2=58758&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Wed Nov 5 10:54:44 2008
@@ -57,7 +57,12 @@
while (*s == '_') ++s;
return CStrInCStrNoCase(s, "create") || CStrInCStrNoCase(s, "copy") ||
CStrInCStrNoCase(s, "new") == s || CStrInCStrNoCase(s, "alloc") == s;
-}
+}
+
+static bool followsReturnRule(const char* s) {
+ while (*s == '_') ++s;
+ return followsFundamentalRule(s) || CStrInCStrNoCase(s, "init") == s;
+}
//===----------------------------------------------------------------------===//
// Selector creation functions.
@@ -1878,7 +1883,7 @@
if (V.isReturnedOwned() && V.getCount() == 0)
if (const ObjCMethodDecl* MD = dyn_cast<ObjCMethodDecl>(CD)) {
std::string s = MD->getSelector().getName();
- if (!followsFundamentalRule(s.c_str())) {
+ if (!followsReturnRule(s.c_str())) {
hasLeak = true;
state = state.set<RefBindings>(sid, V ^ RefVal::ErrorLeakReturned);
return std::make_pair(state, true);
More information about the cfe-commits
mailing list