Skip to content

Commit 09b8b08

Browse files
authored
Merge pull request #74874 from artemcm/60SeparateScanCacheForHeaderDepsToo
[6.0 🍒][Dependency Scanning] Apply `-clang-scanner-module-cache-path` to header Clang module dependencies
2 parents 3bc3f15 + dc60fbf commit 09b8b08

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
@@ -485,11 +485,11 @@ bool ClangImporter::addHeaderDependencies(
485485
std::error_code(errno, std::generic_category()));
486486
}
487487
std::string workingDir = *optionalWorkingDir;
488-
auto moduleCachePath = getModuleCachePathFromClang(getClangInstance());
488+
auto moduleOutputPath = cache.getModuleOutputPath();
489489
auto lookupModuleOutput =
490-
[moduleCachePath](const ModuleID &MID,
491-
ModuleOutputKind MOK) -> std::string {
492-
return moduleCacheRelativeLookupModuleOutput(MID, MOK, moduleCachePath);
490+
[moduleOutputPath](const ModuleID &MID,
491+
ModuleOutputKind MOK) -> std::string {
492+
return moduleCacheRelativeLookupModuleOutput(MID, MOK, moduleOutputPath);
493493
};
494494
auto dependencies = clangScanningTool.getTranslationUnitDependencies(
495495
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)