Skip to content

Commit 7f505d8

Browse files
committed
Swift: do not filter frontend actions
1 parent 208388e commit 7f505d8

File tree

1 file changed

+24
-43
lines changed

1 file changed

+24
-43
lines changed

swift/extractor/main.cpp

Lines changed: 24 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -32,51 +32,32 @@ static void lockOutputSwiftModuleTraps(const codeql::SwiftExtractorConfiguration
3232
}
3333

3434
static void processFrontendOptions(swift::FrontendOptions& options) {
35-
using Action = swift::FrontendOptions::ActionType;
36-
switch (options.RequestedAction) {
37-
case Action::EmitModuleOnly:
38-
case Action::MergeModules:
39-
case Action::CompileModuleFromInterface:
40-
case Action::EmitObject: {
41-
auto& inOuts = options.InputsAndOutputs;
42-
std::vector<swift::InputFile> inputs;
43-
inOuts.forEachInput([&](const swift::InputFile& input) {
44-
swift::PrimarySpecificPaths psp{};
45-
if (std::filesystem::path output = input.getPrimarySpecificPaths().OutputFilename;
46-
!output.empty()) {
47-
if (output.extension() == ".swiftmodule") {
48-
psp.OutputFilename = codeql::redirect(output);
49-
} else {
50-
psp.OutputFilename = "/dev/null";
51-
}
52-
}
53-
if (std::filesystem::path module =
54-
input.getPrimarySpecificPaths().SupplementaryOutputs.ModuleOutputPath;
55-
!module.empty()) {
56-
psp.SupplementaryOutputs.ModuleOutputPath = codeql::redirect(module);
57-
}
58-
auto inputCopy = input;
59-
inputCopy.setPrimarySpecificPaths(std::move(psp));
60-
inputs.push_back(std::move(inputCopy));
61-
return false;
62-
});
63-
inOuts.clearInputs();
64-
for (const auto& i : inputs) {
65-
inOuts.addInput(i);
35+
auto& inOuts = options.InputsAndOutputs;
36+
std::vector<swift::InputFile> inputs;
37+
inOuts.forEachInput([&](const swift::InputFile& input) {
38+
std::cerr << input.getFileName() << ":\n";
39+
swift::PrimarySpecificPaths psp{};
40+
if (std::filesystem::path output = input.getPrimarySpecificPaths().OutputFilename;
41+
!output.empty()) {
42+
if (output.extension() == ".swiftmodule") {
43+
psp.OutputFilename = codeql::redirect(output);
44+
} else {
45+
psp.OutputFilename = "/dev/null";
6646
}
67-
return;
6847
}
69-
case Action::PrintVersion:
70-
case Action::DumpAST:
71-
case Action::PrintAST:
72-
case Action::PrintASTDecl:
73-
// these actions are nice to have on the extractor for debugging, so we preserve them. Also,
74-
// version printing is used by CI to match up the correct compiler version
75-
return;
76-
default:
77-
// otherwise, we have nothing to do
78-
std::cerr << "Frontend action requires no action from extractor, exiting\n";
79-
std::exit(0);
48+
if (std::filesystem::path module =
49+
input.getPrimarySpecificPaths().SupplementaryOutputs.ModuleOutputPath;
50+
!module.empty()) {
51+
psp.SupplementaryOutputs.ModuleOutputPath = codeql::redirect(module);
52+
}
53+
auto inputCopy = input;
54+
inputCopy.setPrimarySpecificPaths(std::move(psp));
55+
inputs.push_back(std::move(inputCopy));
56+
return false;
57+
});
58+
inOuts.clearInputs();
59+
for (const auto& i : inputs) {
60+
inOuts.addInput(i);
8061
}
8162
}
8263

0 commit comments

Comments
 (0)