r326038 - Add a C++11 and C2x spelling for the objc_bridge_related attribute in the clang vendor namespace.

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 24 09:37:37 PST 2018


Author: aaronballman
Date: Sat Feb 24 09:37:37 2018
New Revision: 326038

URL: http://llvm.org/viewvc/llvm-project?rev=326038&view=rev
Log:
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.

Added:
    cfe/trunk/test/Sema/attr-objc-bridge-related.m
Modified:
    cfe/trunk/include/clang/Basic/Attr.td
    cfe/trunk/lib/Parse/ParseDecl.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=326038&r1=326037&r2=326038&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Sat Feb 24 09:37:37 2018
@@ -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>,

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=326038&r1=326037&r2=326038&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Sat Feb 24 09:37:37 2018
@@ -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;
 }

Added: cfe/trunk/test/Sema/attr-objc-bridge-related.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-objc-bridge-related.m?rev=326038&view=auto
==============================================================================
--- cfe/trunk/test/Sema/attr-objc-bridge-related.m (added)
+++ cfe/trunk/test/Sema/attr-objc-bridge-related.m Sat Feb 24 09:37:37 2018
@@ -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:'}}




More information about the cfe-commits mailing list