Hook up attribute 'objc_ownership_retain' to the analyzer. This attribute allows
users to specify that a method's argument is visibly retained (reference count
incremented).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70008 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp
index 9080e66..bb957b8 100644
--- a/lib/Analysis/CFRefCount.cpp
+++ b/lib/Analysis/CFRefCount.cpp
@@ -1095,7 +1095,18 @@
}
}
- if (!hasRetEffect)
+ // Determine if there are any arguments with a specific ArgEffect.
+ bool hasArgEffect = false;
+ unsigned i = 0;
+ for (ObjCMethodDecl::param_iterator I = MD->param_begin(),
+ E = MD->param_end(); I != E; ++I, ++i) {
+ if ((*I)->getAttr<ObjCOwnershipRetainAttr>()) {
+ ScratchArgs.push_back(std::make_pair(i, IncRefMsg));
+ hasArgEffect = true;
+ }
+}
+
+ if (!hasRetEffect && !hasArgEffect)
return 0;
return getPersistentSummary(RE);
diff --git a/lib/Parse/AttributeList.cpp b/lib/Parse/AttributeList.cpp
index a205c04..8048db8 100644
--- a/lib/Parse/AttributeList.cpp
+++ b/lib/Parse/AttributeList.cpp
@@ -135,7 +135,7 @@
break;
case 21:
if (!memcmp(Str, "objc_ownership_retain", 21))
- return AT_objc_ownership_returns;
+ return AT_objc_ownership_retain;
case 22:
if (!memcmp(Str, "objc_ownership_returns", 22))
return AT_objc_ownership_returns;