Commit Graph

20496 Commits

Author SHA1 Message Date
Doug Gregor
94a2529609 Teach diagnostic about non-Sendable global lets to respect @preconcurrency
The diagnostic for non-Sendable globa/static `let` properties was checking
for a Sendable conformance without considering `@preconcurrency`. Emit
this diagnostic via a `@preconcurrency`-sensitive path.

Fixes rdar://121889248.
2024-05-16 11:24:22 -07:00
Doug Gregor
f2610cf236 Merge pull request #73609 from DougGregor/instance-let-not-inout-in-initializer 2024-05-16 06:43:46 -07:00
Slava Pestov
ff6cdeb881 Merge pull request #73625 from slavapestov/sil-cloner-local-archetypes-fix
Redo handling of local archetypes in SILCloner
2024-05-15 22:04:19 -04:00
Rintaro Ishizaki
79a7410206 [CodeCompletion] Remove CrossActorReference diagnostics too
Same for 'async in non-concurrency' context
2024-05-15 15:10:03 -07:00
Slava Pestov
2a82dda217 AST: Remove QueryTypeSubstitutionMapOrIdentity 2024-05-15 17:39:00 -04:00
Rintaro Ishizaki
39d633f5a8 [CodeCompletion] Remove unused 'isAsync' flag from CodeCompletionResult 2024-05-15 13:43:19 -07:00
Steven Wu
cf8187a4fe [ScanDependency] Pass crossimport overlay file to swift-frontend
Teach dependency scanner to pass cross import overlay file to
swift-frontend for main module compilation. This allows swift-frontend
not to repeat the file system search for overlay files when loading
modules.

This also fixes the issue when caching is enabled, the cross import
doesn't work when the first module is a clang module because the module
built with caching using clang include tree does not preserve
DefinitionLoc which is used to inferred the modulemap location for cross
import overlay search.

rdar://127844120
2024-05-14 15:24:35 -07:00
Doug Gregor
b641c54ee2 Generalize AbstractStorageDecl::isSettable() to return a three-state value
This operation determines whether a particular storage declaration,
when accessed from a particular location, is mutable or not. It has a
particular semantic that `let` declarations, when accessed from an
initializer, are considered mutable even though they can only be
assigned. There is similar logic for init accessors.

Tease apart "truly mutable" from "initializable because we're in an
initializer", introducing AbstractStorageDecl::mutability() to
represent all three states. isSettable() remains available as a thin
shim over mutability() and all clients are unchanged thus far, making
this a no-op refactoring.
2024-05-14 14:35:11 -07:00
Slava Pestov
77f948671c AST: Add SubstitutionMap::hasOpaqueArchetypes() 2024-05-14 13:50:35 -04:00
Joe Groff
10f9289ef8 Enable 'BorrowingSwitch' feature. 2024-05-14 07:31:59 -07:00
Michael Gottesman
4789cc7e55 Merge pull request #73556 from gottesmm/rdar127295657_127844737
[region-isolation] When inferring isolation for an argument, handle non-self isolated parameters as well as self parameters that are actor isolated.
2024-05-13 11:18:51 -07:00
Slava Pestov
6df0de5ba9 Merge pull request #73570 from slavapestov/pack-expansion-closures-part-4
Allow local archetypes in interface types of local declarations
2024-05-10 22:00:43 -04:00
Michael Gottesman
5e6b247e09 [ast] Move ActorIsolation::dump out of line so we don't call print in a header.
This works around a layering violation where libSwiftBasic includes parts of the
AST even though it shouldn't.
2024-05-10 16:15:22 -07:00
Michael Gottesman
085f3d745e [region-isolation] Return the old way of printing ActorIsolation for use when printing SIL instructions. 2024-05-10 15:59:25 -07:00
Michael Gottesman
9bfb3b7ee7 [region-isolation] Some small gardening updates in preparation for the next commit.
Specifically, I added a few helper methods and improved the logging printing.
This all makes the next commit a more focused commit.
2024-05-10 15:33:44 -07:00
Slava Pestov
7e36060331 AST: Remove VarDecl::getOpenedElementEnvironment() 2024-05-10 17:21:17 -04:00
Kshitij Jain
01654fd323 Merge pull request #71775 from jkshtj/main
[Autodiff] Adds part of the Autodiff specific closure-specialization optimization pass
2024-05-10 08:51:01 -07:00
Egor Zhdan
796ae1d5f4 Merge pull request #73510 from apple/egorzhdan/macro-name-collision
[cxx-interop][SwiftToCxx] Do not crash while trying to expose a macro to C++
2024-05-10 12:01:47 +01:00
Augusto Noronha
db1c721b99 Merge pull request #73499 from augusto2112/nullptr-source-lock
Add nullptr check in maybeExtractNearestSourceLoc
2024-05-09 17:31:13 -07:00
Slava Pestov
db54207d05 AST: Introduce TypeBase::hasPrimaryArchetype()
The existing hasArchetype() is now deprecated. It is equivalent to:

    hasPrimaryArchetype() || hasLocalArchetype()

