Skip to content

Commit 1b1439b

Browse files
Merge remote-tracking branch 'origin/main' into katei/merge-main-2023-01-05
2 parents 2767e2b + bc2bb5b commit 1b1439b

File tree

228 files changed

+4427
-1349
lines changed

Some content is hidden

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

228 files changed

+4427
-1349
lines changed

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_OSX "10.9")
460460
set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_IOS "7.0")
461461
set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_TVOS "9.0")
462462
set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_WATCHOS "2.0")
463+
set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_MACCATALYST "13.1")
463464

464465
#
465466
# User-configurable debugging options.
@@ -590,6 +591,13 @@ option(SWIFT_THREADING_PACKAGE
590591
Valid package names are 'pthreads', 'darwin', 'linux', 'win32', 'c11', 'none'
591592
or the empty string for the SDK default.")
592593

594+
option(SWIFT_ENABLE_MACCATALYST
595+
"Build the Standard Library and overlays with MacCatalyst support"
596+
FALSE)
597+
598+
set(SWIFT_DARWIN_DEPLOYMENT_VERSION_MACCATALYST "14.5" CACHE STRING
599+
"Minimum deployment target version for macCatalyst")
600+
593601
#
594602
# End of user-configurable options.
595603
#

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ to track the status of our builds, please refer to our [GitHub Actions page](htt
3737
| **CentOS 7** | x86_64 |[![Build Status](https://ci.swift.org/job/oss-swift-package-centos-7/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-centos-7)|
3838
| **Amazon Linux 2** | x86_64 |[![Build Status](https://ci.swift.org/job/oss-swift-package-amazon-linux-2/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-amazon-linux-2)|
3939
| **Amazon Linux 2** | AArch64 |[![Build Status](https://ci.swift.org/job/oss-swift-package-amazon-linux-2-aarch64/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-amazon-linux-2-aarch64)|
40+
| **Universal Base Image 9** | x86_64 |[![Build Status](https://ci.swift.org/job/oss-swift-package-ubi-9/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-ubi-9)|
4041

4142
**Swift Community-Hosted CI Platforms**
4243

benchmark/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ set(SWIFT_BENCH_MODULES
179179
single-source/StrToInt
180180
single-source/StringBuilder
181181
single-source/StringComparison
182+
single-source/StringDistance
182183
single-source/StringEdits
183184
single-source/StringEnum
184185
single-source/StringInterpolation
Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
//===--- StringEdits.swift ------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2022 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 TestsUtils
14+
15+
public let benchmarks: [BenchmarkInfo] = [
16+
BenchmarkInfo(
17+
name: "StringDistance.characters.mixed",
18+
runFunction: { n in
19+
run_characters(string: mixedString, ranges: mixedRanges, n: n)
20+
},
21+
tags: [.api, .String],
22+
setUpFunction: { blackHole(mixedRanges) }),
23+
BenchmarkInfo(
24+
name: "StringDistance.scalars.mixed",
25+
runFunction: { n in
26+
run_scalars(string: mixedString, ranges: mixedRanges, n: n)
27+
},
28+
tags: [.api, .String],
29+
setUpFunction: { blackHole(mixedRanges) }),
30+
BenchmarkInfo(
31+
name: "StringDistance.utf16.mixed",
32+
runFunction: { n in
33+
run_utf16(string: mixedString, ranges: mixedRanges, n: n)
34+
},
35+
tags: [.api, .String],
36+
setUpFunction: { blackHole(mixedRanges) }),
37+
BenchmarkInfo(
38+
name: "StringDistance.utf8.mixed",
39+
runFunction: { n in
40+
run_utf8(string: mixedString, ranges: mixedRanges, n: n)
41+
},
42+
tags: [.api, .String],
43+
setUpFunction: { blackHole(mixedRanges) }),
44+
BenchmarkInfo(
45+
name: "StringDistance.characters.ascii",
46+
runFunction: { n in
47+
run_characters(string: asciiString, ranges: asciiRanges, n: n)
48+
},
49+
tags: [.api, .String],
50+
setUpFunction: { blackHole(asciiRanges) }),
51+
BenchmarkInfo(
52+
name: "StringDistance.scalars.ascii",
53+
runFunction: { n in
54+
run_scalars(string: asciiString, ranges: asciiRanges, n: n)
55+
},
56+
tags: [.api, .String],
57+
setUpFunction: { blackHole(asciiRanges) }),
58+
BenchmarkInfo(
59+
name: "StringDistance.utf16.ascii",
60+
runFunction: { n in
61+
run_utf16(string: asciiString, ranges: asciiRanges, n: n)
62+
},
63+
tags: [.api, .String],
64+
setUpFunction: { blackHole(asciiRanges) }),
65+
BenchmarkInfo(
66+
name: "StringDistance.utf8.ascii",
67+
runFunction: { n in
68+
run_utf8(string: asciiString, ranges: asciiRanges, n: n)
69+
},
70+
tags: [.api, .String],
71+
setUpFunction: { blackHole(asciiRanges) }),
72+
]
73+
74+
75+
let mixedString = #"""
76+
The powerful programming language that is also easy to learn.
77+
손쉽게 학습할 수 있는 강력한 프로그래밍 언어.
78+
🪙 A 🥞 short 🍰 piece 🫘 of 🌰 text 👨‍👨‍👧‍👧 with 👨‍👩‍👦 some 🚶🏽 emoji 🇺🇸🇨🇦 characters 🧈
79+
some🔩times 🛺 placed 🎣 in 🥌 the 🆘 mid🔀dle 🇦🇶or🏁 around 🏳️‍🌈 a 🍇 w🍑o🥒r🥨d
80+
Unicode is such fun!
81+
U̷n̷i̷c̷o̴d̴e̷ ̶i̸s̷ ̸s̵u̵c̸h̷ ̸f̵u̷n̴!̵
82+
U̴̡̲͋̾n̵̻̳͌ì̶̠̕c̴̭̈͘ǫ̷̯͋̊d̸͖̩̈̈́ḛ̴́ ̴̟͎͐̈i̴̦̓s̴̜̱͘ ̶̲̮̚s̶̙̞͘u̵͕̯̎̽c̵̛͕̜̓h̶̘̍̽ ̸̜̞̿f̵̤̽ṷ̴͇̎͘ń̷͓̒!̷͍̾̚
83+
U̷̢̢̧̨̼̬̰̪͓̞̠͔̗̼̙͕͕̭̻̗̮̮̥̣͉̫͉̬̲̺͍̺͊̂ͅ\#
84+
n̶̨̢̨̯͓̹̝̲̣̖̞̼̺̬̤̝̊̌́̑̋̋͜͝ͅ\#
85+
ḭ̸̦̺̺͉̳͎́͑\#
86+
c̵̛̘̥̮̙̥̟̘̝͙̤̮͉͔̭̺̺̅̀̽̒̽̏̊̆͒͌̂͌̌̓̈́̐̔̿̂͑͠͝͝ͅ\#
87+
ö̶̱̠̱̤̙͚͖̳̜̰̹̖̣̻͎͉̞̫̬̯͕̝͔̝̟̘͔̙̪̭̲́̆̂͑̌͂̉̀̓́̏̎̋͗͛͆̌̽͌̄̎̚͝͝͝͝ͅ\#
88+
d̶̨̨̡̡͙̟͉̱̗̝͙͍̮͍̘̮͔͑\#
89+
e̶̢͕̦̜͔̘̘̝͈̪̖̺̥̺̹͉͎͈̫̯̯̻͑͑̿̽͂̀̽͋́̎̈́̈̿͆̿̒̈́̽̔̇͐͛̀̓͆̏̾̀̌̈́̆̽̕ͅ
90+
"""#
91+
92+
let mixedRanges = (
93+
generateRanges(for: mixedString, by: 1)
94+
+ generateRanges(for: mixedString, by: 2)
95+
+ generateRanges(for: mixedString, by: 4)
96+
+ generateRanges(for: mixedString, by: 8)
97+
+ generateRanges(for: mixedString, by: 16)
98+
+ generateRanges(for: mixedString, by: 32)
99+
+ generateRanges(for: mixedString, by: 64)
100+
+ generateRanges(for: mixedString, by: 128)
101+
+ generateRanges(for: mixedString, by: 256)
102+
+ generateRanges(for: mixedString, by: 512))
103+
104+
let _asciiString = #"""
105+
Swift is a high-performance system programming language. It has a clean
106+
and modern syntax, offers seamless access to existing C and Objective-C code
107+
and frameworks, and is memory safe by default.
108+
109+
Although inspired by Objective-C and many other languages, Swift is not itself
110+
a C-derived language. As a complete and independent language, Swift packages
111+
core features like flow control, data structures, and functions, with
112+
high-level constructs like objects, protocols, closures, and generics. Swift
113+
embraces modules, eliminating the need for headers and the code duplication
114+
they entail.
115+
116+
Swift toolchains are created using the script
117+
[build-toolchain](https://github.com/apple/swift/blob/main/utils/build-toolchain).
118+
This script is used by swift.org's CI to produce snapshots and can allow for
119+
one to locally reproduce such builds for development or distribution purposes.
120+
A typical invocation looks like the following:
121+
122+
```
123+
$ ./swift/utils/build-toolchain $BUNDLE_PREFIX
124+
```
125+
126+
where ``$BUNDLE_PREFIX`` is a string that will be prepended to the build date
127+
to give the bundle identifier of the toolchain's ``Info.plist``. For instance,
128+
if ``$BUNDLE_PREFIX`` was ``com.example``, the toolchain produced will have
129+
the bundle identifier ``com.example.YYYYMMDD``. It will be created in the
130+
directory you run the script with a filename of the form:
131+
``swift-LOCAL-YYYY-MM-DD-a-osx.tar.gz``.
132+
"""#
133+
let asciiString = String(repeating: _asciiString, count: 10)
134+
135+
let asciiRanges = (
136+
generateRanges(for: asciiString, by: 1)
137+
+ generateRanges(for: asciiString, by: 2)
138+
+ generateRanges(for: asciiString, by: 4)
139+
+ generateRanges(for: asciiString, by: 8)
140+
+ generateRanges(for: asciiString, by: 16)
141+
+ generateRanges(for: asciiString, by: 32)
142+
+ generateRanges(for: asciiString, by: 64)
143+
+ generateRanges(for: asciiString, by: 128)
144+
+ generateRanges(for: asciiString, by: 256)
145+
+ generateRanges(for: asciiString, by: 512))
146+
147+
func generateRanges(for string: String, by step: Int) -> [Range<String.Index>] {
148+
var remaining = step
149+
var i = string.startIndex
150+
var last = i
151+
152+
var ranges: [Range<String.Index>] = []
153+
while i < string.endIndex {
154+
string.unicodeScalars.formIndex(after: &i)
155+
remaining -= 1
156+
if remaining == 0 {
157+
ranges.append(last ..< i)
158+
remaining = step
159+
last = i
160+
}
161+
}
162+
ranges.append(last ..< i)
163+
return ranges
164+
}
165+
166+
func run_characters(string: String, ranges: [Range<String.Index>], n: Int) {
167+
var c = 0
168+
for _ in 0 ..< n {
169+
for r in ranges {
170+
c += string.distance(from: r.lowerBound, to: r.upperBound)
171+
}
172+
}
173+
blackHole(c)
174+
}
175+
176+
func run_scalars(string: String, ranges: [Range<String.Index>], n: Int) {
177+
var c = 0
178+
for _ in 0 ..< n {
179+
for r in ranges {
180+
c += string.unicodeScalars.distance(from: r.lowerBound, to: r.upperBound)
181+
}
182+
}
183+
blackHole(c)
184+
}
185+
186+
func run_utf16(string: String, ranges: [Range<String.Index>], n: Int) {
187+
var c = 0
188+
for _ in 0 ..< n {
189+
for r in ranges {
190+
c += string.utf16.distance(from: r.lowerBound, to: r.upperBound)
191+
}
192+
}
193+
blackHole(c)
194+
}
195+
196+
func run_utf8(string: String, ranges: [Range<String.Index>], n: Int) {
197+
var c = 0
198+
for _ in 0 ..< n {
199+
for r in ranges {
200+
c += string.utf8.distance(from: r.lowerBound, to: r.upperBound)
201+
}
202+
}
203+
blackHole(c)
204+
}

benchmark/utils/main.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ import StrComplexWalk
178178
import StrToInt
179179
import StringBuilder
180180
import StringComparison
181+
import StringDistance
181182
import StringEdits
182183
import StringEnum
183184
import StringInterpolation
@@ -362,9 +363,10 @@ register(StaticArray.benchmarks)
362363
register(StrComplexWalk.benchmarks)
363364
register(StrToInt.benchmarks)
364365
register(StringBuilder.benchmarks)
366+
register(StringComparison.benchmarks)
367+
register(StringDistance.benchmarks)
365368
register(StringEdits.benchmarks)
366369
register(StringEnum.benchmarks)
367-
register(StringComparison.benchmarks)
368370
register(StringInterpolation.benchmarks)
369371
register(StringMatch.benchmarks)
370372
register(StringRemoveDupes.benchmarks)

docs/CppInteroperability/CppInteroperabilityManifesto.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Assumptions:
6767
+ [Function templates: calls with generic type parameters](#function-templates-calls-with-generic-type-parameters)
6868
+ [Function templates: importing as real generic functions](#function-templates-importing-as-real-generic-functions)
6969
+ [Class templates](#class-templates)
70-
+ [Class templates: importing instantiation behind typedef](#class-templates-importing-instantiation-behind-typedef)
70+
+ [Class templates: importing full class template instantiations](#class-templates-importing-full-class-template-instantiations)
7171
+ [Class templates: importing specific specializations](#class-templates-importing-specific-specializations)
7272
+ [Class templates: using with generic type parameters](#class-templates-using-with-generic-type-parameters)
7373
+ [Class templates: using in generic code through a synthesized protocol](#class-templates-using-in-generic-code-through-a-synthesized-protocol)
@@ -184,7 +184,7 @@ that pick different sides, forcing the user to choose.
184184

185185
Swift/C++ interoperability builds on top of the Swift/C interoperability, so it
186186
helps to be familiar with [Swift's strategy for importing C
187-
modules](HowSwiftImportsCAPIs.md).
187+
modules](../HowSwiftImportsCAPIs.md).
188188

189189
# Importing C++ APIs into Swift
190190

docs/SequencesAndCollections.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ As you can see, sequence does nothing more than deliver an iterator.
5959
To understand the need for iterators, it's important to distinguish
6060
the two kinds of sequences.
6161

62-
* **Volatile** sequences like "stream of network packets," carry
62+
* **Volatile** sequences, like "stream of network packets", carry
6363
their own traversal state, and are expected to be "consumed" as they
6464
are traversed.
6565

include/swift/APIDigester/ModuleAnalyzerNodes.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,13 @@ class SDKNodeDeclVar : public SDKNodeDecl {
674674
void addAccessor(SDKNode* AC);
675675
};
676676

677+
class SDKNodeDeclMacro : public SDKNodeDecl {
678+
public:
679+
SDKNodeDeclMacro(SDKNodeInitInfo Info);
680+
static bool classof(const SDKNode *N);
681+
SDKNodeType *getType() const;
682+
};
683+
677684
class SDKNodeDeclAbstractFunc : public SDKNodeDecl {
678685
bool IsThrowing;
679686
bool ReqNewWitnessTableEntry;
@@ -796,6 +803,7 @@ class SwiftDeclCollector: public VisibleDeclConsumer {
796803
SDKNode *constructSubscriptDeclNode(SubscriptDecl *SD);
797804
SDKNode *constructAssociatedTypeNode(AssociatedTypeDecl *ATD);
798805
SDKNode *constructTypeAliasNode(TypeAliasDecl *TAD);
806+
SDKNode *constructMacroNode(MacroDecl *MAD);
799807
SDKNode *constructVarNode(ValueDecl *VD);
800808
SDKNode *constructExternalExtensionNode(NominalTypeDecl *NTD,
801809
ArrayRef<ExtensionDecl*> AllExts);

0 commit comments

Comments
 (0)