beccadax created this revision. beccadax added a reviewer: arphaman. beccadax added a project: clang. Herald added a reviewer: aaron.ballman. Herald added a subscriber: jdoerfert. beccadax requested review of this revision. Herald added a subscriber: cfe-commits.
This change does what it says on the tin: it allows SwiftAttr to be used with #pragma clang attribute push to add Swift attributes to large regions of header files. We plan to use this to annotate headers with concurrency information. rdar://83499885 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D112773 Files: clang/include/clang/Basic/Attr.td clang/test/AST/attr-swift_attr.m clang/test/Misc/pragma-attribute-supported-attributes-list.test 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 @@ -161,6 +161,7 @@ // CHECK-NEXT: SwiftAsyncContext (SubjectMatchRule_variable_is_parameter) // CHECK-NEXT: SwiftAsyncError (SubjectMatchRule_function, SubjectMatchRule_objc_method) // CHECK-NEXT: SwiftAsyncName (SubjectMatchRule_objc_method, SubjectMatchRule_function) +// CHECK-NEXT: SwiftAttr () // CHECK-NEXT: SwiftBridgedTypedef (SubjectMatchRule_type_alias) // CHECK-NEXT: SwiftContext (SubjectMatchRule_variable_is_parameter) // CHECK-NEXT: SwiftError (SubjectMatchRule_function, SubjectMatchRule_objc_method) Index: clang/test/AST/attr-swift_attr.m =================================================================== --- clang/test/AST/attr-swift_attr.m +++ clang/test/AST/attr-swift_attr.m @@ -4,5 +4,13 @@ @interface View @end -// CHECK: InterfaceDecl {{.*}} View +// CHECK-LABEL: InterfaceDecl {{.*}} View // CHECK-NEXT: SwiftAttrAttr {{.*}} "@actor" + +#pragma clang attribute push(__attribute__((swift_attr("@sendable"))), apply_to=objc_interface) +@interface Contact +@end +#pragma clang attribute pop + +// CHECK-LABEL: InterfaceDecl {{.*}} Contact +// CHECK-NEXT: SwiftAttrAttr {{.*}} "@sendable" Index: clang/include/clang/Basic/Attr.td =================================================================== --- clang/include/clang/Basic/Attr.td +++ clang/include/clang/Basic/Attr.td @@ -2347,6 +2347,7 @@ let Spellings = [GNU<"swift_attr">]; let Args = [StringArgument<"Attribute">]; let Documentation = [SwiftAttrDocs]; + let PragmaAttributeSupport = 1; } def SwiftBridge : InheritableAttr {
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 @@ -161,6 +161,7 @@ // CHECK-NEXT: SwiftAsyncContext (SubjectMatchRule_variable_is_parameter) // CHECK-NEXT: SwiftAsyncError (SubjectMatchRule_function, SubjectMatchRule_objc_method) // CHECK-NEXT: SwiftAsyncName (SubjectMatchRule_objc_method, SubjectMatchRule_function) +// CHECK-NEXT: SwiftAttr () // CHECK-NEXT: SwiftBridgedTypedef (SubjectMatchRule_type_alias) // CHECK-NEXT: SwiftContext (SubjectMatchRule_variable_is_parameter) // CHECK-NEXT: SwiftError (SubjectMatchRule_function, SubjectMatchRule_objc_method) Index: clang/test/AST/attr-swift_attr.m =================================================================== --- clang/test/AST/attr-swift_attr.m +++ clang/test/AST/attr-swift_attr.m @@ -4,5 +4,13 @@ @interface View @end -// CHECK: InterfaceDecl {{.*}} View +// CHECK-LABEL: InterfaceDecl {{.*}} View // CHECK-NEXT: SwiftAttrAttr {{.*}} "@actor" + +#pragma clang attribute push(__attribute__((swift_attr("@sendable"))), apply_to=objc_interface) +@interface Contact +@end +#pragma clang attribute pop + +// CHECK-LABEL: InterfaceDecl {{.*}} Contact +// CHECK-NEXT: SwiftAttrAttr {{.*}} "@sendable" Index: clang/include/clang/Basic/Attr.td =================================================================== --- clang/include/clang/Basic/Attr.td +++ clang/include/clang/Basic/Attr.td @@ -2347,6 +2347,7 @@ let Spellings = [GNU<"swift_attr">]; let Args = [StringArgument<"Attribute">]; let Documentation = [SwiftAttrDocs]; + let PragmaAttributeSupport = 1; } def SwiftBridge : InheritableAttr {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits