Commit Graph

88079 Commits

Author SHA1 Message Date
Rintaro Ishizaki
319b8bd691 [CMake] Fix install for macOS toolchain
recursive-lipo requires shared libraries have +x permissions.
Use PROGRAMS instead of FILES when installing swift-syntax libraries.
2023-08-28 09:53:56 -07:00
Rintaro Ishizaki
757aaa347d [CMake] Set LD_LIBRARY_PATH to builder's runtime when building stdlib
In Linux. Instead of setting temporary "fallback" RUNPATH, Set
LD_LIBRARY_PATH to builder's runtime when building standard library.
So we don't need to strip the temporary RUNPATH when installing.
2023-08-28 01:16:18 +00:00
Rintaro Ishizaki
2a2787b2d0 Avoid adding redundant temporary RUNPATH to builder's stdlib
Many shared libs and executables are only run after stdlib/runtime are
built. They don't need to link with builders stdlib at all.
2023-08-24 23:10:20 +00:00
Rintaro Ishizaki
9c9010e5b7 [CMake] Support Macros in Linux
For compiling codes required for macro support, we now need swiftc
compiler in the build machine.

Unlike Darwin OSes, where swiftCore runtime is guaranteed to be present
in /usr/lib, Linux doesn't have ABI stability and the stdlib of the
build machine is not at the specific location. So the built compiler
cannot relies on the shared object in the toolchain.
2023-08-24 17:04:15 +00:00
Andrew Trick
5dd2cf706a Merge pull request #68110 from atrick/fix-silcombine-moveonly
Fix SILCombine miscompile for discard on non-copyable types
2023-08-24 08:48:55 -07:00
nate-chandler
3687ddfac6 Merge pull request #68090 from nate-chandler/rdar114323803
[CopyPropagation] Don't try to delete owned values on which canonicalization bails.
2023-08-24 07:03:06 -07:00
nate-chandler
89ef8cd080 Merge pull request #68108 from nate-chandler/rdar114351349
[InstructionDeleter] Don't delete-as dead instructions which produce owned move-only values.
2023-08-24 07:00:57 -07:00
swift-ci
b10560f3f6 Merge pull request #68113 from nate-chandler/gardening/20230823/1
[Gardening] Removed stray comment.
2023-08-23 23:50:09 -07:00
Allan Shortlidge
e3bf6bdf0e Merge pull request #68112 from tshortli/enum-equatable-all-elements-unavailable
Sema: Set type on pattern in synthesized enum equatable/hashable conformance
2023-08-23 22:40:49 -07:00
Nate Chandler
91159ae217 [Gardening] Removed stray comment. 2023-08-23 21:01:58 -07:00
Allan Shortlidge
d47a9c6ee9 Sema: Set type on pattern in synthesized enum equatable/hashable conformance.
Fixes a regression caused by https://github.com/apple/swift/pull/67636 in which
the patterns for case statements generated to match unavailable enum elements
were missing a type. The missing type caused a crash during SILGen if the
unavailable element case was the first one in the swtich statement.

Resolves rdar://113761850
2023-08-23 18:08:49 -07:00
Nate Chandler
073f4e21f3 [InstDeleter] Keep dead owned move-only values.
Deleting instructions which produce such values could result in
shortening the lifetime of a move-only value.  This is illegal because
according to language rules, the lifetime of move-only values is fixed.

rdar://114351349
2023-08-23 17:24:21 -07:00
Andrew Trick
a946922798 Fix SILCombine miscompile for discard on non-copyable types
Fixes rdar://113214179 (Raw layout types don't adhere to discard self)

// swift-frontend ./rawdeinit.swift -enable-experimental-feature RawLayout \
// -enable-builtin-module -emit-sil -o rawdeinit.sil

import Builtin

@_rawLayout(like: T)
public struct Cell<T>: ~Copyable {
  var ptr: UnsafeMutablePointer<T> {
    .init(Builtin.unprotectedAddressOfBorrow(self))
  }

  init(_ initialValue: T) {
    ptr.initialize(to: initialValue)
  }

  deinit {
    ptr.deinitialize(count: 1)
  }

