Commit Graph

3132 Commits

Author SHA1 Message Date
Evan Wilde
8a7c3c98b6 Adding another C++ stdlib function to ignore list
Looks like rebranch is finding another realloc_insert function on
vector causing failures on the Ubuntu 20.04 aarch64 bot.

_ZNSt6vectorIjSaIjEE17_M_realloc_insertIJRKjEEEvN9__gnu_cxx17__normal_iteratorIPjS1_EEDpOT_

We'll go ahead and ignore it for now.
2023-09-19 11:58:52 -07:00
Erik Eckstein
5bc036661c SIL optimizer: add the LetPropertyLowering pass
It lowers let property accesses of classes.
Lowering consists of two tasks:

* In class initializers, insert `end_init_let_ref` instructions at places where all let-fields are initialized.
  This strictly separates the life-range of the class into a region where let fields are still written during
  initialization and a region where let fields are truly immutable.

* Add the `[immutable]` flag to all `ref_element_addr` instructions (for let-fields) which are in the "immutable"
  region. This includes the region after an inserted `end_init_let_ref` in an class initializer, but also all
  let-field accesses in other functions than the initializer and the destructor.

This pass should run after DefiniteInitialization but before RawSILInstLowering (because it relies on `mark_uninitialized` still present in the class initializer).
Note that it's not mandatory to run this pass. If it doesn't run, SIL is still correct.

Simplified example (after lowering):

  bb0(%0 : @owned C):                           // = self of the class initializer
    %1 = mark_uninitialized %0
    %2 = ref_element_addr %1, #C.l              // a let-field
    store %init_value to %2
    %3 = end_init_let_ref %1                    // inserted by lowering
    %4 = ref_element_addr [immutable] %3, #C.l  // set to immutable by lowering
    %5 = load %4
2023-09-19 15:10:30 +02:00
Erik Eckstein
e5eb15dcbe Swift SIL: replace the set_deallocating instruction with begin_dealloc_ref
Codegen is the same, but `begin_dealloc_ref` consumes the operand and produces a new SSA value.
This cleanly splits the liferange to the region before and within the destructor of a class.
2023-09-19 15:10:30 +02:00
Guillaume Lessard
c30307e21f [test] replace uses of String(validatingUTF8:)
- use the new name `String(validatingCString:)`
2023-09-11 14:17:05 -07:00
Saleem Abdulrasool
99453fc2e8 test: introduce a new %swift-plugin-dir macro
Use this to define the macro location rather than the "host" dir (which
is actually for the build and not the host).  Furthermore, on Windows,
the build dir is /usr/lib/swift as the host content is in the SDK.

This prepares the tests for Windows.
2023-09-04 13:04:18 -07:00
Nate Cook
c7577bbe41 Disable stdlib tests under the OS stdlib
These two tests verify recent fixes, so they fail when run against
older versions of the stdlib.
2023-08-29 17:35:05 -05:00
Nate Cook
ad19d35b26 Disable StringAPI test on OS stdlib
These tests verify fixes in the stdlib post-5.9, which means
that they fail when tested on older versions of the stdlib.

