[PATCH] D87395: Sema: add support for `__attribute__((__swift_objc_members__))`
Saleem Abdulrasool via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 11 10:48:41 PDT 2020
compnerd updated this revision to Diff 291269.
compnerd added a comment.
address feedback from @aaron.ballman and @gribozavr2
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87395/new/
https://reviews.llvm.org/D87395
Files:
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/Misc/pragma-attribute-supported-attributes-list.test
clang/test/SemaObjC/attr-swift_objc_members.m
Index: clang/test/SemaObjC/attr-swift_objc_members.m
===================================================================
--- /dev/null
+++ clang/test/SemaObjC/attr-swift_objc_members.m
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+
+#if !__has_attribute(swift_objc_members)
+#error cannot verify presence of swift_objc_members attribute
+#endif
+
+__attribute__((__swift_objc_members__))
+__attribute__((__objc_root_class__))
+ at interface I
+ at end
+
+__attribute__((swift_objc_members))
+ at protocol P
+ at end
+// expected-error at -3 {{'swift_objc_members' attribute only applies to Objective-C interfaces}}
+
+__attribute__((swift_objc_members))
+extern void f(void);
+// expected-error at -2 {{'swift_objc_members' attribute only applies to Objective-C interfaces}}
+
+// expected-error at +1 {{'__swift_objc_members__' attribute takes no arguments}}
+__attribute__((__swift_objc_members__("J")))
+ at interface J
+ at end
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===================================================================
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -150,6 +150,7 @@
// CHECK-NEXT: SwiftError (SubjectMatchRule_function, SubjectMatchRule_objc_method)
// CHECK-NEXT: SwiftErrorResult (SubjectMatchRule_variable_is_parameter)
// CHECK-NEXT: SwiftIndirectResult (SubjectMatchRule_variable_is_parameter)
+// CHECK-NEXT: SwiftObjCMembers (SubjectMatchRule_objc_interface)
// CHECK-NEXT: TLSModel (SubjectMatchRule_variable_is_thread_local)
// CHECK-NEXT: Target (SubjectMatchRule_function)
// CHECK-NEXT: TestTypestate (SubjectMatchRule_function_is_member)
Index: clang/lib/Sema/SemaDeclAttr.cpp
===================================================================
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -7536,6 +7536,9 @@
case ParsedAttr::AT_SwiftError:
handleSwiftError(S, D, AL);
break;
+ case ParsedAttr::AT_SwiftObjCMembers:
+ handleSimpleAttribute<SwiftObjCMembersAttr>(S, D, AL);
+ break;
// XRay attributes.
case ParsedAttr::AT_XRayLogArgs:
Index: clang/include/clang/Basic/AttrDocs.td
===================================================================
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -3476,6 +3476,16 @@
}];
}
+def SwiftObjCMembersDocs : Documentation {
+ let Category = SwiftDocs;
+ let Heading = "swift_objc_members";
+ let Content = [{
+This attribute indicates that Swift subclasses and members of Swift extensions
+of this class will be implicitly marked with the ``@objcMembers`` Swift
+attribute, exposing them back to Objective-C.
+ }];
+}
+
def SwiftErrorDocs : Documentation {
let Category = SwiftDocs;
let Heading = "swift_error";
Index: clang/include/clang/Basic/Attr.td
===================================================================
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -2130,6 +2130,12 @@
let ASTNode = 0;
}
+def SwiftObjCMembers : Attr {
+ let Spellings = [GNU<"swift_objc_members">];
+ let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
+ let Documentation = [SwiftObjCMembersDocs];
+}
+
def SwiftError : InheritableAttr {
let Spellings = [GNU<"swift_error">];
let Args = [
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87395.291269.patch
Type: text/x-patch
Size: 3354 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200911/0697025b/attachment-0001.bin>
More information about the cfe-commits
mailing list