Skip to content

Commit b8dbae3

Browse files
Merge branch 'main' into filter-method-for-std-map
2 parents 8e5c234 + 2b6b3fd commit b8dbae3

File tree

1,420 files changed

+35431
-38490
lines changed

Some content is hidden

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

1,420 files changed

+35431
-38490
lines changed

.clang-tidy

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# See https://clang.llvm.org/extra/clang-tidy/checks/list.html
2+
3+
Checks: '
4+
-*,
5+
llvm-*,
6+
misc-*,
7+
-misc-const-correctness,
8+
-misc-unused-parameters,
9+
-misc-non-private-member-variables-in-classes,
10+
-misc-no-recursion,
11+
-misc-use-anonymous-namespace,
12+
-readability-qualified-auto,
13+
-llvm-qualified-auto
14+
'

.github/CODEOWNERS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
# order.
88

99
# TODO: /.clang-format
10+
11+
/.clang-tidy @egorzhdan
12+
1013
# TODO: /.dir-locals.el
1114
# TODO: /.flake8
1215
# TODO: /.gitattributes
@@ -65,6 +68,7 @@
6568
/include/swift/IDE/ @ahoppen @bnbarham @rintaro @hamishknight
6669
/include/swift/Index/ @bnbarham
6770
/include/swift/Refactoring @ahoppen @bnbarham
71+
/include/swift/Option/*Options* @tshortli
6872
/include/swift/Parse/ @ahoppen @bnbarham @CodaFi @DougGregor @rintaro
6973
/include/swift/PrintAsClang @zoecarver @hyp @egorzhdan
7074
# TODO: /include/swift/SIL/

CMakeLists.txt

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ enable_language(CXX)
5050
set(SWIFT_ASM_DIALECT ASM)
5151
set(SWIFT_ASM_EXT S)
5252
set(SWIFT_ASM_AVAILABLE YES)
53-
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
53+
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
5454
if(CMAKE_SYSTEM_PROCESSOR MATCHES "ARM64")
5555
if(CMAKE_VERSION VERSION_LESS "3.26")
56-
message(warning "We can't build assembly language for ARM64 until CMake 3.26")
56+
message(WARNING "We can't build assembly language for ARM64 until CMake 3.26")
5757
set(SWIFT_ASM_AVAILABLE NO)
5858
else()
5959
set(SWIFT_ASM_DIALECT ASM_MARMASM)
@@ -158,7 +158,7 @@ else()
158158
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64|amd64")
159159
set(SWIFT_HOST_VARIANT_ARCH_default "x86_64")
160160
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|ARM64|arm64")
161-
if(SWIFT_HOST_VARIANT_SDK_default STREQUAL OSX)
161+
if(SWIFT_HOST_VARIANT_SDK_default STREQUAL "OSX")
162162
set(SWIFT_HOST_VARIANT_ARCH_default "arm64")
163163
else()
164164
set(SWIFT_HOST_VARIANT_ARCH_default "aarch64")
@@ -380,7 +380,7 @@ set(SWIFT_STDLIB_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
380380
# - MultiThreadedDebug (/MTd)
381381
# - MultiThreadedDLL (/MD)
382382
# - MultiThreadedDebugDLL (/MDd)
383-
if(CMAKE_BUILD_TYPE STREQUAL Debug)
383+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
384384
set(SWIFT_STDLIB_MSVC_RUNTIME_LIBRARY_default MultiThreadedDebugDLL)
385385
else()
386386
set(SWIFT_STDLIB_MSVC_RUNTIME_LIBRARY_default MultiThreadedDLL)
@@ -675,7 +675,7 @@ if(SWIFT_BUILT_STANDALONE)
675675
project(Swift C CXX ${SWIFT_ASM_DIALECT})
676676
endif()
677677

678-
if(MSVC OR "${CMAKE_SIMULATE_ID}" STREQUAL MSVC)
678+
if(MSVC OR "${CMAKE_SIMULATE_ID}" STREQUAL "MSVC")
679679
include(ClangClCompileRules)
680680
elseif(UNIX)
681681
include(UnixCompileRules)
@@ -697,7 +697,7 @@ if(NOT EXISTS "${SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE}")
697697
endif()
698698

699699
set(SWIFT_BUILD_HOST_DISPATCH FALSE)
700-
if(SWIFT_ENABLE_DISPATCH AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
700+
if(SWIFT_ENABLE_DISPATCH AND NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
701701
# Only build libdispatch for the host if the host tools are being built and
702702
# specifically if these two libraries that depend on it are built.
703703
if(SWIFT_INCLUDE_TOOLS AND SWIFT_BUILD_SOURCEKIT)
@@ -794,6 +794,7 @@ include(SwiftConfigureSDK)
794794
include(SwiftComponents)
795795
include(SwiftList)
796796
include(AddPureSwift)
797+
include(SetRPATH)
797798

798799
# Configure swift include, install, build components.
799800
swift_configure_components()
@@ -883,11 +884,11 @@ endif()
883884
# build environment.
884885
if(LLVM_USE_LINKER)
885886
set(SWIFT_USE_LINKER_default "${LLVM_USE_LINKER}")
886-
elseif(${SWIFT_HOST_VARIANT_SDK} STREQUAL ANDROID)
887+
elseif(SWIFT_HOST_VARIANT_SDK STREQUAL "ANDROID")
887888
set(SWIFT_USE_LINKER_default "lld")
888-
elseif(CMAKE_SYSTEM_NAME STREQUAL Windows AND NOT CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
889+
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows" AND NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
889890
set(SWIFT_USE_LINKER_default "lld")
890-
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
891+
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
891892
set(SWIFT_USE_LINKER_default "")
892893
else()
893894
set(SWIFT_USE_LINKER_default "gold")
@@ -952,6 +953,12 @@ if(SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR)
952953
else()
953954
set(SWIFT_SWIFT_PARSER TRUE)
954955
include(${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_TARGETS})
956+
957+
if(SWIFT_HOST_VARIANT_SDK STREQUAL "LINUX" AND NOT BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS")
958+
# Only "HOSTTOOLS" is supported in Linux when Swift parser integration is enabled.
959+
message(WARNING "Force setting BOOTSTRAPPING=HOSTTOOLS because Swift parser integration is enabled")
960+
set(BOOTSTRAPPING_MODE "HOSTTOOLS")
961+
endif()
955962
endif()
956963
endif()
957964

@@ -1214,7 +1221,7 @@ endif()
12141221
# Find required dependencies.
12151222
#
12161223

1217-
find_package(Python3 COMPONENTS Interpreter REQUIRED)
1224+
find_package(Python3 3.6 COMPONENTS Interpreter REQUIRED)
12181225

12191226
#
12201227
# Find optional dependencies.
@@ -1289,11 +1296,6 @@ else()
12891296
endif()
12901297
endif()
12911298

1292-
if (BUILD_SWIFT_CONCURRENCY_BACK_DEPLOYMENT_LIBRARIES)
1293-
# Build the back-deployed concurrency library.
1294-
add_subdirectory(stdlib/public/BackDeployConcurrency)
1295-
endif()
1296-
12971299
# Some tools (e.g. swift-reflection-dump) rely on a host swiftRemoteInspection,
12981300
# so ensure we build that when building tools.
12991301
if(SWIFT_INCLUDE_TOOLS OR SWIFT_BUILD_STDLIB_CXX_MODULE)

SwiftCompilerSources/CMakeLists.txt

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function(add_swift_compiler_modules_library name)
8181
list(APPEND swift_compile_options "-Xfrontend" "-disable-implicit-string-processing-module-import")
8282
endif()
8383

84-
if(CMAKE_BUILD_TYPE STREQUAL Debug)
84+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
8585
list(APPEND swift_compile_options "-g")
8686
else()
8787
list(APPEND swift_compile_options "-O" "-cross-module-optimization")
@@ -103,7 +103,7 @@ function(add_swift_compiler_modules_library name)
103103
set(deployment_version "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_DEPLOYMENT_VERSION}")
104104
set(sdk_path "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_PATH}")
105105
set(sdk_option "-sdk" "${sdk_path}")
106-
if(${BOOTSTRAPPING_MODE} STREQUAL "CROSSCOMPILE-WITH-HOSTLIBS")
106+
if(BOOTSTRAPPING_MODE STREQUAL "CROSSCOMPILE-WITH-HOSTLIBS")
107107
# Let the cross-compiled compile don't pick up the compiled stdlib by providing
108108
# an (almost) empty resource dir.
109109
# The compiler will instead pick up the stdlib from the SDK.
@@ -122,7 +122,7 @@ function(add_swift_compiler_modules_library name)
122122
message(ERROR "libc++ not found in the toolchain.")
123123
endif()
124124
endif()
125-
elseif(${BOOTSTRAPPING_MODE} STREQUAL "CROSSCOMPILE")
125+
elseif(BOOTSTRAPPING_MODE STREQUAL "CROSSCOMPILE")
126126
set(sdk_option "-sdk" "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_PATH}")
127127
get_filename_component(swift_exec_bin_dir ${ALS_SWIFT_EXEC} DIRECTORY)
128128
set(sdk_option ${sdk_option} "-resource-dir" "${swift_exec_bin_dir}/../lib/swift")
@@ -235,7 +235,7 @@ else()
235235
#
236236
# step 1: generate a dummy source file, which just includes all headers
237237
# defined in include/swift/module.modulemap
238-
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/HeaderDependencies.cpp"
238+
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/HeaderDependencies.cpp.tmp"
239239
"
240240
#include \"Basic/BridgedSwiftObject.h\"
241241
#include \"Basic/BasicBridging.h\"
@@ -251,21 +251,26 @@ else()
251251
252252
#include \"Parse/RegexParserBridging.h\"
253253
")
254+
add_custom_command(
255+
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/HeaderDependencies.cpp"
256+
COMMAND ${CMAKE_COMMAND} -E copy_if_different
257+
"${CMAKE_CURRENT_BINARY_DIR}/HeaderDependencies.cpp.tmp"
258+
"${CMAKE_CURRENT_BINARY_DIR}/HeaderDependencies.cpp"
259+
)
254260

255261
# step 2: build a library containing that source file. This library depends on all the included header files.
256262
# The swift modules can now depend on that target.
257263
# Note that this library is unused, i.e. not linked to anything.
258264
add_library(importedHeaderDependencies "${CMAKE_CURRENT_BINARY_DIR}/HeaderDependencies.cpp")
259-
add_dependencies(importedHeaderDependencies swift-ast-generated-headers)
260265
target_include_directories(importedHeaderDependencies PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../include/swift")
261266

262-
if(${BOOTSTRAPPING_MODE} MATCHES "HOSTTOOLS|CROSSCOMPILE")
267+
if(BOOTSTRAPPING_MODE MATCHES "HOSTTOOLS|CROSSCOMPILE")
263268

264269
if (NOT SWIFT_EXEC_FOR_SWIFT_MODULES)
265270
message(FATAL_ERROR "Need a swift toolchain building swift compiler sources")
266271
endif()
267272

268-
if(${BOOTSTRAPPING_MODE} STREQUAL "HOSTTOOLS")
273+
if(BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS")
269274
if(NOT SWIFT_EXEC_FOR_SWIFT_MODULES STREQUAL CMAKE_Swift_COMPILER)
270275
message(FATAL_ERROR "The Swift compiler (${CMAKE_Swift_COMPILER}) differs from the Swift compiler in SWIFT_NATIVE_SWIFT_TOOLS_PATH (${SWIFT_NATIVE_SWIFT_TOOLS_PATH}/swiftc).")
271276
endif()
@@ -281,11 +286,11 @@ else()
281286
add_swift_compiler_modules_library(swiftCompilerModules
282287
SWIFT_EXEC "${SWIFT_EXEC_FOR_SWIFT_MODULES}")
283288

284-
elseif(${BOOTSTRAPPING_MODE} MATCHES "BOOTSTRAPPING.*")
289+
elseif(BOOTSTRAPPING_MODE MATCHES "BOOTSTRAPPING.*")
285290

286291
set(b0_deps swift-frontend-bootstrapping0 symlink-headers-bootstrapping0)
287292
set(b1_deps swift-frontend-bootstrapping1 symlink-headers-bootstrapping1)
288-
if(${BOOTSTRAPPING_MODE} STREQUAL "BOOTSTRAPPING")
293+
if(BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING")
289294
list(APPEND b0_deps swiftCore-bootstrapping0)
290295
list(APPEND b1_deps swiftCore-bootstrapping1)
291296
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
@@ -296,7 +301,7 @@ else()
296301
list(APPEND b0_deps swiftDarwin-bootstrapping0)
297302
list(APPEND b1_deps swiftDarwin-bootstrapping1)
298303
endif()
299-
if(${SWIFT_HOST_VARIANT_SDK} IN_LIST SWIFT_LIBSTDCXX_PLATFORMS)
304+
if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_LIBSTDCXX_PLATFORMS)
300305
list(APPEND b0_deps copy-libstdcxx-modulemap-bootstrapping0 copy-libstdcxx-header-bootstrapping0)
301306
list(APPEND b1_deps copy-libstdcxx-modulemap-bootstrapping1 copy-libstdcxx-header-bootstrapping1)
302307
endif()

SwiftCompilerSources/Package.swift

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.3
1+
// swift-tools-version:5.9
22
//===--- Package.swift.in - SwiftCompiler SwiftPM package -----------------===//
33
//
44
// This source file is part of the Swift.org open source project
@@ -14,20 +14,6 @@
1414
import PackageDescription
1515

1616
private extension Target {
17-
static let defaultSwiftSettings: [SwiftSetting] = [
18-
.unsafeFlags([
19-
"-Xfrontend", "-validate-tbd-against-ir=none",
20-
"-Xfrontend", "-enable-experimental-cxx-interop",
21-
// Bridging modules and headers
22-
"-Xcc", "-I", "-Xcc", "../include",
23-
// LLVM modules and headers
24-
"-Xcc", "-I", "-Xcc", "../../llvm-project/llvm/include",
25-
// Clang modules and headers
26-
"-Xcc", "-I", "-Xcc", "../../llvm-project/clang/include",
27-
"-cross-module-optimization"
28-
]),
29-
]
30-
3117
static func compilerModuleTarget(
3218
name: String,
3319
dependencies: [Dependency],
@@ -40,7 +26,16 @@ private extension Target {
4026
path: path ?? "Sources/\(name)",
4127
exclude: ["CMakeLists.txt"],
4228
sources: sources,
43-
swiftSettings: defaultSwiftSettings + swiftSettings)
29+
swiftSettings: [
30+
.interoperabilityMode(.Cxx),
31+
.unsafeFlags([
32+
"-static",
33+
"-Xcc", "-I../include",
34+
"-Xcc", "-I../../llvm-project/llvm/include",
35+
"-Xcc", "-I../../llvm-project/clang/include",
36+
"-cross-module-optimization",
37+
]),
38+
] + swiftSettings)
4439
}
4540
}
4641

@@ -86,5 +81,6 @@ let package = Package(
8681
.compilerModuleTarget(
8782
name: "Optimizer",
8883
dependencies: ["Basic", "SIL", "Parse"]),
89-
]
84+
],
85+
cxxLanguageStandard: .cxx17
9086
)

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/AssumeSingleThreaded.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727

2828
import SIL
2929

30-
let assumeSingleThreadedPass = FunctionPass(
31-
name: "sil-assume-single-threaded", { function, context in
32-
for inst in function.instructions {
33-
guard let rcInst = inst as? RefCountingInst else { continue }
30+
let assumeSingleThreadedPass = FunctionPass(name: "sil-assume-single-threaded") {
31+
(function: Function, context: FunctionPassContext) in
3432

35-
rcInst.setAtomicity(isAtomic: false, context)
36-
}
33+
for inst in function.instructions {
34+
guard let rcInst = inst as? RefCountingInst else { continue }
35+
36+
rcInst.setAtomicity(isAtomic: false, context)
3737
}
38-
)
38+
}

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ComputeEscapeEffects.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import SIL
2525
/// ```
2626
/// The pass does not try to change or re-compute _defined_ effects.
2727
///
28-
let computeEscapeEffects = FunctionPass(name: "compute-escape-effects", {
28+
let computeEscapeEffects = FunctionPass(name: "compute-escape-effects") {
2929
(function: Function, context: FunctionPassContext) in
3030

3131
var newEffects = function.effects.escapeEffects.arguments.filter {!$0.isDerived }
@@ -73,8 +73,7 @@ let computeEscapeEffects = FunctionPass(name: "compute-escape-effects", {
7373
context.modifyEffects(in: function) { (effects: inout FunctionEffects) in
7474
effects.escapeEffects.arguments = newEffects
7575
}
76-
})
77-
76+
}
7877

7978
/// Returns true if an argument effect was added.
8079
private

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ComputeSideEffects.swift

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import SIL
2424
/// ```
2525
/// are computed.
2626
///
27-
let computeSideEffects = FunctionPass(name: "compute-side-effects", {
27+
let computeSideEffects = FunctionPass(name: "compute-side-effects") {
2828
(function: Function, context: FunctionPassContext) in
2929

3030
if function.isAvailableExternally {
@@ -71,7 +71,7 @@ let computeSideEffects = FunctionPass(name: "compute-side-effects", {
7171
context.modifyEffects(in: function) { (effects: inout FunctionEffects) in
7272
effects.sideEffects = SideEffects(arguments: collectedEffects.argumentEffects, global: collectedEffects.globalEffects)
7373
}
74-
})
74+
}
7575

7676
/// The collected argument and global side effects of the function.
7777
private struct CollectedEffects {
@@ -142,6 +142,24 @@ private struct CollectedEffects {
142142
handleApply(pa)
143143
checkedIfDeinitBarrier = true
144144
}
145+
// In addition to the effects of the apply, also consider the
146+
// effects of the capture, which reads the captured value in
147+
// order to move it into the context. This only applies to
148+
// addressible values, because capturing does not dereference
149+
// any class objects.
150+
//
151+
// Ignore captures for on-stack partial applies. They only
152+
// bitwise-move or capture by address, so the call to
153+
// handleApply above is sufficient. And, if they are not applied
154+
// in this function, then they are never applied.
155+
if !pa.isOnStack {
156+
// callee is never an address.
157+
for argument in pa.arguments {
158+
if argument.type.isAddress {
159+
addEffects(.read, to: argument)
160+
}
161+
}
162+
}
145163

146164
case let fl as FixLifetimeInst:
147165
// A fix_lifetime instruction acts like a read on the operand to prevent

0 commit comments

Comments
 (0)