]> granicus.if.org Git - clang/commitdiff
retain checker: Pull out logic for parameter annotations into a
authorTed Kremenek <kremenek@apple.com>
Mon, 4 May 2009 15:40:58 +0000 (15:40 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 4 May 2009 15:40:58 +0000 (15:40 +0000)
separate method.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70870 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/CFRefCount.cpp

index 047d9f5844dd712e55a5bf3cc82d3b2a185027bb..59d484525031a053a1bee6d2623878c1c1f1f1e6 100644 (file)
@@ -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);
   
@@ -1091,6 +1094,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) {
@@ -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>())