summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2010-08-17 20:23:12 +0000
committerFariborz Jahanian <fjahanian@apple.com>2010-08-17 20:23:12 +0000
commitb5d59b66c27e2c0016953014fbbbd86b175fd1d6 (patch)
tree9ac980bac2cfaeaa6ab8bff58809834f8bb59af3 /clang/lib
parent1a58ce76463878399bc28d5bebe342d2c3ceef6a (diff)
downloadbcm5719-llvm-b5d59b66c27e2c0016953014fbbbd86b175fd1d6.tar.gz
bcm5719-llvm-b5d59b66c27e2c0016953014fbbbd86b175fd1d6.zip
Patch to add type parameter support for attribute iboutletcollection.
Radar 8308053. llvm-svn: 111275
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/AttrImpl.cpp2
-rw-r--r--clang/lib/Frontend/PCHReaderDecl.cpp5
-rw-r--r--clang/lib/Frontend/PCHWriter.cpp2
-rw-r--r--clang/lib/Sema/SemaDeclAttr.cpp25
4 files changed, 25 insertions, 9 deletions
diff --git a/clang/lib/AST/AttrImpl.cpp b/clang/lib/AST/AttrImpl.cpp
index dcd3c5bc434..994d45cf745 100644
--- a/clang/lib/AST/AttrImpl.cpp
+++ b/clang/lib/AST/AttrImpl.cpp
@@ -163,7 +163,7 @@ Attr *IBOutletAttr::clone(ASTContext &C) const {
}
Attr *IBOutletCollectionAttr::clone(ASTContext &C) const {
- return ::new (C) IBOutletCollectionAttr(D);
+ return ::new (C) IBOutletCollectionAttr(QT);
}
Attr *IBActionAttr::clone(ASTContext &C) const {
diff --git a/clang/lib/Frontend/PCHReaderDecl.cpp b/clang/lib/Frontend/PCHReaderDecl.cpp
index aa5ce7aad6a..a581951da72 100644
--- a/clang/lib/Frontend/PCHReaderDecl.cpp
+++ b/clang/lib/Frontend/PCHReaderDecl.cpp
@@ -1190,9 +1190,8 @@ Attr *PCHReader::ReadAttributes(llvm::BitstreamCursor &DeclsCursor) {
break;
case attr::IBOutletCollection: {
- ObjCInterfaceDecl *D =
- cast_or_null<ObjCInterfaceDecl>(GetDecl(Record[Idx++]));
- New = ::new (*Context) IBOutletCollectionAttr(D);
+ QualType QT = GetType(Record[Idx++]);
+ New = ::new (*Context) IBOutletCollectionAttr(QT);
break;
}
diff --git a/clang/lib/Frontend/PCHWriter.cpp b/clang/lib/Frontend/PCHWriter.cpp
index 76fd5528dc8..ac30fd34ccc 100644
--- a/clang/lib/Frontend/PCHWriter.cpp
+++ b/clang/lib/Frontend/PCHWriter.cpp
@@ -2051,7 +2051,7 @@ void PCHWriter::WriteAttributeRecord(const Attr *Attr) {
case attr::IBOutletCollection: {
const IBOutletCollectionAttr *ICA = cast<IBOutletCollectionAttr>(Attr);
- AddDeclRef(ICA->getClass(), Record);
+ AddTypeRef(ICA->getType(), Record);
break;
}
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index a234a737951..1e3405768ae 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -263,7 +263,7 @@ static void HandleIBOutletCollection(Decl *d, const AttributeList &Attr,
Sema &S) {
// The iboutletcollection attribute can have zero or one arguments.
- if (Attr.getNumArgs() > 1) {
+ if (Attr.getParameterName() && Attr.getNumArgs() > 0) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 1;
return;
}
@@ -274,9 +274,26 @@ static void HandleIBOutletCollection(Decl *d, const AttributeList &Attr,
S.Diag(Attr.getLoc(), diag::err_attribute_iboutlet) << Attr.getName();
return;
}
-
- // FIXME: Eventually accept the type argument.
- d->addAttr(::new (S.Context) IBOutletCollectionAttr());
+ IdentifierInfo *II = Attr.getParameterName();
+ if (!II)
+ II = &S.Context.Idents.get("id");
+ Sema::TypeTy *TypeRep = S.getTypeName(*II, Attr.getLoc(),
+ S.getScopeForContext(d->getDeclContext()->getParent()));
+ if (!TypeRep) {
+ S.Diag(Attr.getLoc(), diag::err_iboutletcollection_type) << II;
+ return;
+ }
+ QualType QT(QualType::getFromOpaquePtr(TypeRep));
+ // Diagnose use of non-object type in iboutletcollection attribute.
+ // FIXME. Gnu attribute extension ignores use of builtin types in
+ // attributes. So, __attribute__((iboutletcollection(char))) will be
+ // treated as __attribute__((iboutletcollection())).
+ if (!QT->isObjCIdType() && !QT->isObjCClassType() &&
+ !QT->isObjCObjectType()) {
+ S.Diag(Attr.getLoc(), diag::err_iboutletcollection_type) << II;
+ return;
+ }
+ d->addAttr(::new (S.Context) IBOutletCollectionAttr(QT));
}
static void HandleNonNullAttr(Decl *d, const AttributeList &Attr, Sema &S) {
OpenPOWER on IntegriCloud