Skip to content

Commit 517667e

Browse files
authored
Merge pull request swiftlang#74872 from artemcm/SeparateScanCacheForHeaderDepsToo
[Dependency Scanning] Apply `-clang-scanner-module-cache-path` to header Clang module dependencies
2 parents ae7183e + a89fde1 commit 517667e

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

lib/ClangImporter/ClangModuleDependencyScanner.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -493,11 +493,11 @@ bool ClangImporter::addHeaderDependencies(
493493
std::error_code(errno, std::generic_category()));
494494
}
495495
std::string workingDir = *optionalWorkingDir;
496-
auto moduleCachePath = getModuleCachePathFromClang(getClangInstance());
496+
auto moduleOutputPath = cache.getModuleOutputPath();
497497
auto lookupModuleOutput =
498-
[moduleCachePath](const ModuleID &MID,
499-
ModuleOutputKind MOK) -> std::string {
500-
return moduleCacheRelativeLookupModuleOutput(MID, MOK, moduleCachePath);
498+
[moduleOutputPath](const ModuleID &MID,
499+
ModuleOutputKind MOK) -> std::string {
500+
return moduleCacheRelativeLookupModuleOutput(MID, MOK, moduleOutputPath);
501501
};
502502
auto dependencies = clangScanningTool.getTranslationUnitDependencies(
503503
commandLineArgs, workingDir, cache.getAlreadySeenClangModules(),
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// RUN: %empty-directory(%t.module-cache)
2+
// RUN: %empty-directory(%t.scanner-cache)
3+
4+
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t.module-cache -clang-scanner-module-cache-path %t.scanner-cache %s -o %t.deps.json -I %S/Inputs/SwiftDifferent -import-objc-header %S/Inputs/CHeaders/Bridging.h -dump-clang-diagnostics 2>&1 | %FileCheck %s --check-prefix=CHECK-CLANG-COMMAND
5+
// RUN: %validate-json %t.deps.json | %FileCheck %s --check-prefix=CHECK-DEPS
6+
7+
// Ensure we prefer clang scanner module cache path
8+
// CHECK-CLANG-COMMAND: '-fmodules-cache-path={{.*}}.scanner-cache'
9+
10+
// Ensure we the modules' output path is set to the module cache
11+
// CHECK-DEPS: "swift": "A"
12+
// CHECK-DEPS: "clang": "F"
13+
14+
// CHECK-DEPS: "clang": "F"
15+
// CHECK-DEPS-NEXT: },
16+
// CHECK-DEPS-NEXT: {
17+
// CHECK-DEPS-NEXT: "modulePath": "{{.*}}separate_clang_scan_cache_bridging.swift.tmp.module-cache{{/|\\\\}}F-{{.*}}.pcm"
18+
19+
// CHECK-DEPS: "swift": "A"
20+
// CHECK-DEPS-NEXT: },
21+
// CHECK-DEPS-NEXT: {
22+
// CHECK-DEPS-NEXT: "modulePath": "{{.*}}separate_clang_scan_cache_bridging.swift.tmp.module-cache{{/|\\\\}}A-{{.*}}.swiftmodule"
23+
24+
25+
26+
import A

0 commit comments

Comments
 (0)