Allow imported types to add a Sendable conformance

...by using `__attribute__((swift_attr("@Sendable")))`. `@_nonSendable` will "beat" `@Sendable`, while `@_nonSendable(_assumed)` will not.

This commit also checks if `SwiftAttr` supports `#pragma clang attribute` and, if it does, defines `__SWIFT_ATTR_SUPPORTS_SENDABLE_DECLS` in imported headers so they know they can apply these attributes in an auditing style.
This commit is contained in:
Becca Royal-Gordon
2021-11-12 23:13:29 -08:00
parent de768e8fda
commit 7549278314
9 changed files with 124 additions and 7 deletions

View File

@@ -1,6 +1,9 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-ide-test(mock-sdk: %clang-importer-sdk) -print-module -print-interface -source-filename %s -module-to-print=ObjCConcurrency -function-definitions=false | %FileCheck %s
// RUN: %target-swift-ide-test(mock-sdk: %clang-importer-sdk) -print-module -print-interface -source-filename %s -module-to-print=ObjCConcurrency -function-definitions=false > %t/ObjCConcurrency.printed.txt
// RUN: %FileCheck -input-file %t/ObjCConcurrency.printed.txt %s
// RUN: %FileCheck -check-prefix NEGATIVE -input-file %t/ObjCConcurrency.printed.txt %s
// REQUIRES: objc_interop
// REQUIRES: concurrency
@@ -12,3 +15,18 @@ import _Concurrency
// CHECK-NOT: @available
// CHECK: func doSomethingSlow(_ operation: String, completionHandler handler: @escaping (Int) -> Void)
// CHECK: func doSomethingSlow(_ operation: String) async -> Int
// NEGATIVE-NOT: @Sendable{{.+}}class
// NEGATIVE-NOT: @_nonSendable{{.+}}class
// CHECK-LABEL: class SendableClass :
// CHECK-SAME: @unchecked Sendable
// CHECK-LABEL: class NonSendableClass
// CHECK-LABEL: class AuditedSendable :
// CHECK-SAME: @unchecked Sendable
// CHECK-LABEL: class AuditedNonSendable
// CHECK-LABEL: class AuditedBoth