diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-04-30 19:18:03 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-04-30 19:18:03 +0000 |
commit | 72c9dcd9dbc1ee65d7863d1ea04c2cc928007cc9 (patch) | |
tree | f7a59e31ab57d696664c3946b0f37b20cb754c72 /lib | |
parent | b27d1174673d457e2ee7906c14a92bba35242cea (diff) |
Allow attributes 'objc_ownership_retain' and 'objc_ownership_release' to be
applied to ObjCMethodDecls, not just parameters. This allows one to specific
side-effects on the receiver of a message expression. No checker support yet.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70505 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Sema/SemaDeclAttr.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 4853028ba3..1e3a7e58bb 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -1559,10 +1559,10 @@ static void HandleObjCOwnershipReturnsAttr(Decl *d, const AttributeList &Attr, d->addAttr(::new (S.Context) ObjCOwnershipReturnsAttr()); } -static void HandleObjCOwnershipParmAttr(Decl *d, const AttributeList &Attr, - Sema &S) { +static void HandleObjCOwnershipAttr(Decl *d, const AttributeList &Attr, + Sema &S, bool attachToMethodDecl = false) { - if (!isa<ParmVarDecl>(d)) { + if (!isa<ParmVarDecl>(d) && (!attachToMethodDecl || !isa<ObjCMethodDecl>(d))){ const char *name; switch (Attr.getKind()) { @@ -1582,7 +1582,8 @@ static void HandleObjCOwnershipParmAttr(Decl *d, const AttributeList &Attr, }; S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) << name - << 4 /* parameter */; + << (attachToMethodDecl ? 5 /* parameter or method decl */ + : 4 /* parameter */); return; } @@ -1643,10 +1644,11 @@ static void ProcessDeclAttribute(Decl *D, const AttributeList &Attr, Sema &S) { // Checker-specific. case AttributeList::AT_objc_ownership_cfrelease: case AttributeList::AT_objc_ownership_cfretain: + HandleObjCOwnershipAttr(D, Attr, S); break; case AttributeList::AT_objc_ownership_make_collectable: case AttributeList::AT_objc_ownership_release: case AttributeList::AT_objc_ownership_retain: - HandleObjCOwnershipParmAttr(D, Attr, S); break; + HandleObjCOwnershipAttr(D, Attr, S, true); break; case AttributeList::AT_objc_ownership_returns: HandleObjCOwnershipReturnsAttr(D, Attr, S); break; |