aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/CFRefCount.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-05-04 15:40:58 +0000
committerTed Kremenek <kremenek@apple.com>2009-05-04 15:40:58 +0000
commit05673d61fea9ea656996fe806ece6abf4432075e (patch)
tree8f1bc022607e11cfd391fcdc723775e0b05e0a63 /lib/Analysis/CFRefCount.cpp
parente401a0ce4ac2b77c69ee08c09eb04a3a41652fd6 (diff)
retain checker: Pull out logic for parameter annotations into a
separate method. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70870 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/CFRefCount.cpp')
-rw-r--r--lib/Analysis/CFRefCount.cpp33
1 files changed, 21 insertions, 12 deletions
diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp
index 047d9f5844..59d4845250 100644
--- a/lib/Analysis/CFRefCount.cpp
+++ b/lib/Analysis/CFRefCount.cpp
@@ -779,6 +779,9 @@ public:
RetainSummary* getCommonMethodSummary(const ObjCMethodDecl* MD,
Selector S, QualType RetTy);
+ void updateSummaryArgEffFromAnnotations(RetainSummary &Summ, unsigned i,
+ const ParmVarDecl *PD);
+
void updateSummaryFromAnnotations(RetainSummary &Summ,
const ObjCMethodDecl *MD);
@@ -1092,6 +1095,22 @@ RetainSummaryManager::getInitMethodSummary(QualType RetTy) {
void
+RetainSummaryManager::updateSummaryArgEffFromAnnotations(RetainSummary &Summ,
+ unsigned i,
+ const ParmVarDecl *PD){
+ if (PD->getAttr<ObjCOwnershipRetainAttr>())
+ Summ.setArgEffect(AF, i, IncRefMsg);
+ else if (PD->getAttr<ObjCOwnershipCFRetainAttr>())
+ Summ.setArgEffect(AF, i, IncRef);
+ else if (PD->getAttr<ObjCOwnershipReleaseAttr>())
+ Summ.setArgEffect(AF, i, DecRefMsg);
+ else if (PD->getAttr<ObjCOwnershipCFReleaseAttr>())
+ Summ.setArgEffect(AF, i, DecRef);
+ else if (PD->getAttr<ObjCOwnershipMakeCollectableAttr>())
+ Summ.setArgEffect(AF, i, MakeCollectable);
+}
+
+void
RetainSummaryManager::updateSummaryFromAnnotations(RetainSummary &Summ,
const ObjCMethodDecl *MD) {
if (!MD)
@@ -1109,18 +1128,8 @@ RetainSummaryManager::updateSummaryFromAnnotations(RetainSummary &Summ,
// Determine if there are any arguments with a specific ArgEffect.
unsigned i = 0;
for (ObjCMethodDecl::param_iterator I = MD->param_begin(),
- E = MD->param_end(); I != E; ++I, ++i) {
- if ((*I)->getAttr<ObjCOwnershipRetainAttr>())
- Summ.setArgEffect(AF, i, IncRefMsg);
- else if ((*I)->getAttr<ObjCOwnershipCFRetainAttr>())
- Summ.setArgEffect(AF, i, IncRef);
- else if ((*I)->getAttr<ObjCOwnershipReleaseAttr>())
- Summ.setArgEffect(AF, i, DecRefMsg);
- else if ((*I)->getAttr<ObjCOwnershipCFReleaseAttr>())
- Summ.setArgEffect(AF, i, DecRef);
- else if ((*I)->getAttr<ObjCOwnershipMakeCollectableAttr>())
- Summ.setArgEffect(AF, i, MakeCollectable);
- }
+ E = MD->param_end(); I != E; ++I, ++i)
+ updateSummaryArgEffFromAnnotations(Summ, i, *I);
// Determine any effects on the receiver.
if (MD->getAttr<ObjCOwnershipRetainAttr>())