@@ -425,19 +425,33 @@ number of ways:
425
425
generic function with ``function_ref `` will give a value of
426
426
generic function type.
427
427
428
+ - A SIL function type may be declared ``@noescape ``. This is required for any
429
+ function type passed to a parameter not declared with ``@escaping ``
430
+ declaration modifier. ``@noescape `` function types may be either
431
+ ``@convention(thin) `` or ``@callee_guaranteed ``. They have an
432
+ unowned context--the context's lifetime must be independently guaranteed.
433
+
428
434
- A SIL function type declares its conventional treatment of its
429
435
context value:
430
436
431
437
- If it is ``@convention(thin) ``, the function requires no context value.
438
+ Such types may also be declared ``@noescape ``, which trivially has no effect
439
+ passing the context value.
432
440
433
- - If it is ``@callee_owned ``, the context value is treated as an
434
- owned direct parameter.
441
+ - If it is ``@callee_guaranteed ``, the context value is treated as a direct
442
+ parameter. This implies ``@convention(thick) ``. If the function type is also
443
+ ``@noescape ``, then the context value is unowned, otherwise it is
444
+ guaranteed.
435
445
436
- - If it is ``@callee_guaranteed ``, the context value is treated as
437
- a guaranteed direct parameter.
446
+ - If it is ``@callee_owned ``, the context value is treated as an owned direct
447
+ parameter. This implies ``@convention(thick) `` and is mutually exclusive
448
+ with ``@noescape ``.
438
449
439
- - Otherwise, the context value is treated as an unowned direct
440
- parameter.
450
+ - If it is ``@convention(block) ``, the context value is treated as an unowned
451
+ direct parameter.
452
+
453
+ - Other function type conventions are described in ``Properties of Types `` and
454
+ ``Calling Convention ``.
441
455
442
456
- A SIL function type declares the conventions for its parameters.
443
457
The parameters are written as an unlabeled tuple; the elements of that
@@ -549,14 +563,6 @@ the caller. A non-autoreleased ``apply`` of a function that is defined
549
563
with an autoreleased result has the effect of performing an
550
564
autorelease in the callee.
551
565
552
- - The ``@noescape `` declaration attribute on Swift parameters (which is valid only
553
- on parameters of function type, and is implied by the ``@autoclosure `` attribute)
554
- is turned into a ``@noescape `` type attribute on SIL arguments. ``@noescape ``
555
- indicates that the lifetime of the closure parameter will not be extended by
556
- the callee (e.g. the pointer will not be stored in a global variable). It
557
- corresponds to the LLVM "nocapture" attribute in terms of semantics (but is
558
- limited to only work with parameters of function type in Swift).
559
-
560
566
- SIL function types may provide an optional error result, written by
561
567
placing ``@error `` on a result. An error result is always
562
568
implicitly ``@owned ``. Only functions with a native calling
@@ -704,6 +710,7 @@ types. Function types are transformed in order to encode additional attributes:
704
710
- ``@convention(thick) `` indicates a "thick" function reference, which
705
711
uses the Swift calling convention and carries a reference-counted context
706
712
object used to represent captures or other state required by the function.
713
+ This attribute is implied by ``@callee_owned `` or ``@callee_guaranteed ``.
707
714
- ``@convention(block) `` indicates an Objective-C compatible block reference.
708
715
The function value is represented as a reference to the block object,
709
716
which is an ``id ``-compatible Objective-C object that embeds its invocation
0 commit comments