diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-11-05 16:54:44 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-11-05 16:54:44 +0000 |
commit | 2855a93f0711604a31c00da94e1251bf1a30dfa0 (patch) | |
tree | 737818fbd68cb6a4205773f92f39db8819a86a88 /clang/lib/Analysis/CFRefCount.cpp | |
parent | cfd8ddc6de536ccc4f1903ad56fabc9f1245fbf6 (diff) | |
download | bcm5719-llvm-2855a93f0711604a31c00da94e1251bf1a30dfa0.tar.gz bcm5719-llvm-2855a93f0711604a31c00da94e1251bf1a30dfa0.zip |
initXXX methods can return owned objects
llvm-svn: 58758
Diffstat (limited to 'clang/lib/Analysis/CFRefCount.cpp')
-rw-r--r-- | clang/lib/Analysis/CFRefCount.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/Analysis/CFRefCount.cpp b/clang/lib/Analysis/CFRefCount.cpp index 80c6bf95324..1a38d957eb1 100644 --- a/clang/lib/Analysis/CFRefCount.cpp +++ b/clang/lib/Analysis/CFRefCount.cpp @@ -57,7 +57,12 @@ static bool followsFundamentalRule(const char* s) { 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 @@ CFRefCount::HandleSymbolDeath(GRStateManager& VMgr, 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); |