Skip to content

Commit 6079452

Browse files
authored
Re-alphabetize underscored attributes reference (#60558)
1 parent 1b83307 commit 6079452

File tree

1 file changed

+48
-51
lines changed

1 file changed

+48
-51
lines changed

docs/ReferenceGuides/UnderscoredAttributes.md

+48-51
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ the Swift ABI. This attribute is intended for the SIMD types in the standard
2323
library which use it to increase the alignment of their internal storage to at
2424
least 16 bytes.
2525

26+
## `@_alwaysEmitConformanceMetadata`
27+
28+
Forces conformances of the attributed protocol to always have their Type Metadata get emitted into the binary and prevents it from being optimized away or stripped by the linker.
29+
2630
## `@_alwaysEmitIntoClient`
2731

2832
Forces the body of a function to be emitted into client code.
@@ -39,6 +43,14 @@ Most notably, default argument expressions are implicitly
3943
`@_alwaysEmitIntoClient`, which means that adding a default argument to a
4044
function which did not have one previously does not break ABI.
4145

46+
## `@_assemblyVision`
47+
48+
Forces emission of assembly vision remarks for a function or method, showing
49+
where various runtime calls and performance impacting hazards are in the code
50+
at source level after optimization.
51+
52+
Adding this attribute to a type leads to remarks being emitted for all methods.
53+
4254
## `@_backDeploy(before: ...)`
4355

4456
Causes the body of a function to be emitted into the module interface to be
@@ -53,14 +65,6 @@ client is called instead.
5365
For more details, see the [pitch thread](https://forums.swift.org/t/pitch-function-back-deployment/55769/)
5466
in the forums.
5567

56-
## `@_assemblyVision`
57-
58-
Forces emission of assembly vision remarks for a function or method, showing
59-
where various runtime calls and performance impacting hazards are in the code
60-
at source level after optimization.
61-
62-
Adding this attribute to a type leads to remarks being emitted for all methods.
63-
6468
## `@_borrowed`
6569

6670
Indicates that the [conservative access pattern](/docs/Lexicon.md#access-pattern)
@@ -482,6 +486,19 @@ Fun fact: Rust has a very similar concept called
482486
including one called `Send`,
483487
which inspired the design of `Sendable`.
484488

489+
## `@_noAllocation`, `@_noLocks`
490+
491+
These attributes are performance annotations. If a function is annotated with
492+
such an attribute, the compiler issues a diagnostic message if the function
493+
calls a runtime function which allocates memory or locks, respectively.
494+
The `@_noLocks` attribute implies `@_noAllocation` because a memory allocation
495+
also locks.
496+
497+
## `@_noImplicitCopy`
498+
499+
Marks a var decl as a variable that must be copied explicitly using the builtin
500+
function Builtin.copy.
501+
485502
## `@_nonEphemeral`
486503

487504
Marks a function parameter that cannot accept a temporary pointer produced from
@@ -755,6 +772,14 @@ Clients can access SPI by marking the import as `@_spi(spiName) import Module`.
755772
This design makes it easy to find out which clients are using certain SPIs by
756773
doing a textual search.
757774

775+
## `@_spi_available(platform, version)`
776+
777+
Like `@available`, this attribute indicates a decl is available only as an SPI.
778+
This implies several behavioral changes comparing to regular `@available`:
779+
1. Type checker diagnoses when a client accidently exposes such a symbol in library APIs.
780+
2. When emitting public interfaces, `@_spi_available` is printed as `@available(platform, unavailable)`.
781+
3. ClangImporter imports ObjC macros `SPI_AVAILABLE` and `__SPI_AVAILABLE` to this attribute.
782+
758783
## `@_staticInitializeObjCMetadata`
759784

760785
Indicates that a static initializer should be emitted to register the
@@ -789,19 +814,11 @@ A type eraser has the following restrictions:
789814
This feature was designed to be used for compiler-driven type erasure for
790815
dynamic replacement of functions with an opaque return type.
791816

792-
## `@_weakLinked`
793-
794-
Allows a declaration to be weakly-referenced, i.e., any references emitted by
795-
client modules to the declaration's symbol will have weak linkage. This means
796-
that client code will compile without the guarantee that the symbol will be
797-
available at runtime. This requires a dynamic safety check (such as using
798-
`dlsym (3)`); otherwise, accessing the symbol when it is unavailable leads
799-
to a runtime crash.
817+
## `@_unavailableFromAsync`
800818

801-
This is an unsafe alternative to using `@available`, which is statically checked.
802-
If the availability of a library symbol is newer than the deployment target of
803-
the client, the symbol will be weakly linked, but checking for `@available` and
804-
`#(un)available` ensures that a symbol is not accessed when it is unavailable.
819+
Marks a synchronous API as being unavailable from asynchronous contexts. Direct
820+
usage of annotated API from asynchronous contexts will result in a warning from
821+
the compiler.
805822

806823
## `@_unsafeMainActor`, `@_unsafeSendable`
807824

@@ -812,38 +829,23 @@ within Swift 5 code that has adopted concurrency, but non-`@MainActor`
812829
See the forum post on [Concurrency in Swift 5 and 6](https://forums.swift.org/t/concurrency-in-swift-5-and-6/49337)
813830
for more details.
814831

815-
## `@_noImplicitCopy`
816-
817-
Marks a var decl as a variable that must be copied explicitly using the builtin
818-
function Builtin.copy.
819-
820-
## `@_noAllocation`, `@_noLocks`
821-
822-
These attributes are performance annotations. If a function is annotated with
823-
such an attribute, the compiler issues a diagnostic message if the function
824-
calls a runtime function which allocates memory or locks, respectively.
825-
The `@_noLocks` attribute implies `@_noAllocation` because a memory allocation
826-
also locks.
827-
828-
## `@_unavailableFromAsync`
829-
830-
Marks a synchronous API as being unavailable from asynchronous contexts. Direct
831-
usage of annotated API from asynchronous contexts will result in a warning from
832-
the compiler.
833-
834832
## `@_unsafeInheritExecutor`
835833

836834
This `async` function uses the pre-SE-0338 semantics of unsafely inheriting the caller's executor. This is an underscored feature because the right way of inheriting an executor is to pass in the required executor and switch to it. Unfortunately, there are functions in the standard library which need to inherit their caller's executor but cannot change their ABI because they were not defined as `@_alwaysEmitIntoClient` in the initial release.
837835

836+
## `@_weakLinked`
838837

839-
## `@_spi_available(platform, version)`
840-
841-
Like `@available`, this attribute indicates a decl is available only as an SPI.
842-
This implies several behavioral changes comparing to regular `@available`:
843-
1. Type checker diagnoses when a client accidently exposes such a symbol in library APIs.
844-
2. When emitting public interfaces, `@_spi_available` is printed as `@available(platform, unavailable)`.
845-
3. ClangImporter imports ObjC macros `SPI_AVAILABLE` and `__SPI_AVAILABLE` to this attribute.
838+
Allows a declaration to be weakly-referenced, i.e., any references emitted by
839+
client modules to the declaration's symbol will have weak linkage. This means
840+
that client code will compile without the guarantee that the symbol will be
841+
available at runtime. This requires a dynamic safety check (such as using
842+
`dlsym (3)`); otherwise, accessing the symbol when it is unavailable leads
843+
to a runtime crash.
846844

845+
This is an unsafe alternative to using `@available`, which is statically checked.
846+
If the availability of a library symbol is newer than the deployment target of
847+
the client, the symbol will be weakly linked, but checking for `@available` and
848+
`#(un)available` ensures that a symbol is not accessed when it is unavailable.
847849

848850
## `_local`
849851

@@ -852,8 +854,3 @@ the distributed actor isolation checks. This is used for things like `whenLocal`
852854
where the actor passed to the closure is known-to-be-local, and similarly a
853855
`self` of obtained from an _isolated_ function inside a distributed actor is
854856
also guaranteed to be local by construction.
855-
856-
857-
## `@_alwaysEmitConformanceMetadata`
858-
859-
Forces conformances of the attributed protocol to always have their Type Metadata get emitted into the binary and prevents it from being optimized away or stripped by the linker.

0 commit comments

Comments
 (0)