Commit Graph

7628 Commits

Author SHA1 Message Date
Nate Chandler
7713eef817 [MoveValueChecker] Complete lifetimes first.
Before move-checking values, complete the lifetimes of all the values
derived from them via copy, borrow, and move.

Collect all such values and their derived transitive values and then
complete the lifetimes of each, visiting the instructions which produce
them in post-order.

Once OSSALifetimeCommpletion runs as part of SILGenCleanup, this code
can be deleted.
2023-09-07 07:11:24 -07:00
Alex Hoppen
acc6c10344 Merge pull request #68075 from ahoppen/ahoppen/labeled-trailing-closure-solver-based
[CodeCompletion] Migrate labeled trailing closure completions to solver-based
2023-09-06 13:10:56 -07:00
Erik Eckstein
f6f9e75173 AliasAnalysis: use a complexity limit for the isObjReleased function
We already use a complexity limit for other functions in AliasAnalysis.
This is a workaround for quadratic complexity in ARCSequenceOpts.

Fixes a compile time problem
rdar://114352817
2023-09-04 19:52:57 +02:00
Nate Chandler
b3e009003f [Test] Loosened check lines.
The metatype param may or may not be removed from the callee during
specialization.  If it is, there is only one argument, if it is not,
there are two arguments.  None of that is relevant to this test case.
It is just verifying that the strong_retain occurs before the apply.
2023-08-31 15:19:57 -07:00
Ben Barham
d431e03307 Merge pull request #68218 from bnbarham/set-python-encoding
[stdlib] Set PYTHONIOENCODING when building the stdlib
2023-08-31 09:46:10 -07:00
Nate Chandler
504ce43753 [stdlib] Delete bad @_effects(readonly) annotation
`Dictionary.init(dictionaryLiteral:)` was annotated
`@_effects(readonly)` which means among other things that it doesn't
release any references. Being an init, however, it consumes its
arguments, and so does in fact release.

rdar://114699006
2023-08-30 12:33:58 -07:00
Ben Barham
ec1550c92a [validation] Fix line-directive validation test
This was disabled due to:
```
Unable to decode the command from the command line:
UnicodeEncodeError: 'utf-8' codec can't encode characters in position 13-20: surrogates not allowed
```

Note that this error isn't in `line-directive`, but in Python decoding
surrogates from the command line. Not sure why that's not allowed, but
printing from within a script works so change to that.

We already set `PYTHONIOENCODING=UTF8` in the environment in
`test/lit.cfg`, which makes sure stdout is UTF8 as opposed to ASCII.

Resolves rdar://92613094.
2023-08-30 11:52:21 -07:00
swift-ci
720e423c12 Merge pull request #68199 from natecook1000/test_fix_2
Disable stdlib tests under the OS stdlib
2023-08-29 21:52:44 -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
Mike Ash
5928859970 [Test] Have rdar81421394.swift import Foundation.
This test occasionally fails due apparently not loading libswiftFoundation. The test relies on a bridging header to import the Foundation module, which seems iffy. Explicitly import Foundation instead.

