Skip to content

Commit 3cd0af6

Browse files
authored
Merge pull request github#12700 from github/redsun82/swift-fix-wmo
Swift: extract all source files in WMO mode
2 parents b382465 + f938fde commit 3cd0af6

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

swift/extractor/SwiftExtractor.cpp

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

swift/integration-tests/posix-only/frontend-invocations/Files.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
| F1.swift:0:0:0:0 | F1.swift |
77
| F2.swift:0:0:0:0 | F2.swift |
88
| F3.swift:0:0:0:0 | F3.swift |
9+
| F4.swift:0:0:0:0 | F4.swift |
910
| F5.swift:0:0:0:0 | F5.swift |
1011
| G.swift:0:0:0:0 | G.swift |
1112
| H1.swift:0:0:0:0 | H1.swift |

0 commit comments

Comments
 (0)