Skip to content

Commit 9e198ab

Browse files
authored
Merge pull request #35077 from nkcsgexi/add-empty-trace-file
Frontend: allow specifying only one module trace output path in batch mode
2 parents d606015 + 1b1fae5 commit 9e198ab

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/Frontend/ArgsToFrontendOutputsConverter.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,15 @@ SupplementaryOutputPathsComputer::getSupplementaryFilenamesFromArguments(
354354

355355
if (paths.size() == N)
356356
return paths;
357+
else if (pathID == options::OPT_emit_loaded_module_trace_path &&
358+
paths.size() < N) {
359+
// We only need one file to output the module trace file because they
360+
// are all equivalent. Add additional empty output paths for module trace to
361+
// make sure the compiler won't panic for diag::error_wrong_number_of_arguments.
362+
for(unsigned I = paths.size(); I != N; I ++)
363+
paths.emplace_back();
364+
return paths;
365+
}
357366

358367
if (paths.empty())
359368
return std::vector<std::string>(N, std::string());
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: touch %t/file-01.swift
3+
// RUN: touch %t/file-02.swift
4+
// RUN: cd %t
5+
// RUN: %target-swift-frontend -emit-module -primary-file file-01.swift -primary-file file-02.swift -o file-01.swiftmodule -o file-02.swiftmodule -module-name foo -emit-loaded-module-trace-path=%t/trace.json

0 commit comments

Comments
 (0)