Add the @exclusivity attribute.

The `@exclusivity(unchecked)` attribute can be used on variables to selectively disable exclusivity checking.
For completeness, also the `@exclusivity(checked)` variant is supported: it turns on exclusivity checking for specific variables if exclusivity enforcement is disabled by the command line option.

This new attribute is a missing implementation part of SE-0176 (https://github.com/apple/swift-evolution/blob/main/proposals/0176-enforce-exclusive-access-to-memory.md).

rdar://31121356
This commit is contained in:
Erik Eckstein
2022-01-24 21:08:18 +01:00
parent 83484f8516
commit 5fd941eb67
14 changed files with 215 additions and 2 deletions

View File

@@ -56,7 +56,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0;
/// describe what change you made. The content of this comment isn't important;
/// it just ensures a conflict if two people change the module format.
/// Don't worry about adhering to the 80-column limit for this line.
const uint16_t SWIFTMODULE_VERSION_MINOR = 660; // remove nested archetypes
const uint16_t SWIFTMODULE_VERSION_MINOR = 661; // @exclusivity attribute
/// A standard hash seed used for all string hashes in a serialized module.
///
@@ -1923,6 +1923,11 @@ namespace decls_block {
BCFixed<2> // optimize value
>;
using ExclusivityDeclAttrLayout = BCRecordLayout<
Optimize_DECL_ATTR,
BCFixed<2> // exclusivity mode
>;
using AvailableDeclAttrLayout = BCRecordLayout<
Available_DECL_ATTR,
BCFixed<1>, // implicit flag