FormatArg,
GNUInline,
Hiding,
- IBOutletKind, // Clang-specific. Use "Kind" suffix to not conflict with
+ IBOutletKind, // Clang-specific. Use "Kind" suffix to not conflict w/ macro.
+ IBActionKind, // Clang-specific. Use "Kind" suffix to not conflict w/ macro.
Malloc,
NoDebug,
NoInline,
static bool classof(const IBOutletAttr *A) { return true; }
};
+class IBActionAttr : public Attr {
+public:
+ IBActionAttr() : Attr(IBActionKind) {}
+
+ virtual Attr *clone(ASTContext &C) const;
+
+ // Implement isa/cast/dyncast/etc.
+ static bool classof(const Attr *A) {
+ return A->getKind() == IBActionKind;
+ }
+ static bool classof(const IBActionAttr *A) { return true; }
+};
+
DEF_SIMPLE_ATTR(Malloc);
DEF_SIMPLE_ATTR(NoReturn);
DEF_SIMPLE_ATTR(AnalyzerNoReturn);
// Clang-Specific Attributes
-def err_attribute_iboutlet : Error<
- "'iboutlet' attribute can only be applied to instance variables or "
+def err_attribute_ib : Error<
+ "%0 attribute can only be applied to instance variables or "
"properties">;
def err_attribute_overloadable_not_function : Error<
"'overloadable' attribute can only be applied to a function">;
AttributeList *Next, bool declspec = false, bool cxx0x = false);
~AttributeList();
- enum Kind { // Please keep this list alphabetized.
+ enum Kind { // Please keep this list alphabetized.
+ AT_IBAction, // Clang-specific.
AT_IBOutlet, // Clang-specific.
AT_address_space,
AT_alias,
return ::new (C) IBOutletAttr;
}
+Attr *IBActionAttr::clone(ASTContext &C) const {
+ return ::new (C) IBActionAttr;
+}
+
Attr *GNUInlineAttr::clone(ASTContext &C) const {
return ::new (C) GNUInlineAttr;
}
SIMPLE_ATTR(GNUInline);
SIMPLE_ATTR(Hiding);
+ case Attr::IBActionKind:
+ New = ::new (*Context) IBActionAttr();
+ break;
+
case Attr::IBOutletKind:
New = ::new (*Context) IBOutletAttr();
break;
case Attr::GNUInline:
case Attr::Hiding:
case Attr::IBOutletKind:
+ case Attr::IBActionKind:
case Attr::Malloc:
case Attr::NoDebug:
case Attr::NoReturn:
.Case("stdcall", AT_stdcall)
.Case("annotate", AT_annotate)
.Case("fastcall", AT_fastcall)
+ .Case("ibaction", AT_IBAction)
.Case("iboutlet", AT_IBOutlet)
.Case("noreturn", AT_noreturn)
.Case("noinline", AT_noinline)
S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
}
-static void HandleIBOutletAttr(Decl *d, const AttributeList &Attr, Sema &S) {
+static void HandleIBAttr(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 attribute only applies to instance variables of Objective-C
- // classes.
- if (isa<ObjCIvarDecl>(d) || isa<ObjCPropertyDecl>(d))
- d->addAttr(::new (S.Context) IBOutletAttr());
+ // The IBOutlet/IBAction 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");
+ }
+ }
else
- S.Diag(Attr.getLoc(), diag::err_attribute_iboutlet);
+ S.Diag(Attr.getLoc(), diag::err_attribute_ib) << Attr.getName();
}
static void HandleNonNullAttr(Decl *d, const AttributeList &Attr, Sema &S) {
// FIXME: Try to deal with other __declspec attributes!
return;
switch (Attr.getKind()) {
- case AttributeList::AT_IBOutlet: HandleIBOutletAttr (D, Attr, S); break;
+ case AttributeList::AT_IBAction:
+ case AttributeList::AT_IBOutlet: HandleIBAttr (D, Attr, S); break;
case AttributeList::AT_address_space:
case AttributeList::AT_objc_gc:
case AttributeList::AT_vector_size: