aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/CFRefCount.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-10-24 21:22:44 +0000
committerTed Kremenek <kremenek@apple.com>2008-10-24 21:22:44 +0000
commit9d1d57092e7e1cf2c56c64a32a1b816e99d2ae8c (patch)
tree08d292cfdc1022682bb0639c92020830f1cbdfc5 /lib/Analysis/CFRefCount.cpp
parent5c74d505d59c49c4b558e12f34533f47638ec81b (diff)
Use "followsFundamentalRule" to determine if an instance method allocates memory.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58114 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/CFRefCount.cpp')
-rw-r--r--lib/Analysis/CFRefCount.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp
index 78c9a40eec..21c2ecf4b9 100644
--- a/lib/Analysis/CFRefCount.cpp
+++ b/lib/Analysis/CFRefCount.cpp
@@ -951,8 +951,7 @@ RetainSummaryManager::getMethodSummary(ObjCMessageExpr* ME,
if (!isNSType(ME->getReceiver()->getType()))
return 0;
- if (CStrInCStrNoCase(s, "create") || CStrInCStrNoCase(s, "copy") ||
- CStrInCStrNoCase(s, "new")) {
+ if (followsFundamentalRule(s)) {
RetEffect E = isGCEnabled() ? RetEffect::MakeNoRet()
: RetEffect::MakeOwned(true);
@@ -2226,13 +2225,14 @@ namespace {
}
else {
if (getTF().isGCEnabled())
- return "leak of returned object (GC)";
+ return "[naming convention] leak of returned object (GC)";
if (getTF().getLangOptions().getGCMode() == LangOptions::HybridGC)
- return "leak of returned object (hybrid MM, non-GC)";
+ return "[naming convention] leak of returned object (hybrid MM, "
+ "non-GC)";
assert (getTF().getLangOptions().getGCMode() == LangOptions::NonGC);
- return "leak of returned object";
+ return "[naming convention] leak of returned object";
}
}
@@ -2617,12 +2617,13 @@ PathDiagnosticPiece* CFRefReport::getEndPath(BugReporter& br,
ObjCMethodDecl& MD = cast<ObjCMethodDecl>(BR.getGraph().getCodeDecl());
os << " is returned from a method whose name ('"
<< MD.getSelector().getName()
- << "') does not contain 'create', "
- "'copy', or 'new'. This violates the naming convention rules given"
+ << "') does not contain 'create' or 'copy' or otherwise starts with"
+ " 'new' or 'alloc'. This violates the naming convention rules given"
" in the Memory Management Guide for Cocoa (object leaked).";
}
else
- os << " is no longer referenced after this point and has a retain count of +"
+ os << " is no longer referenced after this point and has a retain count of"
+ " +"
<< RV->getCount() << " (object leaked).";
return new PathDiagnosticPiece(L, os.str(), Hint);