Skip to content

Commit 23e863d

Browse files
committed
Address code review: adding a test for -experimental-clang-importer-direct-cc1-scan and renaming a function.
1 parent b7b2795 commit 23e863d

File tree

4 files changed

+24
-11
lines changed

4 files changed

+24
-11
lines changed

include/swift/Frontend/ModuleInterfaceLoader.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ struct ResultTy {
638638

639639
using ArgListTy = std::vector<std::string>;
640640

641-
void getOutputPath(ResultTy &outputPath, const StringRef &moduleName,
641+
void setOutputPath(ResultTy &outputPath, const StringRef &moduleName,
642642
const StringRef &interfacePath, const StringRef &sdkPath,
643643
const CompilerInvocation &CI, const ArgListTy &extraArgs);
644644
} // namespace SwiftInterfaceModuleOutputPathResolution

lib/DependencyScan/ScanDependencies.cpp

+6-7
Original file line numberDiff line numberDiff line change
@@ -422,14 +422,13 @@ class ExplicitModuleDependencyResolver {
422422
const auto &CI = instance.getInvocation();
423423

424424
SwiftInterfaceModuleOutputPathResolution::ArgListTy extraArgsList;
425-
const SwiftInterfaceModuleOutputPathResolution::ArgListTy
426-
&clangImpporterOptions =
427-
CI.getClangImporterOptions()
428-
.getReducedExtraArgsForSwiftModuleDependency();
425+
const auto &clangImporterOptions =
426+
CI.getClangImporterOptions()
427+
.getReducedExtraArgsForSwiftModuleDependency();
429428

430429
skip = 0;
431-
for (auto it = clangImpporterOptions.begin(),
432-
end = clangImpporterOptions.end();
430+
for (auto it = clangImporterOptions.begin(),
431+
end = clangImporterOptions.end();
433432
it != end; it++) {
434433
if (skip) {
435434
skip = 0;
@@ -449,7 +448,7 @@ class ExplicitModuleDependencyResolver {
449448
auto swiftTextualDeps = resolvingDepInfo.getAsSwiftInterfaceModule();
450449
auto &interfacePath = swiftTextualDeps->swiftInterfaceFile;
451450
auto sdkPath = instance.getASTContext().SearchPathOpts.getSDKPath();
452-
SwiftInterfaceModuleOutputPathResolution::getOutputPath(
451+
SwiftInterfaceModuleOutputPathResolution::setOutputPath(
453452
outputPath, moduleID.ModuleName, interfacePath, sdkPath, CI,
454453
extraArgsList);
455454

lib/Frontend/ModuleInterfaceLoader.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2010,7 +2010,7 @@ InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl(
20102010
void InterfaceSubContextDelegateImpl::getCachedOutputPath(
20112011
SwiftInterfaceModuleOutputPathResolution::ResultTy &resolvedOutputPath,
20122012
StringRef moduleName, StringRef interfacePath, StringRef sdkPath) {
2013-
SwiftInterfaceModuleOutputPathResolution::getOutputPath(
2013+
SwiftInterfaceModuleOutputPathResolution::setOutputPath(
20142014
resolvedOutputPath, moduleName, interfacePath, sdkPath,
20152015
genericSubInvocation,
20162016
genericSubInvocation.getClangImporterOptions()
@@ -2831,7 +2831,7 @@ static std::string getContextHash(const CompilerInvocation &CI,
28312831
return llvm::toString(llvm::APInt(64, H), 36, /*Signed=*/false);
28322832
}
28332833

2834-
void getOutputPath(ResultTy &resolvedOutputPath, const StringRef &moduleName,
2834+
void setOutputPath(ResultTy &resolvedOutputPath, const StringRef &moduleName,
28352835
const StringRef &interfacePath, const StringRef &sdkPath,
28362836
const CompilerInvocation &CI, const ArgListTy &extraArgs) {
28372837
auto &outputPath = resolvedOutputPath.outputPath;

test/ScanDependencies/eliminate_unused_vfs.swift

+15-1
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@
66

77
// RUN: sed -e "s|OUT_DIR|%t/redirects|g" -e "s|IN_DIR|%S/Inputs/CHeaders|g" %t/overlay_template.yaml > %t/overlay.yaml
88
// RUN: sed -e "s|OUT_DIR|%t/redirects|g" -e "s|IN_DIR|%S/Inputs/CHeaders1|g" %t/overlay_template.yaml > %t/overlay1.yaml
9+
// RUN: sed -e "s|OUT_DIR|%t/redirects|g" -e "s|IN_DIR|%S/Inputs/CHeaders2|g" %t/overlay_template.yaml > %t/overlay2.yaml
910

1011
// RUN: %target-swift-frontend -scan-dependencies -module-load-mode prefer-interface -module-cache-path %t/module-cache %t/test.swift -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -disable-implicit-concurrency-module-import -disable-implicit-string-processing-module-import -file-compilation-dir %t -Xcc -ivfsoverlay -Xcc %t/overlay.yaml
1112
// RUN: %validate-json %t/deps.json > %t/validated_deps.json
1213
// RUN: cat %t/validated_deps.json | %FileCheck %s
1314

1415
// RUN: %target-swift-frontend -scan-dependencies -module-load-mode prefer-interface -module-cache-path %t/module-cache %t/test.swift -o %t/deps1.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -disable-implicit-concurrency-module-import -disable-implicit-string-processing-module-import -file-compilation-dir %t -Xcc -ivfsoverlay -Xcc %t/overlay1.yaml
1516
// RUN: %validate-json %t/deps1.json > %t/validated_deps1.json
16-
// RUN: cat %t/validated_deps.json %t/validated_deps1.json \
17+
// RUN: %target-swift-frontend -scan-dependencies -module-load-mode prefer-interface -module-cache-path %t/module-cache %t/test.swift -o %t/deps2.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -disable-implicit-concurrency-module-import -disable-implicit-string-processing-module-import -experimental-clang-importer-direct-cc1-scan -file-compilation-dir %t -Xcc -ivfsoverlay -Xcc %t/overlay2.yaml
18+
// RUN: %validate-json %t/deps2.json > %t/validated_deps2.json
19+
// RUN: cat %t/validated_deps.json %t/validated_deps1.json %t/validated_deps2.json \
1720
// RUN: | %FileCheck %s --check-prefix=MOD-HASH
1821

1922
//--- overlay_template.yaml
@@ -92,3 +95,14 @@ import F
9295
// MOD-HASH: "-swift-module-file=Swift={{.*}}{{/|\\}}Swift-[[SHASH]].swiftmodule",
9396
// MOD-HASH: "-swift-module-file=SwiftOnoneSupport={{.*}}{{/|\\}}SwiftOnoneSupport-[[SOSHASH]].swiftmodule",
9497
// MOD-HASH: ],
98+
// MOD-HASH: "mainModuleName": "deps2",
99+
// MOD-HASH: "linkLibraries": [],
100+
// MOD-HASH: "details": {
101+
// MOD-HASH-NEXT: "swift": {
102+
// MOD-HASH-NEXT: "moduleInterfacePath": "{{.*}}{{/|\\}}F.swiftinterface",
103+
// MOD-HASH: "commandLine": [
104+
// MOD-HASH: "-o",
105+
// MOD-HASH-NEXT: "{{.*}}{{/|\\}}F-[[FHASH]].swiftmodule",
106+
// MOD-HASH: "-swift-module-file=Swift={{.*}}{{/|\\}}Swift-[[SHASH]].swiftmodule",
107+
// MOD-HASH: "-swift-module-file=SwiftOnoneSupport={{.*}}{{/|\\}}SwiftOnoneSupport-[[SOSHASH]].swiftmodule",
108+
// MOD-HASH: ],

0 commit comments

Comments
 (0)