rdar://114590327
2023-08-29 09:50:31 -04:00
Saleem Abdulrasool
88e62d7de2 Merge pull request #68134 from compnerd/fragility
Cxx: mark as fragile
2023-08-25 16:21:35 -07:00
Saleem Abdulrasool
dff40e9399 Cxx: mark as fragile
This library is still fragile as C++ Interop is in preview. Mark it as
fragile to match cxxStdlib.
2023-08-25 11:31:36 -07:00
Alex Hoppen
a1bfb510e1 [CodeCompletion] Migrate labeled trailing closure completions to solver-based
rdar://113472967
2023-08-24 15:41:36 -07:00
Ben Barham
8fbdae12fc [Build] Skip early-* on non-darwin hosts
These builds do not work outside of darwin currently. Rather than adding
the skip to all the necessary build presets, just disable in the product
instead.
2023-08-23 11:43:35 -07:00
Evan Wilde
0f0e68fc4c Merge pull request #68029 from etcwilde/ewilde/delete-backdeploy-concurrency
Delete backdeploy concurrency library
2023-08-23 09:03:09 -07:00
Holly Borla
d4f3bc6cd3 Merge pull request #68081 from hborla/sendable-self-in-reference 2023-08-23 06:13:38 -07:00
Holly Borla
84eaeb766f [Concurrency] Diagnose non-Sendable 'self' arguments crossing actor isolation
boundaries in member reference expressions.
2023-08-22 21:28:33 -07:00
Alex Hoppen
baa20aec52 Merge pull request #67909 from nishithshah2211/imperative-fixits
[Diagnostics] Use imperative msg for protocol conformance & switch-case fixits
2023-08-21 14:40:21 -07:00
Evan Wilde
e54b18370d Delete backdeploy concurrency library
This library served its purpose and has overstayed its welcome.
The library shipped in Xcode can't change again from the state it was
in, so changes to the sources here will not affect that library, which
is confusing. The library does not currently build due to changes in the
runtime headers, so it does not give meaningful signal to anything
anymore. If you need to test things in a backdeploy concurrency
environment, use the copy from the toolchain in Xcode as that will give
you a far clearer picture of what the code will actually be running with
than the state of the sources here did.
2023-08-20 11:01:23 -07:00
nate-chandler
c0fa16e7be Merge pull request #68000 from nate-chandler/cherrypick/main/rdar114013709
[IRGen] Cast fixed-size opaque globals.
2023-08-18 06:59:30 -07:00
Nate Chandler
9981a82d01 [IRGen] Cast fixed-size opaque globals.
In https://github.com/apple/swift/pull/66560 , a bug in the lowering of
`global_addr` was fixed.  Part of that fix was to postpone mapping the
type of the global into context until getting the address of the global
and projecting the buffer for the out-of-line value; at that point, the
type is mapped into context and the address is cast.

It introduced an issue for fixed-size globals, however: the type of such
globals was not mapped into context; the result was that the lowered
value set for the corresponding SIL value would have the wrong type.

Fix that by extracting the code which mapped the type into context and
cast the address to the appropriate lowered type into a lambda and call
that lambda both in both the fixed-size (newly) and non-fixed-size (as
before) cases.

rdar://114013709
2023-08-17 17:23:02 -07:00
Pavel Yaskevich
b34f9720e4 [CSSimplify] Adjust {Any, Partial}KeyPath bindings right before resolving
A type variable that represents a key path literal cannot be bound
directly to `AnyKeyPath` or `PartialKeyPath`, such types could only
be used for conversions.
It used to be the task of the binding inference to infer `AnyKeyPath`
and `PartiaKeyPath` as a `KeyPath` using previously generated type
variables for a root and value associated with key path literal
(previously stored in the locator).

Recently we switched over to storing key path information in the
constraint system and introduced `resolveKeyPath` method to gain
more control over how key path type variable gets assigned.

Getting information from the constraint system creates a problem
for the inference because "undo" for some bindings would be run
after solver scope has been erased, so instead of modifying bindings
in `inferFromRelational`, let's do that in `resolveKeyPath` right
before the key path type variable gets bound which seems to be a
better place for that logic anyway.

Resolves: rdar://113760727
2023-08-15 13:50:54 -07:00
Pavel Yaskevich
cedbdf920c Merge pull request #67759 from xedin/rdar-112617922
[CSSimplify] Relax `isBindable` requirements for pack expansion variables
2023-08-15 09:00:12 -07:00
Nishith Shah
8e2e625543 [Diagnostics] Use imperative msg for protocol conformance & switch-case fixits
This commit changes fixit messages from a question/suggestion to an
imperative message for protocol conformances and switch-case. Addresses
https://github.com/apple/swift/issues/67510.
2023-08-13 22:34:26 -07:00
Slava Pestov
64eb9dfbd4 Merge pull request #67798 from slavapestov/fix-rdar113103854
Sema: Fix a couple of problems in checkContextualRequirements()
2023-08-09 20:12:11 -04:00
Slava Pestov
a7c276bd14 Update 0161-issue-49119.swift 2023-08-09 17:11:11 -04:00
Slava Pestov
fbd1f1acbd Sema: Fix a couple of problems in checkContextualRequirements()
The original bug was a crash-on-invalid with a missing '}', but it
actually exposed a bug with nested protocols (SE-0404) and another
long-time bug.

