Skip to content

Commit 10ac586

Browse files
committed
[Dependency Scanning] Add an implicit dependency on the '_SwiftConcurrencyShims' library
Whenever concurrency mode is enabled in compilation
1 parent f594699 commit 10ac586

File tree

8 files changed

+21
-1
lines changed

8 files changed

+21
-1
lines changed

include/swift/Frontend/Frontend.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,10 @@ class CompilerInstance {
559559
/// i.e. if it can be found.
560560
bool canImportSwiftConcurrency() const;
561561

562+
/// Whether the Swift Concurrency Shims support Clang library can be imported
563+
/// i.e. if it can be found.
564+
bool canImportSwiftConcurrencyShims() const;
565+
562566
/// Verify that if an implicit import of the `StringProcessing` module if
563567
/// expected, it can actually be imported. Emit a warning, otherwise.
564568
void verifyImplicitStringProcessingImport();

include/swift/Strings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ constexpr static const StringLiteral STDLIB_NAME = "Swift";
2424
constexpr static const StringLiteral SWIFT_ONONE_SUPPORT = "SwiftOnoneSupport";
2525
/// The name of the Concurrency module, which supports that extension.
2626
constexpr static const StringLiteral SWIFT_CONCURRENCY_NAME = "_Concurrency";
27+
/// The name of the Concurrency Shims Clang module
28+
constexpr static const StringLiteral SWIFT_CONCURRENCY_SHIMS_NAME = "_SwiftConcurrencyShims";
2729
/// The name of the Distributed module, which supports that extension.
2830
constexpr static const StringLiteral SWIFT_DISTRIBUTED_NAME = "Distributed";
2931
/// The name of the StringProcessing module, which supports that extension.

lib/Frontend/Frontend.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,13 @@ bool CompilerInstance::canImportSwiftConcurrency() const {
870870
return getASTContext().canImportModule(modulePath);
871871
}
872872

873+
bool CompilerInstance::canImportSwiftConcurrencyShims() const {
874+
ImportPath::Module::Builder builder(
875+
getASTContext().getIdentifier(SWIFT_CONCURRENCY_SHIMS_NAME));
876+
auto modulePath = builder.get();
877+
return getASTContext().canImportModule(modulePath);
878+
}
879+
873880
void CompilerInstance::verifyImplicitStringProcessingImport() {
874881
if (Invocation.shouldImportSwiftStringProcessing() &&
875882
!canImportSwiftStringProcessing()) {
@@ -930,6 +937,8 @@ ImplicitImportInfo CompilerInstance::getImplicitImportInfo() const {
930937
case ImplicitStdlibKind::Stdlib:
931938
if (canImportSwiftConcurrency())
932939
pushImport(SWIFT_CONCURRENCY_NAME);
940+
if (canImportSwiftConcurrencyShims())
941+
pushImport(SWIFT_CONCURRENCY_SHIMS_NAME);
933942
break;
934943
}
935944
}

test/ScanDependencies/can_import_placeholder.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ import SomeExternalModule
3838
// CHECK-DAG: "swift": "SwiftOnoneSupport"
3939
// CHECK-DAG: "swift": "_Concurrency"
4040
// CHECK-DAG: "swift": "_StringProcessing"
41+
// CHECK-DAG: "clang": "_SwiftConcurrencyShims"
4142
// CHECK: ],

test/ScanDependencies/module_deps_cache_reuse.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import SubE
4141
// CHECK-DAG: "swift": "_Concurrency"
4242
// CHECK-DAG: "swift": "_StringProcessing"
4343
// CHECK-DAG: "swift": "_cross_import_E"
44+
// CHECK-DAG: "clang": "_SwiftConcurrencyShims"
4445
// CHECK: ],
4546

4647
// CHECK: "extraPcmArgs": [

test/ScanDependencies/module_deps_cross_import_overlay.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ import SubEWrapper
2323
// CHECK-DAG: "swift": "_Concurrency"
2424
// CHECK-DAG: "swift": "_StringProcessing"
2525
// CHECK-DAG: "swift": "_cross_import_E"
26+
// CHECK-DAG: "clang": "_SwiftConcurrencyShims"
2627
// CHECK: ],

test/ScanDependencies/module_deps_external.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import SomeExternalModule
5050
// CHECK-DAG: "swift": "SwiftOnoneSupport"
5151
// CHECK-DAG: "swift": "_Concurrency"
5252
// CHECK-DAG: "swift": "_StringProcessing"
53+
// CHECK-DAG: "clang": "_SwiftConcurrencyShims"
5354
// CHECK: ],
5455

5556
// CHECK: "extraPcmArgs": [

test/ScanDependencies/prescan_deps.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import SubE
2020
// CHECK-NEXT: "SubE",
2121
// CHECK-NEXT: "Swift",
2222
// CHECK-NEXT: "SwiftOnoneSupport",
23-
// CHECK-NEXT: "_Concurrency"
23+
// CHECK-NEXT: "_Concurrency",
24+
// CHECK-NEXT: "_SwiftConcurrencyShims",
2425
// CHECK-NEXT: "_StringProcessing"
2526
// CHECK-NEXT: ]

0 commit comments

Comments
 (0)