[cfe-commits] r96447 - in /cfe/trunk: include/clang/AST/Attr.h include/clang/Basic/DiagnosticSemaKinds.td include/clang/Parse/AttributeList.h lib/AST/AttrImpl.cpp lib/Frontend/PCHReaderDecl.cpp lib/Frontend/PCHWriter.cpp lib/Parse/AttributeList.cpp lib/Sema/SemaDeclAttr.cpp
Ted Kremenek
kremenek at apple.com
Tue Feb 16 18:37:45 PST 2010
Author: kremenek
Date: Tue Feb 16 20:37:45 2010
New Revision: 96447
URL: http://llvm.org/viewvc/llvm-project?rev=96447&view=rev
Log:
Add IBAction attribute to keep the IBOutlet attribute company.
Modified:
cfe/trunk/include/clang/AST/Attr.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Parse/AttributeList.h
cfe/trunk/lib/AST/AttrImpl.cpp
cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
cfe/trunk/lib/Frontend/PCHWriter.cpp
cfe/trunk/lib/Parse/AttributeList.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
Modified: cfe/trunk/include/clang/AST/Attr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=96447&r1=96446&r2=96447&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Attr.h (original)
+++ cfe/trunk/include/clang/AST/Attr.h Tue Feb 16 20:37:45 2010
@@ -62,7 +62,8 @@
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,
@@ -326,6 +327,19 @@
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);
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=96447&r1=96446&r2=96447&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Feb 16 20:37:45 2010
@@ -846,8 +846,8 @@
// 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">;
Modified: cfe/trunk/include/clang/Parse/AttributeList.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/AttributeList.h?rev=96447&r1=96446&r2=96447&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/AttributeList.h (original)
+++ cfe/trunk/include/clang/Parse/AttributeList.h Tue Feb 16 20:37:45 2010
@@ -51,7 +51,8 @@
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,
Modified: cfe/trunk/lib/AST/AttrImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/AttrImpl.cpp?rev=96447&r1=96446&r2=96447&view=diff
==============================================================================
--- cfe/trunk/lib/AST/AttrImpl.cpp (original)
+++ cfe/trunk/lib/AST/AttrImpl.cpp Tue Feb 16 20:37:45 2010
@@ -139,6 +139,10 @@
return ::new (C) IBOutletAttr;
}
+Attr *IBActionAttr::clone(ASTContext &C) const {
+ return ::new (C) IBActionAttr;
+}
+
Attr *GNUInlineAttr::clone(ASTContext &C) const {
return ::new (C) GNUInlineAttr;
}
Modified: cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReaderDecl.cpp?rev=96447&r1=96446&r2=96447&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReaderDecl.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReaderDecl.cpp Tue Feb 16 20:37:45 2010
@@ -517,6 +517,10 @@
SIMPLE_ATTR(GNUInline);
SIMPLE_ATTR(Hiding);
+ case Attr::IBActionKind:
+ New = ::new (*Context) IBActionAttr();
+ break;
+
case Attr::IBOutletKind:
New = ::new (*Context) IBOutletAttr();
break;
Modified: cfe/trunk/lib/Frontend/PCHWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriter.cpp?rev=96447&r1=96446&r2=96447&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriter.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriter.cpp Tue Feb 16 20:37:45 2010
@@ -1853,6 +1853,7 @@
case Attr::GNUInline:
case Attr::Hiding:
case Attr::IBOutletKind:
+ case Attr::IBActionKind:
case Attr::Malloc:
case Attr::NoDebug:
case Attr::NoReturn:
Modified: cfe/trunk/lib/Parse/AttributeList.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/AttributeList.cpp?rev=96447&r1=96446&r2=96447&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/AttributeList.cpp (original)
+++ cfe/trunk/lib/Parse/AttributeList.cpp Tue Feb 16 20:37:45 2010
@@ -82,6 +82,7 @@
.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)
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=96447&r1=96446&r2=96447&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue Feb 16 20:37:45 2010
@@ -225,19 +225,29 @@
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) {
@@ -1729,7 +1739,8 @@
// 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:
More information about the cfe-commits
mailing list