- Whatever we do, we should skip this for protocols because their 'Self'
  parameter is not bound from context.

- getTrailingWhereClause() is not the right proxy for "has a generic
  signature different than its parent", in particular it doesn't
  round-trip through serialization. Instead, just compare generic
  signatures for pointer equality in the early return check.

The second change is source-breaking because it was possible to
write a nested type with a `where` clause and use it contradicting
its requirements across a module boundary.

Fixes rdar://113103854.
2023-08-08 15:06:08 -04:00
Slava Pestov
4ebbb60fae Regression test for rdar://problem/113492450 2023-08-08 11:03:11 -04:00
Pavel Yaskevich
27413f5624 [CSSimplify] Relax isBindable requirements for pack expansion variables
If type variable we are about to bind represents a pack
expansion type, allow the binding to happen regardless of
what the \c type is, because contextual type is just a hint
in this situation and type variable would be bound to its
opened type instead.

Resolves: rdar://112617922
2023-08-04 16:49:20 -07:00
eeckstein
b3cd553dba Merge pull request #67534 from eeckstein/fix-24-bit-enums
IRGen: fix a problem with 24-bit enum payloads in statically initialized global variables
2023-07-27 05:50:32 +02:00
Nate Chandler
35b37ab5f5 [Test] Disable test with debug stdlibs.
Now that the SwiftStdlib 5.9 macro has been defined, this test failing
with stdlib debug builds is exposed. That is occurring because the back
deployment fallback
`$ss9TaskLocalC13withValueImpl_9operation4file4lineqd__xn_qd__yYaKXESSSutYaKlFTwB`
is now being called.

In unoptimized stdlib builds, the version of that function that is
deserialized into the test case module features an unoptimized copy of
the argument `%1` into a temporary (`%10`):

```
  %10 = alloc_stack $Value                        // users: %14, %13, %11
  copy_addr %1 to [init] %10 : $*Value            // id: %11
  // function_ref swift_task_localValuePush
  %12 = function_ref @swift_task_localValuePush : $@convention(thin) <τ_0_0> (Builtin.RawPointer, @in τ_0_0) -> () // user: %13
  %13 = apply %12<Value>(%9, %10) : $@convention(thin) <τ_0_0> (Builtin.RawPointer, @in τ_0_0) -> ()
  dealloc_stack %10 : $*Value                     // id: %14
```

