Skip to content

Commit 9276bb0

Browse files
authored
Merge branch 'apple:main' into my-branch
2 parents 2be845e + 4b1deb0 commit 9276bb0

File tree

116 files changed

+1246
-618
lines changed

Some content is hidden

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

116 files changed

+1246
-618
lines changed

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LetPropertyLowering.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ private func insertEndInitInstructions(
9999
atEndOf initRegion: InstructionRange,
100100
_ context: FunctionPassContext
101101
) {
102-
var ssaUpdater = SSAUpdater(type: markUninitialized.type, ownership: .owned, context)
102+
var ssaUpdater = SSAUpdater(function: markUninitialized.parentFunction,
103+
type: markUninitialized.type, ownership: .owned, context)
103104
ssaUpdater.addAvailableValue(markUninitialized, in: markUninitialized.parentBlock)
104105

105106
for endInst in initRegion.ends {

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/RedundantLoadElimination.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ private extension LoadInst {
236236
}
237237

238238
private func replace(load: LoadInst, with availableValues: [AvailableValue], _ context: FunctionPassContext) {
239-
var ssaUpdater = SSAUpdater(type: load.type, ownership: load.ownership, context)
239+
var ssaUpdater = SSAUpdater(function: load.parentFunction,
240+
type: load.type, ownership: load.ownership, context)
240241

241242
for availableValue in availableValues {
242243
let block = availableValue.instruction.parentBlock

SwiftCompilerSources/Sources/Optimizer/Utilities/SSAUpdater.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ import OptimizerBridging
1717
struct SSAUpdater<Context: MutatingContext> {
1818
let context: Context
1919

20-
init(type: Type, ownership: Ownership, _ context: Context) {
20+
init(function: Function, type: Type, ownership: Ownership,
21+
_ context: Context) {
2122
self.context = context
22-
context._bridged.SSAUpdater_initialize(type.bridged, ownership._bridged)
23+
context._bridged.SSAUpdater_initialize(function.bridged, type.bridged,
24+
ownership._bridged)
2325
}
2426

2527
mutating func addAvailableValue(_ value: Value, in block: BasicBlock) {

docs/Android.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ To follow along with this guide, you'll need:
3636
instructions in the Swift project README.
3737
2. The latest build of the Swift compiler for your Linux distro, available at
3838
https://www.swift.org/download/ or sometimes your distro package manager.
39-
3. The last version of the Android LTS NDK (r25c, the latest LTS NDK 26 at the
40-
time of this writing doesn't work yet), available to download here:
39+
3. The latest version of the Android LTS NDK (r26c at the time of this writing),
40+
available to download here:
4141
https://developer.android.com/ndk/downloads
4242
4. An Android device with remote debugging enabled or the emulator. We require
4343
remote debugging in order to deploy built stdlib products to the device. You
@@ -54,7 +54,7 @@ and the prebuilt Swift toolchain (add --skip-early-swift-driver if you already
5454
have a Swift toolchain in your path):
5555

5656
```
57-
$ NDK_PATH=path/to/android-ndk-r25c
57+
$ NDK_PATH=path/to/android-ndk-r26c
5858
$ SWIFT_PATH=path/to/swift-DEVELOPMENT-SNAPSHOT-2023-09-30-a-ubuntu20.04/usr/bin
5959
$ git checkout swift-DEVELOPMENT-SNAPSHOT-2023-09-30-a
6060
$ utils/build-script \
@@ -83,7 +83,7 @@ Then use the standalone Swift stdlib from the previous step to compile a Swift
8383
source file, targeting Android:
8484

8585
```
86-
$ NDK_PATH="path/to/android-ndk-r25c"
86+
$ NDK_PATH="path/to/android-ndk-r26c"
8787
$ SWIFT_PATH=path/to/swift-DEVELOPMENT-SNAPSHOT-2023-09-30-a-ubuntu20.04/usr/bin
8888
$ $SWIFT_PATH/swiftc \ # The prebuilt Swift compiler you downloaded
8989
# The location of the tools used to build Android binaries
@@ -133,7 +133,7 @@ $ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libBlo
133133
In addition, you'll also need to copy the Android NDK's libc++:
134134

135135
```
136-
$ adb push /path/to/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so /data/local/tmp
136+
$ adb push /path/to/android-ndk-r26c/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so /data/local/tmp
137137
```
138138

139139
Finally, you'll need to copy the `hello` executable you built in the
@@ -176,7 +176,7 @@ $ utils/build-script \
176176
-R \ # Build in ReleaseAssert mode.
177177
-T \ # Run all tests, including on the Android device (add --host-test to only run Android tests on the Linux host).
178178
--android \ # Build for Android.
179-
--android-ndk ~/android-ndk-r25c \ # Path to an Android NDK.
179+
--android-ndk ~/android-ndk-r26c \ # Path to an Android NDK.
180180
--android-arch aarch64 \ # Optionally specify Android architecture, alternately armv7
181181
--android-api-level 21
182182
```

include/swift-c/DependencyScan/DependencyScan.h

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,18 @@ typedef struct {
6161
size_t count;
6262
} swiftscan_dependency_set_t;
6363

64+
typedef enum {
65+
SWIFTSCAN_DIAGNOSTIC_SEVERITY_ERROR = 0,
66+
SWIFTSCAN_DIAGNOSTIC_SEVERITY_WARNING = 1,
67+
SWIFTSCAN_DIAGNOSTIC_SEVERITY_NOTE = 2,
68+
SWIFTSCAN_DIAGNOSTIC_SEVERITY_REMARK = 3
69+
} swiftscan_diagnostic_severity_t;
70+
71+
typedef struct {
72+
swiftscan_diagnostic_info_t *diagnostics;
73+
size_t count;
74+
} swiftscan_diagnostic_set_t;
75+
6476
//=== Batch Scan Input Specification --------------------------------------===//
6577

6678
/// Opaque container to a container of batch scan entry information.
@@ -92,6 +104,12 @@ SWIFTSCAN_PUBLIC swiftscan_dependency_set_t *
92104
swiftscan_dependency_graph_get_dependencies(
93105
swiftscan_dependency_graph_t result);
94106

107+
// Return value disposed of together with the dependency_graph
108+
// using `swiftscan_dependency_graph_dispose`
109+
SWIFTSCAN_PUBLIC swiftscan_diagnostic_set_t *
110+
swiftscan_dependency_graph_get_diagnostics(
111+
swiftscan_dependency_graph_t result);
112+
95113
//=== Dependency Module Info Functions ------------------------------------===//
96114

97115
SWIFTSCAN_PUBLIC swiftscan_string_ref_t
@@ -277,6 +295,11 @@ swiftscan_batch_scan_entry_get_is_swift(swiftscan_batch_scan_entry_t entry);
277295
SWIFTSCAN_PUBLIC swiftscan_string_set_t *
278296
swiftscan_import_set_get_imports(swiftscan_import_set_t result);
279297

298+
// Return value disposed of together with the dependency_graph
299+
// using `swiftscan_import_set_dispose`
300+
SWIFTSCAN_PUBLIC swiftscan_diagnostic_set_t *
301+
swiftscan_import_set_get_diagnostics(swiftscan_import_set_t result);
302+
280303
//=== Scanner Invocation Functions ----------------------------------------===//
281304

282305
/// Create an \c swiftscan_scan_invocation_t instance.
@@ -378,18 +401,6 @@ SWIFTSCAN_PUBLIC swiftscan_import_set_t swiftscan_import_set_create(
378401

379402

380403
//=== Scanner Diagnostics -------------------------------------------------===//
381-
typedef enum {
382-
SWIFTSCAN_DIAGNOSTIC_SEVERITY_ERROR = 0,
383-
SWIFTSCAN_DIAGNOSTIC_SEVERITY_WARNING = 1,
384-
SWIFTSCAN_DIAGNOSTIC_SEVERITY_NOTE = 2,
385-
SWIFTSCAN_DIAGNOSTIC_SEVERITY_REMARK = 3
386-
} swiftscan_diagnostic_severity_t;
387-
388-
typedef struct {
389-
swiftscan_diagnostic_info_t *diagnostics;
390-
size_t count;
391-
} swiftscan_diagnostic_set_t;
392-
393404
/// For the specified \c scanner instance, query all insofar emitted diagnostics
394405
SWIFTSCAN_PUBLIC swiftscan_diagnostic_set_t*
395406
swiftscan_scanner_diagnostics_query(swiftscan_scanner_t scanner);

include/swift/AST/DiagnosticsSema.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2465,7 +2465,7 @@ ERROR(spi_only_imports_not_enabled, none,
24652465
ERROR(access_level_on_import_unsupported, none,
24662466
"The access level %0 is unsupported on imports: "
24672467
"only 'public', 'package', 'internal', 'fileprivate' and 'private' "
2468-
"are unsupported",
2468+
"are accepted",
24692469
(DeclAttribute))
24702470
ERROR(access_level_conflict_with_exported,none,
24712471
"'%0' is incompatible with %1; it can only be applied to public imports",

include/swift/AST/Module.h

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,7 @@ class ModuleDecl
846846
bool allowMissing = false);
847847

848848
/// Global conformance lookup, checks conditional requirements.
849+
/// Requires a contextualized type.
849850
///
850851
/// \param type The type for which we are computing conformance. Must not
851852
/// contain type parameters.
@@ -859,8 +860,32 @@ class ModuleDecl
859860
/// \returns An invalid conformance if the search failed, otherwise an
860861
/// abstract, concrete or pack conformance, depending on the lookup type.
861862
ProtocolConformanceRef checkConformance(Type type, ProtocolDecl *protocol,
862-
// Note: different default than above
863-
bool allowMissing = true);
863+
// Note: different default from lookupConformance
864+
bool allowMissing = true);
865+
866+
/// Global conformance lookup, checks conditional requirements.
867+
/// Accepts interface types without context. If the conformance cannot be
868+
/// definitively established without the missing context, returns \c nullopt.
869+
///
870+
/// \param type The type for which we are computing conformance. Must not
871+
/// contain type parameters.
872+
///
873+
/// \param protocol The protocol to which we are computing conformance.
874+
///
875+
/// \param allowMissing When \c true, the resulting conformance reference
876+
/// might include "missing" conformances, which are synthesized for some
877+
/// protocols as an error recovery mechanism.
878+
///
879+
/// \returns An invalid conformance if the search definitively failed. An
880+
/// abstract, concrete or pack conformance, depending on the lookup type,
881+
/// if the search succeeded. `std::nullopt` if the type could have
882+
/// conditionally conformed depending on the context of the interface types.
883+
std::optional<ProtocolConformanceRef>
884+
checkConformanceWithoutContext(Type type,
885+
ProtocolDecl *protocol,
886+
// Note: different default from lookupConformance
887+
bool allowMissing = true);
888+
864889

865890
/// Look for the conformance of the given existential type to the given
866891
/// protocol.

include/swift/AST/PlatformKind.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ StringRef platformString(PlatformKind platform);
4242
/// or None if such a platform kind does not exist.
4343
std::optional<PlatformKind> platformFromString(StringRef Name);
4444

45+
/// Safely converts the given unsigned value to a valid \c PlatformKind value or
46+
/// \c nullopt otherwise.
47+
std::optional<PlatformKind> platformFromUnsigned(unsigned value);
48+
4549
/// Returns a valid platform string that is closest to the candidate string
4650
/// based on edit distance. Returns \c None if the closest valid platform
4751
/// distance is not within a minimum threshold.

include/swift/AST/Requirement.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,12 @@ enum class CheckRequirementsResult : uint8_t {
223223
/// not contain any type parameters.
224224
CheckRequirementsResult checkRequirements(ArrayRef<Requirement> requirements);
225225

226+
/// Check if each substituted requirement is satisfied. If the requirement
227+
/// contains type parameters, and the answer would depend on the context of
228+
/// those type parameters, then `nullopt` is returned.
229+
std::optional<CheckRequirementsResult>
230+
checkRequirementsWithoutContext(ArrayRef<Requirement> requirements);
231+
226232
/// Check if each requirement is satisfied after applying the given
227233
/// substitutions. The substitutions must replace all type parameters that
228234
/// appear in the requirement with concrete types or archetypes.

include/swift/DependencyScan/DependencyScanImpl.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ struct swiftscan_dependency_graph_s {
3030

3131
/// The complete list of modules discovered
3232
swiftscan_dependency_set_t *dependencies;
33+
34+
/// Diagnostics produced during this scan
35+
swiftscan_diagnostic_set_t *diagnostics;
3336
};
3437

3538
struct swiftscan_dependency_info_s {
@@ -192,6 +195,8 @@ struct swiftscan_batch_scan_entry_s {
192195
struct swiftscan_import_set_s {
193196
/// The complete list of imports discovered
194197
swiftscan_string_set_t *imports;
198+
/// Diagnostics produced during this import scan
199+
swiftscan_diagnostic_set_t *diagnostics;
195200
};
196201

197202
struct swiftscan_scan_invocation_s {

0 commit comments

Comments
 (0)