[cfe-commits] r69936 - /cfe/trunk/lib/Analysis/CFRefCount.cpp
Ted Kremenek
kremenek at apple.com
Thu Apr 23 16:08:23 PDT 2009
Author: kremenek
Date: Thu Apr 23 18:08:22 2009
New Revision: 69936
URL: http://llvm.org/viewvc/llvm-project?rev=69936&view=rev
Log:
Refactor common logic in getMethodSummary() and getClassMethodSummary(). No
functionality change.
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=69936&r1=69935&r2=69936&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Thu Apr 23 18:08:22 2009
@@ -704,6 +704,7 @@
RetainSummary* getSummary(FunctionDecl* FD);
RetainSummary* getMethodSummary(ObjCMessageExpr* ME, ObjCInterfaceDecl* ID);
RetainSummary* getClassMethodSummary(ObjCMessageExpr *ME);
+ RetainSummary* getCommonMethodSummary(ObjCMessageExpr *ME, const char *s);
bool isGCEnabled() const { return GCEnabled; }
};
@@ -1056,6 +1057,25 @@
RetainSummary*
+RetainSummaryManager::getCommonMethodSummary(ObjCMessageExpr* ME, const char *s)
+{
+ // Look for methods that return an owned object.
+ if (!isTrackedObjectType(ME->getType()))
+ return 0;
+
+ // EXPERIMENTAL: Assume the Cocoa conventions for all objects returned
+ // by instance methods.
+
+ RetEffect E =
+ followsFundamentalRule(s)
+ ? (isGCEnabled() ? RetEffect::MakeNotOwned(RetEffect::ObjC)
+ : RetEffect::MakeOwned(RetEffect::ObjC, true))
+ : RetEffect::MakeNotOwned(RetEffect::ObjC);
+
+ return getPersistentSummary(E);
+}
+
+RetainSummary*
RetainSummaryManager::getMethodSummary(ObjCMessageExpr* ME,
ObjCInterfaceDecl* ID) {
@@ -1069,25 +1089,12 @@
// "initXXX": pass-through for receiver.
const char* s = S.getIdentifierInfoForSlot(0)->getName();
- assert (ScratchArgs.empty());
+ assert(ScratchArgs.empty());
if (deriveNamingConvention(s) == InitRule)
return getInitMethodSummary(ME);
- // Look for methods that return an owned object.
- if (!isTrackedObjectType(ME->getType()))
- return 0;
-
- // EXPERIMENTAL: Assume the Cocoa conventions for all objects returned
- // by instance methods.
-
- RetEffect E =
- followsFundamentalRule(s)
- ? (isGCEnabled() ? RetEffect::MakeNotOwned(RetEffect::ObjC)
- : RetEffect::MakeOwned(RetEffect::ObjC, true))
- : RetEffect::MakeNotOwned(RetEffect::ObjC);
-
- RetainSummary* Summ = getPersistentSummary(E);
+ RetainSummary *Summ = getCommonMethodSummary(ME, s);
ObjCMethodSummaries[ME] = Summ;
return Summ;
}
@@ -1107,21 +1114,8 @@
if (I != ObjCClassMethodSummaries.end())
return I->second;
- // Look for methods that return an owned object.
- if (!isTrackedObjectType(ME->getType()))
- return 0;
-
- // EXPERIMENTAL: Assume the Cocoa conventions for all objects returned
- // by class methods.
- // Look for methods that return an owned object.
-
- const char* s = S.getIdentifierInfoForSlot(0)->getName();
- RetEffect E = followsFundamentalRule(s)
- ? (isGCEnabled() ? RetEffect::MakeNotOwned(RetEffect::ObjC)
- : RetEffect::MakeOwned(RetEffect::ObjC, true))
- : RetEffect::MakeNotOwned(RetEffect::ObjC);
-
- RetainSummary* Summ = getPersistentSummary(E);
+ RetainSummary* Summ =
+ getCommonMethodSummary(ME, S.getIdentifierInfoForSlot(0)->getName());
ObjCClassMethodSummaries[ObjCSummaryKey(ClsName, S)] = Summ;
return Summ;
}
More information about the cfe-commits
mailing list