From e60bbaeb9b94ff58f8fefe663627db5a34bce22b Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Sat, 24 Feb 2018 17:37:37 +0000 Subject: [PATCH] Add a C++11 and C2x spelling for the objc_bridge_related attribute in the clang vendor namespace. This attribute has custom parsing rules that previously prevented it from being supported with square bracket notation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326038 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/Attr.td | 4 +--- lib/Parse/ParseDecl.cpp | 4 ++++ test/Sema/attr-objc-bridge-related.m | 7 +++++++ 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 test/Sema/attr-objc-bridge-related.m diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td index 1efede7f40..339fbb8120 100644 --- a/include/clang/Basic/Attr.td +++ b/include/clang/Basic/Attr.td @@ -1503,9 +1503,7 @@ def ObjCBridgeMutable : InheritableAttr { } def ObjCBridgeRelated : InheritableAttr { - // TODO: this attribute does not have a [[]] spelling because it requires - // custom parsing support. - let Spellings = [GNU<"objc_bridge_related">]; + let Spellings = [Clang<"objc_bridge_related", 1>]; let Subjects = SubjectList<[Record], ErrorDiag>; let Args = [IdentifierArgument<"RelatedClass">, IdentifierArgument<"ClassMethod", 1>, diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index ade822bc47..d79ca8a0b2 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -416,6 +416,10 @@ unsigned Parser::ParseClangAttributeArgs( ParseAvailabilityAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName, ScopeLoc, Syntax); break; + case AttributeList::AT_ObjCBridgeRelated: + ParseObjCBridgeRelatedAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc, + ScopeName, ScopeLoc, Syntax); + break; } return Attrs.getList() ? Attrs.getList()->getNumArgs() : 0; } diff --git a/test/Sema/attr-objc-bridge-related.m b/test/Sema/attr-objc-bridge-related.m new file mode 100644 index 0000000000..bf059ba018 --- /dev/null +++ b/test/Sema/attr-objc-bridge-related.m @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -verify -fsyntax-only -fdouble-square-bracket-attributes %s + +struct [[clang::objc_bridge_related(NSParagraphStyle,,)]] TestBridgedRef; + +struct [[clang::objc_bridge_related(NSColor,colorWithCGColor:,CGColor)]] CGColorRefOk; +struct [[clang::objc_bridge_related(,colorWithCGColor:,CGColor)]] CGColorRef1NotOk; // expected-error {{expected a related ObjectiveC class name, e.g., 'NSColor'}} +struct [[clang::objc_bridge_related(NSColor,colorWithCGColor::,CGColor)]] CGColorRef3NotOk; // expected-error {{expected a class method selector with single argument, e.g., 'colorWithCGColor:'}} -- 2.40.0