  public consuming func get() -> T {
    let value = ptr.move()
    discard self // SILCombine inserts a destroy of self here
    return value
  }
}
2023-08-23 17:07:07 -07:00
nate-chandler
49865f2ec6 Merge pull request #68054 from nate-chandler/opaque-values/20230821/2/closures
[OpaqueValues] Fix closure handling.
2023-08-23 15:44:47 -07:00
Doug Gregor
fc8da01c05 Merge pull request #68087 from DougGregor/accessor-macro-single-binding-restriction
Ban the use of accessor macros on bindings with multiple variables in a single binding
2023-08-23 13:50:49 -07:00
swift-ci
92de4d9a98 Merge pull request #68095 from apple/revert-67155-use_clang_arc_attachedcall
Revert "Use clang.arc.attachedcall for emission of objc_retainAutoreleasedReturnValue"
2023-08-23 12:31:41 -07:00
Nate Chandler
a67c22d905 [CopyPropagation] Only delete if canonicalized.
Owned lifetime canonicalization bails on move-only values.

Previously, though, every value that was fed to canonicalization was
then attempted to be deleted.  For dead move-only values, the result
could be to shorten move-only lifetimes, which is illegal per language
rules.

Here, this is fixed by not attempting to delete owned values for which
canonicalization bailed.

rdar://114323803
2023-08-23 11:42:57 -07:00
eeckstein
b6ed12715e Merge pull request #68084 from eeckstein/fix-memory-lifetime-verifier
MemoryLifetimeVerifier: relax the check for trivial enums a bit
2023-08-23 19:42:20 +02:00
nate-chandler
c3b8091815 Revert "Use clang.arc.attachedcall for emission of objc_retainAutoreleasedReturnValue" 2023-08-23 10:11:35 -07:00
Artem Chikin
352632bc9b Merge pull request #68071 from artemcm/AllowScanningCrossImportOverlays
[Dependency Scanning] Avoid adding a cross-import-overlay dependency when  scanning the cross-import overlay module itself.
2023-08-23 08:40:06 -07:00
Doug Gregor
10a5cc991c Merge pull request #68085 from DougGregor/macro-expansion-with-operators 2023-08-23 08:11:30 -07:00
nate-chandler
309a147d80 Merge pull request #68076 from nate-chandler/opaque-values/20230822/2/consume-addronly-var
[OpaqueValues] Consume addr-only vars as loadable.
2023-08-23 07:07:14 -07:00
Doug Gregor
8ed1853b61 Ban the use of accessor macros on bindings with multiple variables
As with property wrappers, we can't properly desugar the application of
accessor macros to bindings with multiple variables. Prohibit them up
front.

Fixes rdar://112783811.
2023-08-23 06:24:48 -07:00
Holly Borla
d4f3bc6cd3 Merge pull request #68081 from hborla/sendable-self-in-reference 2023-08-23 06:13:38 -07:00
Doug Gregor
8371d3b517 [Macros] Ensure that we find operators in any macro-expanded context.
In any nominal declaration or extension thereof that is produced by a
macro expansion, make sure we perform qualified name lookup when
resolving operators so that we're guaranteed to find the
macro-introduced operators. Otherwise, expanding a macro that defines
a new type with conformances involving operators doesn't work.

Fixes rdar://114257019,
2023-08-23 04:54:56 -07:00
Luciano Almeida
c48836cb62 Merge pull request #68073 from apple/remove-diags
Removing code for 'initializes' and 'accesses' attributes old syntax
2023-08-23 08:50:49 -03:00
Erik Eckstein
bad87c4c1e MemoryLifetimeVerifier: relax the check for trivial enums a bit
Trivial enum cases in a memory location don't need to be destroyed.
Don't require that the store to such a memory location is statically known as a trivial enum case.
Instead just require that it's below a switch_enum successor for a trivial case.

Fixes a false alarm.

rdar://114274714
2023-08-23 12:48:46 +02: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
Pavel Yaskevich
a7f9182d28 Merge pull request #68048 from amritpan/kp-refs
[ConstraintSystem] Handle incorrect key path member references earlier
2023-08-22 18:01:20 -07:00
Nate Chandler
49e76caca5 [OpaqueValues] Consume addr-only vars as loadable. 2023-08-22 17:41:15 -07:00
Artem Chikin
2dda2576b5 Merge pull request #68053 from artemcm/AvailabilityRenameLookThroughFunctionConversions
Look through function conversion expressions when querying the called function decl of a deprecated-renamed API in order to emit a fix-it
2023-08-22 17:11:06 -07:00
Luciano Almeida
499547a3b8 [Serialization] Remove serialization code for initializes() and accesses() attributes 2023-08-22 20:57:30 -03:00
Luciano Almeida
e88012488c [Sema] Remove type check verification for initializes and accesses attr 2023-08-22 20:56:39 -03:00
Luciano Almeida
4c24384f5f [Parse] Remove initializes and accesses attr parse code 2023-08-22 20:55:30 -03:00
Luciano Almeida
76becb4cd0 [AST] Remove initializes and accesses attr reference 2023-08-22 20:54:37 -03:00
nate-chandler
c16bbd9666 Merge pull request #68064 from nate-chandler/opaque-values/20230822/1/consume-addronly
[OpaqueValues] Emit consume expr for addr-only as loadable.
2023-08-22 16:53:06 -07:00
Artem Chikin
475fc6a74d [Dependency Scanning] Avoid adding a cross-import-overlay dependency when
scanning the cross-import overlay module itself.

