diff options
author | Jordan Rose <jordan_rose@apple.com> | 2012-06-15 18:19:52 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2012-06-15 18:19:52 +0000 |
commit | 95dfae824ef82ad51ba5f6b3a1681f2ef5febc45 (patch) | |
tree | 2e448b8c22bb27bd63d355366ea7c6cc3fde3246 /clang/lib/StaticAnalyzer | |
parent | 2684c68ddc2f19c34ab0ed280c1d3238a1279e73 (diff) | |
download | bcm5719-llvm-95dfae824ef82ad51ba5f6b3a1681f2ef5febc45.tar.gz bcm5719-llvm-95dfae824ef82ad51ba5f6b3a1681f2ef5febc45.zip |
[analyzer] RetainCount: don't track objects init'd with a delegate
We already didn't track objects that have delegates or callbacks or
objects that are passed through void * "context pointers". It's a
not-uncommon pattern to release the object in its callback, and so
the leak message we give is not very helpful.
llvm-svn: 158532
Diffstat (limited to 'clang/lib/StaticAnalyzer')
-rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp index 99243d2b141..fc21a1ba7d7 100644 --- a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp @@ -1351,10 +1351,15 @@ RetainSummaryManager::getStandardMethodSummary(const ObjCMethodDecl *MD, // because the reference count is quite possibly handled by a delegate // method. if (S.isKeywordSelector()) { - const std::string &str = S.getAsString(); - assert(!str.empty()); - if (StrInStrNoCase(str, "delegate:") != StringRef::npos) - ReceiverEff = StopTracking; + for (unsigned i = 0, e = S.getNumArgs(); i != e; ++i) { + StringRef Slot = S.getNameForSlot(i); + if (Slot.substr(Slot.size() - 8).equals_lower("delegate")) { + if (ResultEff == ObjCInitRetE) + ResultEff = RetEffect::MakeNoRet(); + else + ReceiverEff = StopTracking; + } + } } if (ScratchArgs.isEmpty() && ReceiverEff == DoNothing && |