Callers should be changed to check one or both of the above predicates
in the most precise way possible.
2024-05-09 17:02:32 -04:00
Augusto Noronha
b7bc8722dc Add nullptr check in maybeExtractNearestSourceLoc
For templated types which are pointers, check if the pointer is null in
maybeExtractNearestSourceLoc.

rdar://127251788
2024-05-09 09:50:10 -07:00
Saleem Abdulrasool
b2bc7a0090 Merge pull request #73518 from z2oh/z2oh/fix-windows-search-path-options
Switch Windows search path options to std::string
2024-05-09 23:51:17 +09:00
nate-chandler
387e8d3ff1 Merge pull request #73516 from nate-chandler/rdar127755503
[BitwiseCopyable] Avoid a condfail.
2024-05-09 07:00:01 -07:00
Stephen Canon
396b055369 Implement Builtin.freeze for integer and integer-vector types. (#73519)
* Implement Builtin.freeze for integer and integer-vector types.

https://llvm.org/docs/LangRef.html#freeze-instruction

> If the argument is undef or poison, ‘freeze’ returns an arbitrary, but fixed, value of type ‘ty’. Otherwise, this instruction is a no-op and returns the input argument. All uses of a value returned by the same ‘freeze’ instruction are guaranteed to always observe the same value, while different ‘freeze’ instructions may yield different values.

It's most importation for integer and integer-vector types because floating-point results are generally not poison (except in the case of conversion from poison integer values).
However, we might want to implement this for other types as well in the future.

* Make builtin.freeze TrivialUse

Also fix filecheck patterns for its test to work with asserts build.
2024-05-09 06:41:02 -04:00
Alexis Laferrière
d63d6c8f7a Merge pull request #73498 from xymus/missing-import-package
Sema: Report references to missing imports from package extensions through typealiases
2024-05-08 18:07:34 -07:00
Nate Chandler
2671652085 [BitwiseCopyable] Avoid a condfail.
The standard library defines
```
protocol BitwiseCopyable {}
typealias _BitwiseCopyable = BitwiseCopyable
```
For current compilers, `BitwiseCopyable` is a "known protocol".

For older compilers, it is not; instead `_BitwiseCopyable` is.  So
print the following into the swiftinterface for those older compilers:
```
protocol _BitwiseCopyable {}
typealias BitwiseCopyable = _BitwiseCopyable
```

rdar://127755503
2024-05-08 16:53:14 -07:00
Jeremy Day
7c640931eb Switch Windows search path options to std::string
A CompilerInvocation object may outlive the input argument list, so we need to copy these argument strings to avoid a use-after-free
2024-05-08 09:46:38 -07:00
Egor Zhdan
f42609b7bd [cxx-interop][SwiftToCxx] Do not crash while trying to expose a macro to C++
This fixes a compiler crash that happened when emitting a Clang header for a Swift module that declares multiple macros with the same base name and different argument names.

Swift macros are not currently designed to be exposed to C++. This teaches the compiler to explicitly mark them as unavailable in C++.

rdar://117969472 / resolves https://github.com/apple/swift/issues/69656
2024-05-08 16:08:02 +01:00
Alexis Laferrière
12f7abcef6 Sema: Report references to missing imports from package extensions 2024-05-07 15:26:51 -07:00
Holly Borla
e7db0ec8f8 Merge pull request #73472 from hborla/exhaustive-switch-error
[Sema] Non-exhaustive switch statements are always an error in Swift 6.
2024-05-07 09:03:40 -07:00
Slava Pestov
3aa133fc66 Merge pull request #70575 from calda/cal--fix-70089
[SE-0365] Fix issue where implicit self was unexpectedly disallowed in nested closures
2024-05-07 11:37:21 -04:00
Holly Borla
910bc35e85 [Sema] Non-exhaustive switch statements are always an error in Swift 6. 2024-05-06 20:56:20 -07:00
Michael Gottesman
f64f2529fb [region-isolation] Some more diagnostic wordsmithing.
rdar://127580781
2024-05-06 19:20:07 -07:00
Michael Gottesman
e4db879112 [region-isolation] Some more diagnostic wordsmithing.
rdar://127580781
2024-05-06 12:09:10 -07:00
nate-chandler
bf6058b142 Merge pull request #73443 from nate-chandler/rdar127516085
[AST] Remove Builtin.copy.
2024-05-06 12:08:31 -07:00
Michael Gottesman
6a53e9a3f4 Merge pull request #73446 from gottesmm/rdar127580781
[region-isolation] Some diagnostic tweaks
2024-05-05 22:21:36 -07:00
Michael Gottesman
f02172a323 [region-isolation] Change terminology to use the term 'risk' instead of could. 2024-05-05 18:01:05 -07:00
Michael Gottesman
a933c14b77 [region-isolation] Only print the type of region that a value is in if it is not disconnected.
Just another diagnostic tweak.
2024-05-05 18:01:05 -07:00
Michael Gottesman
0b761109e2 [region-isolation] If we can infer the callee's name, use that instead of just saying 'callee'.
I also wordsmithed the error message to use the term 'risk' instead of less
negative terms.
2024-05-05 18:01:05 -07:00
Michael Gottesman
699692bd39 [region-isolation] Change diagnostics from using the term transferring -> sending.
rdar://127580781
2024-05-05 18:00:54 -07:00
Cal Stephens
b525b9c7da Merge tag 'swift-DEVELOPMENT-SNAPSHOT-2024-05-01-a' of github.com:apple/swift into cal--fix-70089
Tag build swift-DEVELOPMENT-SNAPSHOT-2024-05-01-a
2024-05-04 12:19:16 -07:00
Nate Chandler
c10d39e35f [AST] Remove Builtin.copy.
A vestigial remnant of it was left behind after
06921cfe84 in order to avoid a reverse
condfail when building old swiftinterfaces that define

```swift
func _copy<T>(_ value: T) -> T {
  #if $BuiltinCopy
    Builtin.copy(value)
  #else
    value
  #endif
}
```

If the language feature is removed, though, such interfaces should again
be buildable because the branch where the language feature isn't defined
should be expanded.

rdar://127516085
2024-05-04 11:35:17 -07:00
nate-chandler
bcd08c0c9a Merge pull request #73235 from nate-chandler/bitwise-copyable/enable
[BitwiseCopyable] Promote to feature.
2024-05-04 10:16:40 -07:00
nate-chandler
768b3a4944 Merge pull request #73422 from nate-chandler/rdar127502242
[SIL] Hollow out Builtin.copy and deprecate _copy.
2024-05-03 22:19:47 -07:00
Nate Chandler
06921cfe84 [SIL] Hollow out Builtin.copy, deprecate _copy.
The copy operator has been implemented and doesn't use it.  Remove
`Builtin.copy` and `_copy` as much as currently possible.

Source compatibility requires that `_copy` remain in the stdlib.  It is
deprecated here and just uses the copy operator.

Handling old swiftinterfaces requires that `Builtin.copy` be defined.
Redefine it here as a passthrough--SILGen machinery will produce the
necessary copy_addr.

rdar://127502242
2024-05-03 15:56:25 -07:00
Ellie Shin
1c012c88ab Merge pull request #73161 from apple/elsh/pkg-export
[Sema] Handle package exportability.
2024-05-03 14:48:03 -07:00
Artem Chikin
279f3d1c6f Merge pull request #73374 from apple/revert-73234-revert-72932-UseClangStatCacheForScanningFS
Revert "Revert "[Dependency Scanning] Use a standalone `DependencyScanningFilesystem`on the scanner, sharing a common `status` cache from Clang's dependency service cache""
2024-05-03 11:40:27 -07:00
li3zhen1
b82fb851f9 [ParseDecl] Disallow init accessor decl outside of primary declaration 2024-05-02 20:48:29 -07:00
Kshitij
fd609846ae Makes the swift-based closure-spec pass an experimental frontend feature 2024-05-02 09:14:05 -07:00
Daniel Grumberg
cffb637f2d Merge pull request #73080 from daniel-grumberg/export-import-sgf-extract
[SymbolGraphGen] Correctly handle exported imports in swift-symbolgraph-extract
2024-05-02 15:39:26 +01:00