Resolves rdar://114265603
2023-08-22 16:39:19 -07:00
Doug Gregor
221e0e0627 Merge pull request #68059 from DougGregor/module-interface-print-freestanding-macro-expansion
[Swift interface] Print declarations produced by declaration macro expansion
2023-08-22 13:42:00 -07:00
Pavel Yaskevich
4ad33bfe97 Merge pull request #67721 from xedin/rdar-112153201
[CodeSynthesis] Make sure that init synthesis expands macros
2023-08-22 11:31:53 -07:00
Nate Chandler
8c48ca2e8c [OpaqueValues] Addr-only consumes emit loadably. 2023-08-22 11:18:44 -07:00
Doug Gregor
e7a5887fec Merge pull request #68057 from DougGregor/fileprivate-extension-macros 2023-08-22 09:13:02 -07:00
Artem Chikin
2910e87787 Look through function conversion expressions when querying the called function
decl of a deprecated-renamed API in order to emit a fix-it

Resolves rdar://113768664
2023-08-22 08:58:39 -07:00
Nate Chandler
ff302212a0 [OpaqueValues] Fix closure handling.
Rewrote and tested all currently emittable variations of closure
handling for opaque values.
2023-08-22 07:48:39 -07:00
Slava Pestov
15c4822495 Merge pull request #68055 from slavapestov/rdar113943346
RequirementMachine: Fix potential 'pollution' from installing an invalid requirement machine
2023-08-22 08:56:04 -04:00
Doug Gregor
ff8a1be972 [Swift interface] Print declarations produced by declaration macro expansion
Don't print the uses of freestanding declaration macros in Swift
interfaces. Instead, print the declarations they produce, as
appropriate.

Fixes rdar://113730928.
2023-08-21 23:31:47 -07:00
Doug Gregor
323561b157 [Macros] Use outermost source file for establishing (file)private access scope
Fixes rdar://114048069.
2023-08-21 22:01:19 -07:00
nate-chandler
1f05436a99 Merge pull request #68049 from nate-chandler/opaque-values/20230821/1/all-local-archetypes
[AddressLowering] Consider opening instructions of all local archetypes.
2023-08-21 20:55:25 -07:00
Slava Pestov
595a7a530b RequirementMachine: Fix potential 'pollution' from installing an invalid requirement machine
If the substitution terms of a concrete type symbol contain unresolved
name symbols, we have an invalid requirement that is dropped from the
minimized signature. In this case, the rewrite system used for minimization
cannot be installed as the official rewrite system for this generic
signature, because building a rewrite system from the signature will
produce a different result.

This might be the cause of the crash in rdar://114111159.
2023-08-21 23:36:37 -04:00
Nate Chandler
dade867b98 [OpaqueValues] Types with packs remain indirect.
For now, always use indirect convention for types with packs.  This is
motivated by the fact that getting from/setting to a pack currently
requires addresses which aren't materialized for tuples.  In the
fullness of time, these values should be direct in opaque values mode,
but for now it can be postponed.
2023-08-21 20:33:37 -07:00
Pavel Yaskevich
a0573e0219 [CodeSynthesis] Make sure that init synthesis expands macros
Previously both `AreAllStoredPropertiesDefaultInitableRequest`
and `HasMemberwiseInitRequest` checked only "current" properties
of the type but macro expansions can add new stored and/or
init accessor properties that affect this logic so we need to
make sure that macro expansions happen and new properties are
accounted for.

Note that the original idea was to use `getStoredProperties()`
but that runs into multiple circularity issues related to lazy
properties.

Resolves: rdar://112153201
2023-08-21 18:03:01 -07:00