diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2013-11-21 20:50:32 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2013-11-21 20:50:32 +0000 |
commit | 87c7791bb7444d9485964052abd6dc96ff2db0eb (patch) | |
tree | 1aba7e4e498a67f9bffac967bb22b17858b8f62e /clang/lib/Sema/SemaDeclAttr.cpp | |
parent | c680226fbfca2dd74f214359da15e3cb1fb0b95d (diff) | |
download | bcm5719-llvm-87c7791bb7444d9485964052abd6dc96ff2db0eb.tar.gz bcm5719-llvm-87c7791bb7444d9485964052abd6dc96ff2db0eb.zip |
ObjectiveC. Implement attribute 'objc_bridge_mutable'
whose semantic is currently identical to objc_bridge,
but their differences may manifest down the road with
further enhancements. // rdar://15498044
llvm-svn: 195376
Diffstat (limited to 'clang/lib/Sema/SemaDeclAttr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 38bffa2f99e..8b3d738c60b 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -4362,6 +4362,30 @@ static void handleObjCBridgeAttr(Sema &S, Scope *Sc, Decl *D, Attr.getAttributeSpellingListIndex())); } +static void handleObjCBridgeMutableAttr(Sema &S, Scope *Sc, Decl *D, + const AttributeList &Attr) { + if (!isa<RecordDecl>(D)) { + S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type) + << Attr.getName() + << (S.getLangOpts().CPlusPlus ? ExpectedStructOrUnionOrClass + : ExpectedStructOrUnion); + return; + } + + IdentifierLoc *Parm = 0; + if (Attr.getNumArgs() == 1) + Parm = Attr.isArgIdent(0) ? Attr.getArgAsIdent(0) : 0; + + if (!Parm) { + S.Diag(D->getLocStart(), diag::err_objc_attr_not_id) << Attr.getName() << 0; + return; + } + + D->addAttr(::new (S.Context) + ObjCBridgeMutableAttr(Attr.getRange(), S.Context, Parm->Ident, + Attr.getAttributeSpellingListIndex())); +} + static void handleObjCOwnershipAttr(Sema &S, Decl *D, const AttributeList &Attr) { if (hasDeclarator(D)) return; @@ -4651,6 +4675,9 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, case AttributeList::AT_ObjCBridge: handleObjCBridgeAttr(S, scope, D, Attr); break; + + case AttributeList::AT_ObjCBridgeMutable: + handleObjCBridgeMutableAttr(S, scope, D, Attr); break; case AttributeList::AT_CFAuditedTransfer: case AttributeList::AT_CFUnknownTransfer: |