Skip to content

Commit 920406b

Browse files
committed
Use "followsFundamentalRule" to determine if an instance method allocates memory.
llvm-svn: 58114
1 parent e45896f commit 920406b

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

clang/lib/Analysis/CFRefCount.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -951,8 +951,7 @@ RetainSummaryManager::getMethodSummary(ObjCMessageExpr* ME,
951951
if (!isNSType(ME->getReceiver()->getType()))
952952
return 0;
953953

954-
if (CStrInCStrNoCase(s, "create") || CStrInCStrNoCase(s, "copy") ||
955-
CStrInCStrNoCase(s, "new")) {
954+
if (followsFundamentalRule(s)) {
956955

957956
RetEffect E = isGCEnabled() ? RetEffect::MakeNoRet()
958957
: RetEffect::MakeOwned(true);
@@ -2226,13 +2225,14 @@ namespace {
22262225
}
22272226
else {
22282227
if (getTF().isGCEnabled())
2229-
return "leak of returned object (GC)";
2228+
return "[naming convention] leak of returned object (GC)";
22302229

22312230
if (getTF().getLangOptions().getGCMode() == LangOptions::HybridGC)
2232-
return "leak of returned object (hybrid MM, non-GC)";
2231+
return "[naming convention] leak of returned object (hybrid MM, "
2232+
"non-GC)";
22332233

22342234
assert (getTF().getLangOptions().getGCMode() == LangOptions::NonGC);
2235-
return "leak of returned object";
2235+
return "[naming convention] leak of returned object";
22362236
}
22372237
}
22382238

@@ -2617,12 +2617,13 @@ PathDiagnosticPiece* CFRefReport::getEndPath(BugReporter& br,
26172617
ObjCMethodDecl& MD = cast<ObjCMethodDecl>(BR.getGraph().getCodeDecl());
26182618
os << " is returned from a method whose name ('"
26192619
<< MD.getSelector().getName()
2620-
<< "') does not contain 'create', "
2621-
"'copy', or 'new'. This violates the naming convention rules given"
2620+
<< "') does not contain 'create' or 'copy' or otherwise starts with"
2621+
" 'new' or 'alloc'. This violates the naming convention rules given"
26222622
" in the Memory Management Guide for Cocoa (object leaked).";
26232623
}
26242624
else
2625-
os << " is no longer referenced after this point and has a retain count of +"
2625+
os << " is no longer referenced after this point and has a retain count of"
2626+
" +"
26262627
<< RV->getCount() << " (object leaked).";
26272628

26282629
return new PathDiagnosticPiece(L, os.str(), Hint);

0 commit comments

Comments
 (0)