Swift: collect original output module paths

This commit is contained in:
Paolo Tranquilli
2023-01-18 09:37:58 +01:00
parent 84b285a4c6
commit 353536b826
2 changed files with 7 additions and 2 deletions

View File

@@ -21,6 +21,9 @@ struct SwiftExtractorState {
std::unordered_set<const swift::ModuleDecl*> encounteredModules;
std::vector<std::filesystem::path> sourceFiles;
// The path for the modules outputted by the underlying frontend run, ignoring path redirection
std::vector<std::filesystem::path> originalOutputModules;
};
} // namespace codeql

View File

@@ -35,7 +35,8 @@ static void lockOutputSwiftModuleTraps(codeql::SwiftExtractorState& state,
}
}
static void processFrontendOptions(swift::FrontendOptions& options) {
static void processFrontendOptions(codeql::SwiftExtractorState& state,
swift::FrontendOptions& options) {
auto& inOuts = options.InputsAndOutputs;
std::vector<swift::InputFile> inputs;
inOuts.forEachInput([&](const swift::InputFile& input) {
@@ -53,6 +54,7 @@ static void processFrontendOptions(swift::FrontendOptions& options) {
input.getPrimarySpecificPaths().SupplementaryOutputs.ModuleOutputPath;
!module.empty()) {
psp.SupplementaryOutputs.ModuleOutputPath = codeql::redirect(module);
state.originalOutputModules.push_back(module);
}
auto inputCopy = input;
inputCopy.setPrimarySpecificPaths(std::move(psp));
@@ -77,7 +79,7 @@ class Observer : public swift::FrontendObserver {
void parsedArgs(swift::CompilerInvocation& invocation) override {
auto& options = invocation.getFrontendOptions();
lockOutputSwiftModuleTraps(state, options);
processFrontendOptions(options);
processFrontendOptions(state, options);
}
void configuredCompiler(swift::CompilerInstance& instance) override {