Files
swift-mirror/test/ScanDependencies/error_source_locations.swift
Artem Chikin 195bc1e6d6 [Dependency Scanning] Re-use cached queried Clang dependency info in subsequent scanning stages
Dependency Scanning is recursive over discovered Swift module overlays and cross-import overlays. In the main 'resolveImportedModuleDependencies' routine, after all Swift and Clang dependencies of the main module are discovered, the scanner looks up Swift overlays for discovered Clang modules. For each such Swift overlay, the scanner will then proceed to call 'resolveImportedModuleDependencies' on the overlay module.

On these subsequent recursive calls to 'resolveImportedModuleDependencies', Clang dependency resolution will re-query all imports of the overlay module which do not resolve to Swift modules, even if they had been queried previously in a parent invocation. This change adds the ability to re-use previously-queried-and-cached Clang module dependency information by having the dependency cache also store the set of visible modules which resulted from each by-name lookup.
2026-01-05 11:42:51 -08:00

28 lines
1.5 KiB
Swift

// RUN: %empty-directory(%t)
// RUN: mkdir -p %t/clang-module-cache
// REQUIRES: objc_interop
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4 2>&1 | %FileCheck %s
import P
import FooBar
// CHECK: {{.*}}{{/|\\}}Z.swiftinterface:3:8: error: unable to resolve module dependency: 'missing_module'
// CHECK-NEXT: 1 | // swift-interface-format-version: 1.0
// CHECK-NEXT: 2 | // swift-module-flags: -module-name Z
// CHECK-NEXT: 3 | import missing_module
// CHECK-NEXT: | |- error: unable to resolve module dependency: 'missing_module'
// CHECK-NEXT: | |- note: a dependency of Swift module 'Z': '{{.*}}{{/|\\}}Z.swiftinterface'
// CHECK-NEXT: | |- note: a dependency of Swift module 'Y': '{{.*}}{{/|\\}}Y.swiftinterface'
// CHECK-NEXT: | |- note: a dependency of Swift module 'P': '{{.*}}{{/|\\}}P.swiftinterface'
// CHECK-NEXT: | `- note: a dependency of main module 'deps'
// CHECK-NEXT: 4 | public func funcZ() { }
// CHECK: {{.*}}{{/|\\}}error_source_locations.swift:7:8: error: unable to resolve module dependency: 'FooBar'
// CHECK-NEXT: 5 |
// CHECK-NEXT: 6 | import P
// CHECK-NEXT: 7 | import FooBar
// CHECK-NEXT: | |- error: unable to resolve module dependency: 'FooBar'
// CHECK-NEXT: | `- note: a dependency of main module 'deps'
// CHECK-NEXT: 8 |
// CHECK-NEXT: 9 |