зеркало из https://github.com/microsoft/clang-1.git
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
This commit is contained in:
Родитель
b27d117467
Коммит
72c9dcd9db
|
@ -408,7 +408,7 @@ def warn_attribute_weak_import_invalid_on_definition : Warning<
|
||||||
"'weak_import' attribute cannot be specified on a definition">;
|
"'weak_import' attribute cannot be specified on a definition">;
|
||||||
def warn_attribute_wrong_decl_type : Warning<
|
def warn_attribute_wrong_decl_type : Warning<
|
||||||
"'%0' attribute only applies to %select{function|union|"
|
"'%0' attribute only applies to %select{function|union|"
|
||||||
"variable and function|function or method|parameter}1 types">;
|
"variable and function|function or method|parameter|parameter or Objective-C method}1 types">;
|
||||||
def warn_gnu_inline_attribute_requires_inline : Warning<
|
def warn_gnu_inline_attribute_requires_inline : Warning<
|
||||||
"'gnu_inline' attribute requires function to be marked 'inline',"
|
"'gnu_inline' attribute requires function to be marked 'inline',"
|
||||||
" attribute ignored">;
|
" attribute ignored">;
|
||||||
|
|
|
@ -1559,10 +1559,10 @@ static void HandleObjCOwnershipReturnsAttr(Decl *d, const AttributeList &Attr,
|
||||||
d->addAttr(::new (S.Context) ObjCOwnershipReturnsAttr());
|
d->addAttr(::new (S.Context) ObjCOwnershipReturnsAttr());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void HandleObjCOwnershipParmAttr(Decl *d, const AttributeList &Attr,
|
static void HandleObjCOwnershipAttr(Decl *d, const AttributeList &Attr,
|
||||||
Sema &S) {
|
Sema &S, bool attachToMethodDecl = false) {
|
||||||
|
|
||||||
if (!isa<ParmVarDecl>(d)) {
|
if (!isa<ParmVarDecl>(d) && (!attachToMethodDecl || !isa<ObjCMethodDecl>(d))){
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|
||||||
switch (Attr.getKind()) {
|
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
|
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) << name
|
||||||
<< 4 /* parameter */;
|
<< (attachToMethodDecl ? 5 /* parameter or method decl */
|
||||||
|
: 4 /* parameter */);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1643,10 +1644,11 @@ static void ProcessDeclAttribute(Decl *D, const AttributeList &Attr, Sema &S) {
|
||||||
// Checker-specific.
|
// Checker-specific.
|
||||||
case AttributeList::AT_objc_ownership_cfrelease:
|
case AttributeList::AT_objc_ownership_cfrelease:
|
||||||
case AttributeList::AT_objc_ownership_cfretain:
|
case AttributeList::AT_objc_ownership_cfretain:
|
||||||
|
HandleObjCOwnershipAttr(D, Attr, S); break;
|
||||||
case AttributeList::AT_objc_ownership_make_collectable:
|
case AttributeList::AT_objc_ownership_make_collectable:
|
||||||
case AttributeList::AT_objc_ownership_release:
|
case AttributeList::AT_objc_ownership_release:
|
||||||
case AttributeList::AT_objc_ownership_retain:
|
case AttributeList::AT_objc_ownership_retain:
|
||||||
HandleObjCOwnershipParmAttr(D, Attr, S); break;
|
HandleObjCOwnershipAttr(D, Attr, S, true); break;
|
||||||
case AttributeList::AT_objc_ownership_returns:
|
case AttributeList::AT_objc_ownership_returns:
|
||||||
HandleObjCOwnershipReturnsAttr(D, Attr, S); break;
|
HandleObjCOwnershipReturnsAttr(D, Attr, S); break;
|
||||||
|
|
||||||
|
|
|
@ -440,6 +440,9 @@ void rdar6704930(unsigned char *s, unsigned int length) {
|
||||||
- (void) myCFRetain:(id)__attribute__((objc_ownership_cfretain))obj;
|
- (void) myCFRetain:(id)__attribute__((objc_ownership_cfretain))obj;
|
||||||
- (void) myRelease:(id)__attribute__((objc_ownership_release))obj;
|
- (void) myRelease:(id)__attribute__((objc_ownership_release))obj;
|
||||||
- (void) myCFRelease:(id)__attribute__((objc_ownership_cfrelease))obj;
|
- (void) myCFRelease:(id)__attribute__((objc_ownership_cfrelease))obj;
|
||||||
|
|
||||||
|
- (void) myRetain __attribute__((objc_ownership_retain));
|
||||||
|
- (void) myRelease __attribute__((objc_ownership_release));
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface TestAttrHelper : NSObject
|
@interface TestAttrHelper : NSObject
|
||||||
|
|
Загрузка…
Ссылка в новой задаче