summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclAttr.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-12-03 21:11:25 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-12-03 21:11:25 +0000
commitd1438b446e7463db7207720321e0bdf5fc6654ea (patch)
treea69d6f1a96b39433a9cf20dde83c1753e7c7b877 /clang/lib/Sema/SemaDeclAttr.cpp
parentfd9acf6a485fcbc0da3f00b4e213c715c3617086 (diff)
downloadbcm5719-llvm-d1438b446e7463db7207720321e0bdf5fc6654ea.tar.gz
bcm5719-llvm-d1438b446e7463db7207720321e0bdf5fc6654ea.zip
[objc] Introduce attribute 'objc_designated_initializer'.
It only applies to methods of init family in an interface declaration. llvm-svn: 196314
Diffstat (limited to 'clang/lib/Sema/SemaDeclAttr.cpp')
-rw-r--r--clang/lib/Sema/SemaDeclAttr.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 24f9f5fd252..b732fccacf8 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -3713,6 +3713,28 @@ static void handleObjCBridgeMutableAttr(Sema &S, Scope *Sc, Decl *D,
Attr.getAttributeSpellingListIndex()));
}
+static void handleObjCDesignatedInitializer(Sema &S, Decl *D,
+ const AttributeList &Attr) {
+ SourceLocation Loc = Attr.getLoc();
+ ObjCMethodDecl *Method = cast<ObjCMethodDecl>(D);
+
+ if (Method->getMethodFamily() != OMF_init) {
+ S.Diag(D->getLocStart(), diag::err_attr_objc_designated_not_init_family)
+ << SourceRange(Loc, Loc);
+ return;
+ }
+ DeclContext *DC = Method->getDeclContext();
+ if (!isa<ObjCInterfaceDecl>(DC)) {
+ S.Diag(D->getLocStart(), diag::err_attr_objc_designated_not_interface)
+ << SourceRange(Loc, Loc);
+ return;
+ }
+
+ Method->addAttr(::new (S.Context)
+ ObjCDesignatedInitializerAttr(Attr.getRange(), S.Context,
+ Attr.getAttributeSpellingListIndex()));
+}
+
static void handleObjCOwnershipAttr(Sema &S, Decl *D,
const AttributeList &Attr) {
if (hasDeclarator(D)) return;
@@ -3963,6 +3985,9 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D,
case AttributeList::AT_ObjCBridgeMutable:
handleObjCBridgeMutableAttr(S, scope, D, Attr); break;
+ case AttributeList::AT_ObjCDesignatedInitializer:
+ handleObjCDesignatedInitializer(S, D, Attr); break;
+
case AttributeList::AT_CFAuditedTransfer:
handleCFAuditedTransferAttr(S, D, Attr); break;
case AttributeList::AT_CFUnknownTransfer:
OpenPOWER on IntegriCloud