Skip to content

Commit 04f5f33

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents 4e32b60 + f65d41e commit 04f5f33

File tree

947 files changed

+30483
-13913
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

947 files changed

+30483
-13913
lines changed

.github/CODEOWNERS

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
/include/swift/AST/Evaluator* @CodaFi @slavapestov
7171
/include/swift/Basic/ @DougGregor
7272
/include/swift/Basic/Features.def @DougGregor @hborla
73-
/include/swift/ClangImporter @zoecarver @hyp @egorzhdan @beccadax @ian-twilightcoder
73+
/include/swift/ClangImporter @zoecarver @hyp @egorzhdan @beccadax @ian-twilightcoder @Xazax-hun
7474
/include/swift/DependencyScan @artemcm
7575
/include/swift/Driver*/ @artemcm
7676
/include/swift/Frontend*/ @artemcm @tshortli
@@ -81,7 +81,7 @@
8181
/include/swift/Migrator/ @nkcsgexi
8282
/include/swift/Option/*Options* @tshortli
8383
/include/swift/Parse/ @ahoppen @bnbarham @CodaFi @DougGregor @hamishknight @rintaro
84-
/include/swift/PrintAsClang @zoecarver @hyp @egorzhdan
84+
/include/swift/PrintAsClang @zoecarver @hyp @egorzhdan @Xazax-hun
8585
/include/swift/Refactoring @ahoppen @bnbarham @hamishknight @rintaro
8686
/include/swift/Runtime/ @rjmccall
8787
/include/swift/SIL/ @jckarter
@@ -116,7 +116,7 @@
116116
/lib/ASTGen/ @ahoppen @bnbarham @CodaFi @hamishknight @rintaro
117117
/lib/Basic/ @DougGregor
118118
/lib/Basic/Windows @compnerd
119-
/lib/ClangImporter @zoecarver @hyp @egorzhdan @beccadax @ian-twilightcoder
119+
/lib/ClangImporter @zoecarver @hyp @egorzhdan @beccadax @ian-twilightcoder @Xazax-hun
120120
/lib/ClangImporter/DWARFImporter* @adrian-prantl
121121
/lib/DependencyScan @artemcm
122122
/lib/Driver*/ @artemcm
@@ -135,7 +135,7 @@
135135
/lib/Markup/ @nkcsgexi
136136
/lib/Migrator/ @nkcsgexi
137137
/lib/Parse/ @ahoppen @bnbarham @CodaFi @DougGregor @hamishknight @rintaro
138-
/lib/PrintAsClang @zoecarver @hyp @egorzhdan
138+
/lib/PrintAsClang @zoecarver @hyp @egorzhdan @Xazax-hun
139139
/lib/Refactoring/ @ahoppen @bnbarham @hamishknight @rintaro
140140
/lib/SIL/ @jckarter
141141
/lib/SIL/**/*DebugInfo* @adrian-prantl
@@ -177,7 +177,7 @@
177177
/stdlib/public/*Demangl*/ @rjmccall
178178
/stdlib/public/Backtracing/ @al45tair
179179
/stdlib/public/Concurrency/ @ktoso
180-
/stdlib/public/Cxx/ @zoecarver @hyp @egorzhdan
180+
/stdlib/public/Cxx/ @zoecarver @hyp @egorzhdan @Xazax-hun
181181
/stdlib/public/Distributed/ @ktoso
182182
/stdlib/public/Observation/ @phausler
183183
/stdlib/public/SwiftRemoteMirror/ @slavapestov
@@ -202,7 +202,7 @@
202202
/test/IDE/ @ahoppen @bnbarham @hamishknight @rintaro
203203
/test/IRGen/ @rjmccall
204204
/test/Index/ @ahoppen @bnbarham @hamishknight @rintaro
205-
/test/Interop/ @zoecarver @hyp @egorzhdan
205+
/test/Interop/ @zoecarver @hyp @egorzhdan @Xazax-hun
206206
/test/Migrator/ @nkcsgexi
207207
/test/Parse/ @ahoppen @bnbarham @CodaFi @DougGregor @hamishknight @rintaro
208208
/test/Profiler @ahoppen @bnbarham @hamishknight @rintaro

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@
55
66
## Swift (next)
77

