[cfe-commits] r71309 - /cfe/trunk/lib/Analysis/CFRefCount.cpp
Ted Kremenek
kremenek at apple.com
Fri May 8 19:58:13 PDT 2009
Author: kremenek
Date: Fri May 8 21:58:13 2009
New Revision: 71309
URL: http://llvm.org/viewvc/llvm-project?rev=71309&view=rev
Log:
Add back analyzer support for ns_returns_retained and cf_returns_retained.
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=71309&r1=71308&r2=71309&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Fri May 8 21:58:13 2009
@@ -809,6 +809,12 @@
RetainSummary* getCommonMethodSummary(const ObjCMethodDecl* MD,
Selector S, QualType RetTy);
+ void updateSummaryFromAnnotations(RetainSummary &Summ,
+ const ObjCMethodDecl *MD);
+
+ void updateSummaryFromAnnotations(RetainSummary &Summ,
+ const FunctionDecl *FD);
+
bool isGCEnabled() const { return GCEnabled; }
RetainSummary *copySummary(RetainSummary *OldSumm) {
@@ -1033,6 +1039,10 @@
if (!S)
S = getDefaultSummary();
+ // Annotations override defaults.
+ assert(S);
+ updateSummaryFromAnnotations(*S, FD);
+
FuncSummaries[FD] = S;
return S;
}
@@ -1116,7 +1126,41 @@
? RetEffect::MakeReceiverAlias()
: RetEffect::MakeNoRet());
}
-
+
+void
+RetainSummaryManager::updateSummaryFromAnnotations(RetainSummary &Summ,
+ const FunctionDecl *FD) {
+ if (!FD)
+ return;
+
+ // Determine if there is a special return effect for this method.
+ if (isTrackedObjCObjectType(FD->getResultType())) {
+ if (FD->getAttr<NSReturnsRetainedAttr>()) {
+ Summ.setRetEffect(ObjCAllocRetE);
+ }
+ else if (FD->getAttr<CFReturnsRetainedAttr>()) {
+ Summ.setRetEffect(RetEffect::MakeOwned(RetEffect::CF, true));
+ }
+ }
+}
+
+void
+RetainSummaryManager::updateSummaryFromAnnotations(RetainSummary &Summ,
+ const ObjCMethodDecl *MD) {
+ if (!MD)
+ return;
+
+ // Determine if there is a special return effect for this method.
+ if (isTrackedObjCObjectType(MD->getResultType())) {
+ if (MD->getAttr<NSReturnsRetainedAttr>()) {
+ Summ.setRetEffect(ObjCAllocRetE);
+ }
+ else if (MD->getAttr<CFReturnsRetainedAttr>()) {
+ Summ.setRetEffect(RetEffect::MakeOwned(RetEffect::CF, true));
+ }
+ }
+}
+
RetainSummary*
RetainSummaryManager::getCommonMethodSummary(const ObjCMethodDecl* MD,
Selector S, QualType RetTy) {
@@ -1199,6 +1243,9 @@
else
Summ = getCommonMethodSummary(MD, S, RetTy);
+ // Annotations override defaults.
+ updateSummaryFromAnnotations(*Summ, MD);
+
// Memoize the summary.
ObjCMethodSummaries[ObjCSummaryKey(ClsName, S)] = Summ;
return Summ;
@@ -1218,6 +1265,9 @@
return I->second;
RetainSummary *Summ = getCommonMethodSummary(MD, S, RetTy);
+
+ // Annotations override defaults.
+ updateSummaryFromAnnotations(*Summ, MD);
// Memoize the summary.
ObjCClassMethodSummaries[ObjCSummaryKey(ClsName, S)] = Summ;
More information about the cfe-commits
mailing list