Add new checker-specific attribute 'objc_ownership_retain'. This isn't hooked up
to the checker yet, but essentially it allows a user to specify that an
Objective-C method or C function increments the reference count of a passed
object.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70005 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index 5a99fdc..add12e5 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -1533,6 +1533,18 @@
   d->addAttr(::new (S.Context) ObjCOwnershipReturnsAttr());
 }
 
+static void HandleObjCOwnershipRetainAttr(Decl *d, const AttributeList &Attr,
+                                           Sema &S) {
+  
+  if (!isa<ParmVarDecl>(d)) {
+    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) <<
+    "objc_ownership_retain" << 4 /* parameter */;
+    return;
+  }
+  
+  d->addAttr(::new (S.Context) ObjCOwnershipRetainAttr());
+}
+
 //===----------------------------------------------------------------------===//
 // Top Level Sema Entry Points
 //===----------------------------------------------------------------------===//
@@ -1571,6 +1583,8 @@
   case AttributeList::AT_nothrow:     HandleNothrowAttr   (D, Attr, S); break;
 
   // Checker-specific.
+  case AttributeList::AT_objc_ownership_retain:
+    HandleObjCOwnershipRetainAttr(D, Attr, S); break;
   case AttributeList::AT_objc_ownership_returns:
     HandleObjCOwnershipReturnsAttr(D, Attr, S); break;