This is a problem because `swift_task_localValuePush` allocates in the
async stack (see rdar://107275872) but that fact isn't encoded in SIL
(the fix for which is tracked by rdar://108260399), so the
`alloc_stack`/`dealloc_stack` surrounding that call result in a
violation of stack discipline.

```
push // alloc_stack
push // swift_task_localValuePush
pop // dealloc_stack -- oops
```

In optimized stdlib builds, the copy has been optimized away by the time
the function is deserialized into the test case module:

```
bb0(%0 : $*R, %1 : $*Value, %2 : @guaranteed $@noescape @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for <R>, %3 : @guaranteed $String, %4 : $UInt, %5 : @guaranteed $TaskLocal<Value>):
  // function_ref _checkIllegalTaskLocalBindingWithinWithTaskGroup(file:line:)
  %6 = function_ref @$ss039_checkIllegalTaskLocalBindingWithinWithC5Group4file4lineySS_SutF : $@convention(thin) (@guaranteed String, UInt) -> () // user: %7
  %7 = apply %6(%3, %4) : $@convention(thin) (@guaranteed String, UInt) -> ()
  // function_ref TaskLocal.key.getter
  %8 = function_ref @$ss9TaskLocalC3keyBpvg : $@convention(method) <τ_0_0 where τ_0_0 : Sendable> (@guaranteed TaskLocal<τ_0_0>) -> Builtin.RawPointer // user: %9
  %9 = apply %8<Value>(%5) : $@convention(method) <τ_0_0 where τ_0_0 : Sendable> (@guaranteed TaskLocal<τ_0_0>) -> Builtin.RawPointer // user: %11
  // function_ref swift_task_localValuePush
  %10 = function_ref @swift_task_localValuePush : $@convention(thin) <τ_0_0> (Builtin.RawPointer, @in τ_0_0) -> () // user: %11
  %11 = apply %10<Value>(%9, %1) : $@convention(thin) <τ_0_0> (Builtin.RawPointer, @in τ_0_0) -> ()
```

The argument `%1` is forwarded into the apply of `swift_task_localValuePush`.

rdar://112898559
2023-07-26 16:16:55 -07:00
Erik Eckstein
a3822cd2c5 IRGen: fix a problem with 24-bit enum payloads in statically initialized global variables
IRGen crashed in case an enum, which has a 24 bit payload (e.g. three `UInt8`), is used as a payload of another enum, e.g. `Optional`, in a statically initialized global variable.

rdar://112823823
2023-07-26 15:36:31 +02:00
Pavel Yaskevich
33a37b9516 Merge pull request #67377 from xedin/rdar-112090069
[CSSimplify] Extend same-shape detection to account for pack archetypes
2023-07-24 10:01:29 -07: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
Pavel Yaskevich
5a5edcafc3 [CSSimplify] Extend same-shape detection to account for pack archetypes
`same-shape` mismatch detection logic shouldn't expect that types are
always packs because they could be either invalid (i.e. Void) or pack
archetypes too.

Resolves: rdar://112090069
2023-07-20 22:50:22 -07:00
Holly Borla
43c300408b [NFC] Update additional parameter pack tests. 2023-07-20 15:36:20 -07:00
Slava Pestov
9e73dad311 Merge pull request #67342 from slavapestov/open-type-workaround
Sema: Workaround for issue in ConstraintSystem::openType()
2023-07-19 07:49:45 -04:00
Slava Pestov
e0a1a11a6b SIL: Fix substituted function type visitor for PackExpansionType with concrete pattern type
If the pattern doesn't have any pack parameters in it anymore,
we need to recover the substituted count type from the original
count type.

Fixes rdar://problem/112065340.
2023-07-18 12:19:22 -04:00
Slava Pestov
415b70584a Sema: Workaround for issue in ConstraintSystem::openType() 2023-07-17 15:33:34 -04: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
Slava Pestov
aa026f4d06 Merge pull request #67266 from slavapestov/transform-type-parameter-packs
Fix various places where we didn't handle "bound" pack references correctly
2023-07-13 08:09:04 -04:00
Slava Pestov
e6253b282a AST: Re-implement mapPackTypeIntoElementContext() in terms of mapContextualPackTypeIntoElementContext() 2023-07-12 18:02:14 -04: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
Tim Kientzle
a897fcb47c Correctly project enums with zero-sized payloads
I earlier overhauled the enum layout logic to correctly consider
enums with generic cases and cases that have zero size.
This updates the enum projection logic to use that information
as well.

In particular, this fixes a bug where an MPE with zero-sized cases
would be incorrectly projected by RemoteMirror (with consequences
for the `leaks` tool and lldb).

Resolves rdar://111705059
2023-07-12 08:46:32 -07:00
Alex Hoppen
4f5743c8c6 [IDE] Adjust more test cases 2023-07-07 19:51:01 +02:00
Alex Hoppen
c7e0bfae02 [IDE] Adjust test cases for migrating all completion kinds to solver-based 2023-07-07 19:51:01 +02:00
Alex Hoppen
928a03a2e0 [CodeCompletion] Migrate conforming methods list to solver-based 2023-07-07 19:51:01 +02:00
Alex Hoppen
00eaed3af9 [CodeCompletion] Migrate postfix expr completion to solver-based 2023-07-07 19:51:01 +02:00
Alex Hoppen
4c186c0a9a [CodeCompletion] Fix code completion issues related to type checking tap expressions in the cosntraint system 2023-07-07 19:50:46 +02:00
Eric Miotto
266c00d285 Skip build system tests when targeting remote executors
These will be still exercised when targeting macOS, Linux and Windows.

Addresses rdar://111854328
2023-07-06 09:50:02 -07:00