Add new checker-specific attribute 'objc_ownership_cfretain'. This is the same
as 'objc_ownership_cfretain' except that the method acts like a CFRetain instead
of a [... retain] (important in GC modes). Checker support is wired up, but
currently only for Objective-C message expressions (not function calls).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70218 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index c0a3b44..7bbfb26 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -1545,6 +1545,18 @@
d->addAttr(::new (S.Context) ObjCOwnershipRetainAttr());
}
+static void HandleObjCOwnershipCFRetainAttr(Decl *d, const AttributeList &Attr,
+ Sema &S) {
+
+ if (!isa<ParmVarDecl>(d)) {
+ S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) <<
+ "objc_ownership_cfretain" << 4 /* parameter */;
+ return;
+ }
+
+ d->addAttr(::new (S.Context) ObjCOwnershipCFRetainAttr());
+}
+
//===----------------------------------------------------------------------===//
// Top Level Sema Entry Points
//===----------------------------------------------------------------------===//
@@ -1587,6 +1599,8 @@
HandleObjCOwnershipRetainAttr(D, Attr, S); break;
case AttributeList::AT_objc_ownership_returns:
HandleObjCOwnershipReturnsAttr(D, Attr, S); break;
+ case AttributeList::AT_objc_ownership_cfretain:
+ HandleObjCOwnershipCFRetainAttr(D, Attr, S); break;
case AttributeList::AT_packed: HandlePackedAttr (D, Attr, S); break;
case AttributeList::AT_section: HandleSectionAttr (D, Attr, S); break;