Commit Graph

48 Commits

Author SHA1 Message Date
Andrew Trick
4f337f0b9c Update tests after disallowing @_lifetime(borrow) for inout
(cherry picked from commit f6c7524353)
2025-06-12 16:31:56 -07:00
Meghana Gupta
8d3f38623d [NFC] Update tests and diagnostics 2025-06-11 13:15:22 -07:00
Guillaume Lessard
8d860936b2 Merge pull request #81225 from glessard/override-lifetime-publicly-6.2
[6.2, stdlib] make _overrideLifetime() functions public
2025-05-08 08:59:21 -07:00
Guillaume Lessard
ca8fc0ec04 [test] remove more copies of _overrideLifetime() 2025-05-07 17:14:14 -07:00
Andrew Trick
52228af771 Update tests for stricter diagnostics on borrowed argument lifetime
(cherry picked from commit 4ef3b4fa2d)
2025-04-25 19:21:16 -07:00
Andrew Trick
64a48d08e1 Update tests for strict @lifetime type checking 2025-03-19 11:59:04 -07:00
Andrew Trick
6849b66bb3 LifetimeDependenceDiagnostics; remove a bootstrapping hack.
This temporary hack was preventing diagnostics from kicking in. This could even
result in invalid SIL after the diagnostic failed to trigger.
2025-01-13 08:30:41 -08:00
Andrew Trick
5581ab876b Remove the experimental LifetimeDependenceDiagnoseTrivial feature.
This was never used to generate a .swiftinterface, so can be safely removed. It
was used to guard compiler fixes that might break older .swiftinterface
files. Now, we guard the same fixes by checking the source file type.
2024-12-18 17:11:32 -08:00
Andrew Trick
c05ddd683f Fix lifetime_dependence tests for trivial dependence.
To allow enforcement of trivial borrows.
2024-12-16 16:09:37 -08:00
Andrew Trick
5c89708def Add experimental-feature LifetimeDependenceDiagnoseTrivial to tests. 2024-12-16 16:09:37 -08:00
Meghana Gupta
e8abd59da5 Update tests 2024-11-18 18:09:19 -08:00
Meghana Gupta
daba1cb7bb Delete lifetime dependence inference on mutating self
We don't need this anymore since we have @lifetime(target: sources) syntax
2024-11-15 06:45:15 -08:00
Meghana Gupta
84a0d9c0b2 Remove -disable-experimental-parser-round-trip from @lifetime tests 2024-11-07 14:38:01 -08:00
Daniel Rodríguez Troitiño
ba68faaed5 [test] Mark tests that use experimental/upcoming features as such
Find all the usages of `--enable-experimental-feature` or
`--enable-upcoming-feature` in the tests and replace some of the
`REQUIRES: asserts` to use `REQUIRES: swift-feature-Foo` instead, which
should correctly apply to depending on the asserts/noasserts mode of the
toolchain for each feature.

Remove some comments that talked about enabling asserts since they don't
apply anymore (but I might had miss some).

All this was done with an automated script, so some formatting weirdness
might happen, but I hope I fixed most of those.

There might be some tests that were `REQUIRES: asserts` that might run
in `noasserts` toolchains now. This will normally be because their
feature went from experimental to upcoming/base and the tests were not
updated.
2024-11-02 11:46:46 -07:00
Allan Shortlidge
cb578172ea Tests: Remove -disable-availability-checking in more tests that use concurrency.
Use the `%target-swift-5.1-abi-triple` substitution to compile the tests for
deployment to the minimum OS versions required for use of _Concurrency APIs,
instead of disabling availability checking.
2024-10-19 12:35:20 -07:00
Rintaro Ishizaki
ba485d4630 [Test] Disable experimental parser round-trip in '@lifetime' test cases
Until SwiftParser supports the syntax

rdar://137636751
2024-10-09 23:52:52 -07:00
Meghana Gupta
008431c3b4 Update some dependsOn tests to @lifetime 2024-10-08 15:12:13 -07:00
Meghana Gupta
10057523ec Delete lifetime dependence mangling
Mangling this information for future directions like component lifetimes
becomes complex and the current mangling scheme isn't scalable anyway.

Deleting this support for now.
2024-09-05 22:03:58 -07:00
Andrew Trick
11ba799cd4 LifetimeDependence: diagnose yield and store-to-yield. 2024-07-30 16:27:48 -07:00
Andrew Trick
50ee84a0b4 Infer LifetimeDependenceInfo on a mutating method
We need this at least until we have 'dependsOn(self)' syntax.

When 'self' is nonescapable and the result is 'void', assume that 'self' depends
on a single nonescapable argument.
2024-07-30 15:57:57 -07:00
Andrew Trick
11640461ef Lifetime dependence: add inferrence for setters.
A nonescapable computed property should always depend on 'newValue'. We simply
infer that now. There's no way to explicitly spell the dependence.
2024-07-30 15:57:57 -07:00
Meghana Gupta
7499cf3fbb Update lifetime dependence tests 2024-07-10 14:48:30 -07:00
Andrew Trick
b5b0c75ccd Remove diagnostic: lifetime_dependence_on_bitwise_copyable
Allow lifetime depenendence on types that are BitwiseCopyable & Escapable.

This is unsafe in the sense that the compiler will not diagnose any use of the
dependent value outside of the lexcial scope of the source value. But, in
practice, dependence on an UnsafePointer is often needed. In that case, the
programmer should have already taken responsibility for ensuring the lifetime of the
pointer over all dependent uses. Typically, an unsafe pointer is valid for the
duration of a closure. Lifetime dependence prevents the dependent value from
being returned by the closure, so common usage is safe by default.