8+
* [SE-0444][]:
9+
When the upcoming feature `MemberImportVisibility` is enabled, Swift will
10+
require that a module be directly imported in a source file when resolving
11+
member declarations from that module:
12+
13+
```swift
14+
let recipe = "2 slices of bread, 1.5 tbs peanut butter".parse()
15+
// error: instance method 'parse()' is inaccessible due to missing import of
16+
// defining module 'RecipeKit'
17+
// note: add import of module 'RecipeKit'
18+
```
19+
20+
This new behavior prevents ambiguities from arising when a transitively
21+
imported module declares a member that conflicts with a member of a directly
22+
imported module.
23+
824
* Syntactic SourceKit queries no longer attempt to provide information
925
within the inactive `#if` regions. For example, given:
1026

@@ -10629,6 +10645,7 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
1062910645
[SE-0428]: https://github.com/apple/swift-evolution/blob/main/proposals/0428-resolve-distributed-actor-protocols.md
1063010646
[SE-0431]: https://github.com/apple/swift-evolution/blob/main/proposals/0431-isolated-any-functions.md
1063110647
[SE-0442]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0442-allow-taskgroup-childtaskresult-type-to-be-inferred.md
10648+
[SE-0444]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0444-member-import-visibility.md
1063210649
[#64927]: <https://github.com/apple/swift/issues/64927>
1063310650
[#42697]: <https://github.com/apple/swift/issues/42697>
1063410651
[#42728]: <https://github.com/apple/swift/issues/42728>

CMakeLists.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ else()
155155
set(SWIFT_HOST_VARIANT_SDK_default "ANDROID")
156156
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
157157
set(SWIFT_HOST_VARIANT_SDK_default "OSX")
158+
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "WASI")
159+
set(SWIFT_HOST_VARIANT_SDK_default "WASI")
158160
else()
159161
message(FATAL_ERROR "Unable to detect SDK for host system: ${CMAKE_SYSTEM_NAME}")
160162
endif()
@@ -419,11 +421,21 @@ set(SWIFT_STDLIB_MSVC_RUNTIME_LIBRARY
419421
${SWIFT_STDLIB_MSVC_RUNTIME_LIBRARY_default}
420422
CACHE STRING "MSVC Runtime Library for the standard library")
421423

424+
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" AND BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS" AND
425+
CMAKE_BUILD_TYPE STREQUAL "Debug")
426+
# Building with the host Swift toolchain requires linking just-built binaries
427+
# against the host Swift runtime. In debug builds, that means linking a debug
428+
# binary against a release binary. The MSVC linker does not normally permit
429+
# this, since debug builds enable bounds-checked C++ iterators by default,
430+
# which are not ABI-compatible with regular iterators. Let's instruct MSVC to
431+
# disable bounds-checked iterators to make it possible to do a debug build of
432+
# the Swift compiler with a host toolchain.
433+
add_definitions(-D_ITERATOR_DEBUG_LEVEL=0)
434+
endif()
422435

423436
if(BRIDGING_MODE STREQUAL "DEFAULT" OR NOT BRIDGING_MODE)
424437
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR "${SWIFT_HOST_VARIANT_SDK}" STREQUAL "WINDOWS" OR (CMAKE_Swift_COMPILER AND CMAKE_Swift_COMPILER_VERSION VERSION_LESS 5.8))
425438
# In debug builds, to workaround a problem with LLDB's `po` command (rdar://115770255).
426-
# On Windows, to workaround a build problem.
427439
# If the host Swift version is less than 5.8, use pure mode to workaround a C++ interop compiler crash.
428440
set(BRIDGING_MODE "PURE")
429441
else()

SwiftCompilerSources/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ function(add_swift_compiler_modules_library name)
177177
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
178178
list(APPEND swift_compile_options "-static")
179179
list(APPEND sdk_option "-sdk" "${SWIFT_PATH_TO_SWIFT_SDK}")
180+
# For "swift/shims/*.h".
181+
list(APPEND sdk_option "-I" "${SWIFT_PATH_TO_SWIFT_SDK}/usr/lib")
180182

181183
# Workaround a crash in the LoadableByAddress pass
182184
# https://github.com/apple/swift/issues/73254
@@ -188,6 +190,12 @@ function(add_swift_compiler_modules_library name)
188190
if (CMAKE_Swift_COMPILER_VERSION VERSION_LESS 6.0)
189191
list(APPEND swift_compile_options "-Xcc" "-D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH")
190192
endif()
193+
194+
# Make 'offsetof()' a const value.
195+
list(APPEND swift_compile_options "-Xcc" "-D_CRT_USE_BUILTIN_OFFSETOF")
196+
197+
# Workaround for https://github.com/swiftlang/llvm-project/issues/7172
198+
list(APPEND swift_compile_options "-Xcc" "-Xclang" "-Xcc" "-fmodule-format=raw")
191199
else()
192200
list(APPEND sdk_option "-I" "${swift_exec_bin_dir}/../lib" "-I" "${sdk_path}/usr/lib")
193201
endif()

