Commit Graph

2 Commits

Author SHA1 Message Date
Andrew Trick
b56a787c74 SILGen: emit mark_dependence for unsafeAddress
Fixes a correctness issue with unsafe addressors: `unsafeAddress` and
`unsafeMutableAddress`. Previously, the resulting `Unsafe[Mutable]Pointer` did
not depend on `self`, meaning that the compiler is allowed to destroy `self`
before any uses of the pointer. This happens to be valid for
`UnsafePointer.pointee` because, in that case, `self` does not have a lifetime
anyway; the correctness burden was on the programmer to use
`withExtendedLifetime` around all uses of `self`.

Now, unsafe addressors can be used for arbitrary `Self` types.

This also enables lifetime dependence diagnostics when the addressor points to a
`~Escapable` type.

Addressors can now be used as an implementation of borrowed properties.
2024-12-17 09:53:02 -08:00
Andrew Trick
cfe1aa8f07 [MoveCheckers] test unsafeAddress with mark_depends
Test MoveOnlyAddressChecker and MoveOnlyObjectChecker utilities, which
handle load [copy], with a mark_dependence on the address returned by
unsafeAddress.
2024-10-22 09:28:54 -07:00