Fixes rdar://114581543
2023-08-28 15:07:11 -05:00
Stephen Canon
b9a07dcf89 Disable stdlib/Duration.swift tests on old OSes.
These tests exercise a code path that has a known bug on older OS versions (fixed with Swift 5.9), so disable it for testing in those environments.
2023-08-28 13:29:29 -04:00
Saleem Abdulrasool
898f9efe3e Merge pull request #68099 from hjyamauchi/abort
Fix a fatal error not-terminating issue in Windows
2023-08-27 12:08:32 -07:00
Hiroshi Yamauchi
5fc3ad3a81 Fix a fatal error not-terminating issue in Windows.
Fix the issue that fatal errors in certain cases don't terminate the
process and the process keeps running in Windows by disabling the
exception swallowing that supressed the illegal instruction exceptions
coming from llvm.trap.
2023-08-25 13:04:36 -07:00
Nishith Kumar M Shah
056b4943a3 Fix String.hasPrefix and String.hasSuffix when self and arg are in NFC form (#67729) 2023-08-23 11:23:59 -05:00
Michael Spencer
b2640e15e4 [test] Rename all module.map files to module.modulemap
`module.map` as a module map name has been discouraged since 2014, and
Clang will soon warn on its usage. This patch renames all instances of
`module.map` in the Swift tests to `module.modulemap` in preparation
for this change to Clang.

rdar://106123303
2023-08-21 15:58:59 -07:00
Doug Gregor
1d246629a4 Merge pull request #67998 from DougGregor/observer-macros-on-computed-properties
Improve checking of macro-generated accessors against documented names
2023-08-17 20:46:35 -07:00
Doug Gregor
5d6746d974 Improve checking of macro-generated accessors against documented names
The checking of the accessors generated by a macro against the
documented set of accessors for the macro is slightly too strict and
produces misleading error messages. Make the check slightly looser in
the case where an observer-producing macro (such as
`@ObservationIgnored`) is applied to a computed property. Here, we
would diagnose that the observer did not in fact produce any
observers, even though it couldn't have: computed properties don't get
observers. Remove the diagnostic in this case.

While here, add some tests and improve the wording of diagnostics a
bit.

Fixes rdar://113710199.
2023-08-17 16:59:42 -07:00
swift-ci
5f5b68e38e Merge pull request #67962 from DougGregor/init-accessors-is-not-experimental
Remove unnecessary `--enable-experimental-feature InitAccessors` from tests
2023-08-16 11:33:38 -07:00
Doug Gregor
5edfc26156 Remove unnecessary --enable-experimental-feature InitAccessors from tests
This feature was accepted, so we no longer need to pass this flag. Worse,
it triggers errors in non-Asserts compilers. Fixes rdar://113708096.
2023-08-16 09:00:39 -07:00
Ben Rimmington
98ada1b200 [stdlib] Fix buffer size of small-capacity strings (#67929) 2023-08-16 10:00:42 +01:00
Allan Shortlidge
024ed957cd NFC: Re-enable ObservableAvailabilityCycle.swift test. 2023-08-08 15:58:08 -07:00
Slava Pestov
c9225db156 Disable test/stdlib/Observation/ObservableAvailabilityCycle.swift 2023-08-04 10:20:04 -04:00
Doug Gregor
c098175059 Add test case involving circular references with @Observable
Add a test case for Observable types that are extended from other
source files. Prior to the recent changes to make
`TypeRefinementContext` more lazy, this would trigger circular
references through the `TypeRefinementContextBuilder`.

Finishes rdar://112079160.
2023-08-02 15:07:09 -07:00
Allan Shortlidge
7c0a9cc92e Merge pull request #67636 from tshortli/enum-unavailable-element-derived-equatable-hashable
Sema: Fix unavailable enum element cases in derived hashable/equatable impls
2023-08-01 16:22:28 -07:00
Allan Shortlidge
2442737a7d NFC: Fix %target-run-simple-swift invocations in a couple of tests.
The `-unavailable-decl-optimization` flag is a frontend flag and therefore
requires `-Xfrontend` when passed through the driver.
2023-07-31 17:26:34 -07:00
Pavel Yaskevich
2a0651e8b0 [Frontend/NFC] SE-0400: Enable InitAccessors feature by default 2023-07-31 13:18:59 -07:00
Allan Shortlidge
7996c5b30c Sema: Avoid decoding unavailable enum elements in derived Codable conformances.
The compiler derived implementations of `Codable` conformances for enums did
not take enum element unavailability into account. This could result in
unavailable values being instantiated at runtime, leading to a general
violation of the invariant that unavailable code is unreachable at runtime.
This problem is possible because synthesized code is not type checked; had the
conformances been hand-written, they would have been rejected for referencing
unavailable declarations inside of available declarations.

This change specifically alters derivation for the following declarations:
- `Decodable.init(from:)`
- `Encodable.encode(to:)`
- `CodingKey.init(stringValue:)`

Resolves rdar://110098469
2023-07-26 22:48:25 -07:00
Max Desiatov
1f99204897 test: disable crashing tests on WASI (#67531)
WASI doesn't support spawning a subprocess, so crash tests crashes the test harness itself. Those should be skipped until proper subprocess support is available.
2023-07-26 18:43:02 +01:00
Philippe Hausler
0fca5199e7 [Observation] Forward availability and defines to extensions (#67412)
* [Observation] Forward availability and defines to extensions

* Simplify availability slightly from review feedback

* Simplify availability for extensions to use `.with`
2023-07-26 08:46:57 -07:00
Slava Pestov
e454458e2a Runtime: Lift prohibition on packs in swift_getTypeByMangledName() overload used by mirrors
Fixes rdar://problem/112866068.
2023-07-25 23:15:01 -04:00
Erik Eckstein
7f54c63b29 tests: Disable some tests which fail due to problems in Foundation
Those tests should be part of the Foundation overlay, which is no longer part of the Swift project.

rdar://112643333
2023-07-24 08:34:06 +02:00
Max Desiatov
29fa1c0806 test: Disable test/stdlib/Duration.swift on 32bit platforms (#67469)
128-bit types are not provided by LLVM for 32-bit targets.
2023-07-22 22:48:30 +01:00
Max Desiatov
a7142c896a test/stdlib/UnsafeRawPointer.swift: disable crashing tests on WASI 2023-07-22 14:44:16 +01:00
Max Desiatov
ed7043cc0a test/stdlib/TemporaryAllocation.swift: disable crashing tests on WASI 2023-07-22 14:42:48 +01:00
Max Desiatov
94271b53f1 test/stdlib/StringAPICString.swift: disable crashing tests on WASI 2023-07-22 14:41:31 +01:00
Max Desiatov
2b69325821 test/stdlib/StringAPI.swift: disable crashing tests on WASI 2023-07-22 14:38:04 +01:00
Max Desiatov
8b52415184 test/stdlib/Error.swift: disable crashing tests on WASI 2023-07-22 14:36:57 +01:00
Nate Cook
e68395c923 Disable diagnostic test again for now 2023-07-21 09:29:20 -05:00
Nate Cook
90d341421e Remove dump-macro flag in test 2023-07-19 16:07:13 -05:00
Nate Cook
5b9d68b023 Merge branch 'main' into observation_peer_macros 2023-07-19 16:05:43 -05:00
Philippe Hausler
7d37cdf982 [Observation] Tracking adjustments for stability and correctness (#67233)
* [Observation] Correct tracking such that recursive but disperate changes can be tracked without crashing

* [Observation] Adjust the SPI interface for tracking to support deferred cancellation of events and handle both willSet and didSet events
2023-07-18 11:06:43 -07:00
Mike Ash
e89de6e7e0 Merge pull request #67252 from mikeash/remove-foundation-tests
[Test] Remove stdlib/NSStringAPI.swift and some supporting code.
2023-07-17 11:45:49 -04:00
Nate Cook
c5fbb4210e [Obs] Switch to peer instead of arbitrary macros
This adopts `@attached(peer)` for generating an observable type's
underscored storage when expanding the `@ObservationTracked` macro,
instead of using `arbitrary` with the member macro on the
observable type.
2023-07-13 14:30:33 -05:00
Nate Cook
e36e316b05 Add diagnostic test for @Observable macro (#67250)
This adds a diagnostic test that validates errors for putting
the `@Observable` macro on a struct, enum, or actor.
2023-07-13 11:27:52 -05:00
Mike Ash
ea6a2e26f2 [Test] Remove stdlib/NSStringAPI.swift and some supporting code.
This is testing the Foundation overlay, which is no longer part of the Swift project.
2023-07-12 12:18:58 -04:00
Nate Cook
003b335351 [Observation] Switch Observable to be a non-marker protocol (#66993)
With support for redundant conformance declarations via macros,
the `Observable` protocol can be a non-marker protocol, which
provides more flexibility for evolution in the future.

rdar://111463883

This change also switches to the new ExtensionMacro protocol,
the requirement for which includes information about whether the
conformance to the Observable protocol has already been added, either
in the declaration or in a superclass to the macro-attributed type.
This allows the @Observable macro to be applied to subclasses of
observable types without redundant-conformance errors.
2023-07-09 13:09:14 -05:00
Nate Cook
40a7396b03 Make the @Observable macro class only (#67033)
* Make ObservationRegistrar Codable/Hashable

These conformances enable automatic Codable synthesis for Observable
types, and smooth the runway for structs being supported by the
Observable macro in the future.

* Limit Observable macro to classes

This removes the ability for the Observable macro to apply to structs,
and adds diagnostic tests for the three disallowed declaration kinds.
2023-07-06 15:01:01 -05:00
Max Desiatov
bc783c4601 test/stdlib: cover wasm32 in FloatingPointIR.swift (#67138)
This makes sure that floating point IR doesn't regress when targeting wasm32.
2023-07-06 10:17:16 +01:00
Doug Gregor
6265f0c542 [SE-0395] Rename _Observation module to Observation
The review of SE-0395 is down to small details at this point that won't
affect the overall shape of the API much. Rename the model in
anticipation of that.
2023-06-30 11:01:02 -07:00
Yuta Saito
cadc20cf3a [test] Make KeyPath test pointer-size agnostic part 2 2023-06-29 06:02:48 +00:00
Alejandro Alonso
0bb142f1fc Merge pull request #66870 from Azoy/keypath-offset-spi-fix
[stdlib] Add support for classes in _createOffsetBasedKeyPath
2023-06-26 11:24:45 -07:00
Doug Gregor
606db016e6 Merge pull request #66730 from DougGregor/observable-willset-didset
[Macros] Add test using observer accessors (didSet/willSet) with Observable
2023-06-23 14:18:44 -07:00
Alejandro Alonso
d9d26eec9d Add support for classes in _createOffsetBasedKeyPath 2023-06-22 14:07:41 -07:00