forked from OSchip/llvm-project
Change the behavior of ibaction attributes to be attached to methods, not ivars.
llvm-svn: 96562
This commit is contained in:
parent
186ad8098e
commit
1f672829fb
|
@ -846,9 +846,11 @@ def err_attribute_regparm_invalid_number : Error<
|
|||
|
||||
|
||||
// Clang-Specific Attributes
|
||||
def err_attribute_ib : Error<
|
||||
"%0 attribute can only be applied to instance variables or "
|
||||
def err_attribute_iboutlet : Error<
|
||||
"iboutlet attribute can only be applied to instance variables or "
|
||||
"properties">;
|
||||
def err_attribute_ibaction: Error<
|
||||
"ibaction attribute can only be applied to Objective-C instance methods">;
|
||||
def err_attribute_overloadable_not_function : Error<
|
||||
"'overloadable' attribute can only be applied to a function">;
|
||||
def err_attribute_overloadable_missing : Error<
|
||||
|
|
|
@ -225,29 +225,38 @@ static void HandlePackedAttr(Decl *d, const AttributeList &Attr, Sema &S) {
|
|||
S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
|
||||
}
|
||||
|
||||
static void HandleIBAttr(Decl *d, const AttributeList &Attr, Sema &S) {
|
||||
static void HandleIBAction(Decl *d, const AttributeList &Attr, Sema &S) {
|
||||
// check the attribute arguments.
|
||||
if (Attr.getNumArgs() > 0) {
|
||||
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// The IBOutlet/IBAction attributes only apply to instance variables of
|
||||
// The IBAction attributes only apply to instance methods.
|
||||
if (ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(d))
|
||||
if (MD->isInstanceMethod()) {
|
||||
d->addAttr(::new (S.Context) IBActionAttr());
|
||||
return;
|
||||
}
|
||||
|
||||
S.Diag(Attr.getLoc(), diag::err_attribute_ibaction) << Attr.getName();
|
||||
}
|
||||
|
||||
static void HandleIBOutlet(Decl *d, const AttributeList &Attr, Sema &S) {
|
||||
// check the attribute arguments.
|
||||
if (Attr.getNumArgs() > 0) {
|
||||
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// The IBOutlet attributes only apply to instance variables of
|
||||
// Objective-C classes.
|
||||
if (isa<ObjCIvarDecl>(d) || isa<ObjCPropertyDecl>(d)) {
|
||||
switch (Attr.getKind()) {
|
||||
case AttributeList::AT_IBAction:
|
||||
d->addAttr(::new (S.Context) IBActionAttr());
|
||||
break;
|
||||
case AttributeList::AT_IBOutlet:
|
||||
d->addAttr(::new (S.Context) IBOutletAttr());
|
||||
break;
|
||||
default:
|
||||
llvm_unreachable("Invalid IB attribute");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
S.Diag(Attr.getLoc(), diag::err_attribute_ib) << Attr.getName();
|
||||
|
||||
S.Diag(Attr.getLoc(), diag::err_attribute_iboutlet) << Attr.getName();
|
||||
}
|
||||
|
||||
static void HandleNonNullAttr(Decl *d, const AttributeList &Attr, Sema &S) {
|
||||
|
@ -1745,8 +1754,8 @@ static void ProcessDeclAttribute(Scope *scope, Decl *D,
|
|||
// FIXME: Try to deal with other __declspec attributes!
|
||||
return;
|
||||
switch (Attr.getKind()) {
|
||||
case AttributeList::AT_IBAction:
|
||||
case AttributeList::AT_IBOutlet: HandleIBAttr (D, Attr, S); break;
|
||||
case AttributeList::AT_IBAction: HandleIBAction(D, Attr, S); break;
|
||||
case AttributeList::AT_IBOutlet: HandleIBOutlet(D, Attr, S); break;
|
||||
case AttributeList::AT_address_space:
|
||||
case AttributeList::AT_objc_gc:
|
||||
case AttributeList::AT_vector_size:
|
||||
|
|
Loading…
Reference in New Issue