SwiftCompilerSources/Package.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ private extension Target {
5858
let package = Package(
5959
name: "SwiftCompilerSources",
6060
platforms: [
61-
// We need at least macOS 13 here to avoid hitting an availability error
62-
// for CxxStdlib. It's only needed for the package though, the CMake build
63-
// works fine with a lower deployment target.
6461
.macOS(.v13),
6562
],
6663
products: [
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# This source file is part of the Swift.org open source project
2+
#
3+
# Copyright (c) 2014 - 2024 Apple Inc. and the Swift project authors
4+
# Licensed under Apache License v2.0 with Runtime Library Exception
5+
#
6+
# See http://swift.org/LICENSE.txt for license information
7+
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
8+
9+
add_swift_compiler_module(AST
10+
DEPENDS
11+
Basic
12+
SOURCES
13+
Declarations.swift
14+
Conformance.swift
15+
Registration.swift
16+
SubstitutionMap.swift
17+
Type.swift)
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
//===--- Conformance.swift ------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2024 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
import Basic
14+
import ASTBridging
15+
16+
/// Describes how a particular type conforms to a given protocol, providing the mapping from the protocol
17+
/// members to the type (or extension) members that provide the functionality for the concrete type.
18+
///
19+
/// TODO: Ideally, `Conformance` should be an enum
20+
public struct Conformance: CustomStringConvertible, NoReflectionChildren {
21+
public let bridged: BridgedConformance
22+
23+
public init(bridged: BridgedConformance) {
24+
self.bridged = bridged
25+
}
26+
27+
public var description: String {
28+
return String(taking: bridged.getDebugDescription())
29+
}
30+
31+
public var isConcrete: Bool { bridged.isConcrete() }
32+
33+
public var isValid: Bool { bridged.isValid() }
34+
35+
public var type: Type {
36+
assert(isConcrete)
37+
return Type(bridged: bridged.getType())
38+
}
39+
40+
public var isSpecialized: Bool {
41+
assert(isConcrete)
42+
return bridged.isSpecializedConformance()
43+
}
44+
45+
public var genericConformance: Conformance {
46+
assert(isSpecialized)
47+
return bridged.getGenericConformance().conformance
48+
}
49+
50+
public var isInherited: Bool {
51+
assert(isConcrete)
52+
return bridged.isInheritedConformance()
53+
}
54+
55+
public var inheritedConformance: Conformance {
56+
assert(isInherited)
57+
return bridged.getInheritedConformance().conformance
58+
}
59+
60+
public var specializedSubstitutions: SubstitutionMap {
61+
assert(isSpecialized)
62+
return SubstitutionMap(bridged: bridged.getSpecializedSubstitutions())
63+
}
64+
}
65+
66+
public struct ConformanceArray : RandomAccessCollection, CustomReflectable {
67+
public let bridged: BridgedConformanceArray
68+
69+
public var startIndex: Int { return 0 }
70+
public var endIndex: Int { return bridged.getCount() }
71+
72+
public init(bridged: BridgedConformanceArray) {
73+
self.bridged = bridged
74+
}
75+
76+
public subscript(_ index: Int) -> Conformance {
77+
bridged.getAt(index).conformance
78+
}
79+
80+
public var customMirror: Mirror {
81+
let c: [Mirror.Child] = map { (label: nil, value: $0) }
82+
return Mirror(self, children: c)
83+
}
84+
}
85+
86+
extension BridgedConformance {
87+
public var conformance: Conformance { Conformance(bridged: self) }
88+
}
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
//===--- Declarations.swift -----------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2024 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
import Basic
14+
import ASTBridging
15+
16+
/// The base class for all declarations in Swift.
17+
@_semantics("arc.immortal")
18+
public class Decl: CustomStringConvertible, Hashable {
19+
public var bridged: BridgedDeclObj { BridgedDeclObj(SwiftObject(self)) }
20+
21+
public var description: String { String(taking: bridged.getDebugDescription()) }
22+
23+
public static func ==(lhs: Decl, rhs: Decl) -> Bool { lhs === rhs }
24+
25+
public func hash(into hasher: inout Hasher) {
26+
hasher.combine(ObjectIdentifier(self))
27+
}
28+
}
29+
30+
public class ValueDecl: Decl {
31+
final public var nameLoc: SourceLoc? { SourceLoc(bridged: bridged.Value_getNameLoc()) }
32+
final public var userFacingName: StringRef { StringRef(bridged: bridged.Value_getUserFacingName()) }
33+
final public var isObjC: Bool { bridged.Value_isObjC() }
34+
}
35+
36+
public class TypeDecl: ValueDecl {
37+
final public var name: StringRef { StringRef(bridged: bridged.Type_getName()) }
38+
}
39+
40+
public class GenericTypeDecl: TypeDecl {
41+
final public var isGenericAtAnyLevel: Bool { bridged.GenericType_isGenericAtAnyLevel() }
42+
}
43+
44+
public class NominalTypeDecl: GenericTypeDecl {
45+
final public var isGlobalActor: Bool { bridged.NominalType_isGlobalActor() }
46+
47+
final public var valueTypeDestructor: DestructorDecl? {
48+
bridged.NominalType_getValueTypeDestructor().getAs(DestructorDecl.self)
49+
}
50+
}
51+
52+
final public class EnumDecl: NominalTypeDecl {}
53+
54+
final public class StructDecl: NominalTypeDecl {
55+
public var hasUnreferenceableStorage: Bool { bridged.Struct_hasUnreferenceableStorage() }
56+
}
57+
58+
final public class ClassDecl: NominalTypeDecl {
59+
public var superClass: Type? { Type(bridgedOrNil: bridged.Class_getSuperclass()) }
60+
}
61+
62+
final public class ProtocolDecl: NominalTypeDecl {}
63+
64+
final public class BuiltinTupleDecl: NominalTypeDecl {}
65+
66+
final public class OpaqueTypeDecl: GenericTypeDecl {}
67+
68+
final public class TypeAliasDecl: GenericTypeDecl {}
69+
70+
final public class GenericTypeParamDecl: TypeDecl {}
71+
72+
final public class AssociatedTypeDecl: TypeDecl {}
73+
74+
final public class ModuleDecl: TypeDecl {}
75+
76+
public class AbstractStorageDecl: ValueDecl {}
77+
78+
public class VarDecl: AbstractStorageDecl {}
79+
80+
final public class ParamDecl: VarDecl {}
81+
82+
final public class SubscriptDecl: AbstractStorageDecl {}
83+
84+
public class AbstractFunctionDecl: ValueDecl {}
85+
86+
final public class ConstructorDecl: AbstractFunctionDecl {}
87+
88+
final public class DestructorDecl: AbstractFunctionDecl {}
89+
90+
public class FuncDecl: AbstractFunctionDecl {}
91+
92+
final public class AccessorDecl: FuncDecl {}
93+
94+
final public class MacroDecl: ValueDecl {}
95+
96+
final public class EnumElementDecl: ValueDecl {}
97+
98+
final public class ExtensionDecl: Decl {}
99+
100+
final public class TopLevelCodeDecl: Decl {}
101+
102+
final public class ImportDecl: Decl {}
103+
104+
final public class PoundDiagnosticDecl: Decl {}
105+
106+
final public class PrecedenceGroupDecl: Decl {}
107+
108+
final public class MissingDecl: Decl {}
109+
110+
final public class MissingMemberDecl: Decl {}
111+
112+
final public class PatternBindingDecl: Decl {}
113+
114+
final public class EnumCaseDecl: Decl {}
115+
116+
public class OperatorDecl: Decl {}
117+
118+
final public class InfixOperatorDecl: OperatorDecl {}
119+
120+
final public class PrefixOperatorDecl: OperatorDecl {}
121+
122+
final public class PostfixOperatorDecl: OperatorDecl {}
123+
124+
final public class MacroExpansionDecl: Decl {}
125+
126+
// Bridging utilities
127+
128+
extension BridgedDeclObj {
129+
public var decl: Decl { obj.getAs(Decl.self) }
130+
public func getAs<T: Decl>(_ declType: T.Type) -> T { obj.getAs(T.self) }
131+
}
132+
133+
extension OptionalBridgedDeclObj {
134+
public var decl: Decl? { obj.getAs(Decl.self) }
135+
public func getAs<T: Decl>(_ declType: T.Type) -> T? { obj.getAs(T.self) }
136+
}

0 commit comments

Comments
 (0)