Merge pull request #12700 from github/redsun82/swift-fix-wmo

Swift: extract all source files in WMO mode
This commit is contained in:
AlexDenisov
2023-03-30 18:01:48 +02:00
committed by GitHub
2 changed files with 6 additions and 4 deletions

View File

@@ -161,11 +161,12 @@ static std::unordered_set<swift::ModuleDecl*> extractDeclarations(
static std::unordered_set<std::string> collectInputFilenames(swift::CompilerInstance& compiler) {
// The frontend can be called in many different ways.
// At each invocation we only extract system and builtin modules and any input source files that
// have an output associated with them.
// are primary inputs, or all of them if there are no primary inputs (whole module optimization)
std::unordered_set<std::string> sourceFiles;
auto inputFiles = compiler.getInvocation().getFrontendOptions().InputsAndOutputs.getAllInputs();
for (auto& input : inputFiles) {
if (input.getType() == swift::file_types::TY_Swift && !input.outputFilename().empty()) {
const auto& inOuts = compiler.getInvocation().getFrontendOptions().InputsAndOutputs;
for (auto& input : inOuts.getAllInputs()) {
if (input.getType() == swift::file_types::TY_Swift &&
(!inOuts.hasPrimaryInputs() || input.isPrimary())) {
sourceFiles.insert(input.getFileName());
}
}

View File

@@ -6,6 +6,7 @@
| F1.swift:0:0:0:0 | F1.swift |
| F2.swift:0:0:0:0 | F2.swift |
| F3.swift:0:0:0:0 | F3.swift |
| F4.swift:0:0:0:0 | F4.swift |
| F5.swift:0:0:0:0 | F5.swift |
| G.swift:0:0:0:0 | G.swift |
| H1.swift:0:0:0:0 | H1.swift |