Typical example:

func decode(_ bufferRef: Span<Int>) { /*...*/ }

extension UnsafeBufferPointer {
  // The client must ensure the lifetime of the buffer across the invocation of `body`.
  // The client must ensure that no code modifies the buffer during the invocation of `body`.
  func withUnsafeSpan<Result>(_ body: (Span<Element>) throws -> Result) rethrows -> Result {
    // Construct Span using its internal, unsafe API.
    try body(Span(unsafePointer: baseAddress!, count: count))
  }
}

func decodeArrayAsUBP(array: [Int]) {
  array.withUnsafeBufferPointer { buffer in
    buffer.withUnsafeSpan {
      decode($0)
    }
  }
}

In the future, we may add SILGen support for tracking the lexical scope of
BitwiseCopyable values. That would allow them to have the same dependence
behavior as other source values.
2024-05-22 17:10:56 -07:00
Kavon Farvardin
0420310623 NCGenerics: it's no longer "experimental"
resolves rdar://127701059
2024-05-08 10:49:12 -07:00
Meghana Gupta
9c57458163 Fix index numbering in lifetime dependence 2024-04-08 22:33:28 -07:00
Meghana Gupta
5a96e6c199 Add -disable-availability-checking to the required test 2024-03-28 18:27:13 -07:00
Meghana Gupta
bc0b884609 Fix demangling of lifetime dependence when other function annotations like throws etc are present
It was demangled in the wrong order previously.
2024-03-28 14:58:06 -07:00
Meghana Gupta
b5ca933002 Update lifetime dependence syntax and inference as per changes in the pitch
Pitch - https://github.com/apple/swift-evolution/pull/2305

Changes highlights:

dependsOn(paramName) and dependsOn(scoped argName) syntax

dependsOn(paramName) -> copy lifetime dependence for all parameters/self except
                         when we have Escapable parameters/self, we assign scope
                         lifetime dependence.

Allow lifetime dependence on parameters without ownership modifier.

Always infer copy lifetime dependence except when we have
Escapable parameters/self, we infer scope lifetime dependence.

Allow lifetime dependence inference on parameters without ownership modifier.
2024-03-23 18:19:47 -07:00
Alex Hoppen
978145c61d [Parser] Remove remaining -disable-experimental-parser-round-trip uses in test cases
All the features in these test cases are now supported by the new parser, so we don’t need the opt-out anymore.

rdar://124646502
2024-03-15 12:30:40 -07:00
Meghana Gupta
a9b1de47cc Remove unnecessary -enable-builtin-module flag from lifetime dependence tests 2024-02-27 15:59:33 -08:00
Meghana Gupta
0b574c4b39 Remove -enable-experimental-lifetime-dependence-inference now that it is enabled by default 2024-02-27 15:56:50 -08:00
Meghana Gupta
55153ce00f Fix lifetime dependence inference for multi-arg functions 2024-02-27 15:53:32 -08:00
Meghana Gupta
afdd141714 Ban lifetime dependence specifiers on tuple result 2024-02-23 15:29:05 -08:00
Meghana Gupta
c628bc1362 Add test for lifetime dependence inference in subscripts 2024-02-20 13:29:00 -08:00
Meghana Gupta
820929438b Add support for lifetime dependence inference for _read/_modify accessors 2024-02-19 15:28:04 -08:00
Meghana Gupta
3fa0886206 Merge pull request #71677 from meg-gupta/lifetimedepgetter
Support lifetime dependence inference on getters
2024-02-16 14:53:02 -08:00
Meghana Gupta
dfa95c4e48 Support lifetime dependence inference on getters 2024-02-15 23:29:12 -08:00
Kavon Farvardin
08b71e0136 NCGenerics: rebuild stdlib from its interface
When a NoncopyableGenericsMismatch happens between the compiler and
stdlib, allow the compiler to rebuild the stdlib from its interface
instead of exiting with an error.
2024-02-15 18:08:54 -08:00
Meghana Gupta
59a401d337 Update tests 2024-02-15 00:58:38 -08:00
Meghana Gupta
455a3d5e05 Enable lifetime dependence inference on parameters with just ownership modifiers 2024-02-14 19:50:03 -08:00
Meghana Gupta
0fd6ef3309 Add support for lifetime dependence mangling 2024-02-14 13:16:31 -08:00
Meghana Gupta
75bd5b08dd Add LifetimeDependenceScopeFixup pass 2024-02-13 16:52:01 -08:00
Meghana Gupta
8fd8bb99ec Rename borrowLifetimeParamIndices -> scopeLifetimeParamIndices 2024-02-08 14:21:43 -08:00
Kavon Farvardin
9e6f8ce488 Test: remove incorrect flag 2024-02-06 10:08:34 -08:00
Kavon Farvardin
5f977ca763 NCGenerics: force module mismatches 2024-01-31 14:00:08 -08:00
Meghana Gupta
843d0037ab Infer lifetime dependence for initializers of ~Escapable type 2024-01-31 00:01:43 -08:00
Andrew Trick
ddceffaf3b LifetimeDependenceDiagnostics pass
Initial diagnostic pass to enforce ~Escapable types.
2024-01-30 11:45:55 -08:00
Meghana Gupta
4dcda843e2 Infer lifetime dependence info for functions that return ~Escapable type 2024-01-29 15:45:19 -08:00