1414#include " swift/extractor/trap/generated/TrapClasses.h"
1515#include " swift/extractor/trap/TrapDomain.h"
1616#include " swift/extractor/visitors/SwiftVisitor.h"
17- #include " swift/extractor/infra/TargetFile .h"
17+ #include " swift/extractor/TargetTrapFile .h"
1818
1919using namespace codeql ;
2020using namespace std ::string_literals;
@@ -80,20 +80,6 @@ static llvm::SmallVector<swift::Decl*> getTopLevelDecls(swift::ModuleDecl& modul
8080 return ret;
8181}
8282
83- static void dumpArgs (TargetFile& out, const SwiftExtractorConfiguration& config) {
84- out << " /* extractor-args:\n " ;
85- for (const auto & opt : config.frontendOptions ) {
86- out << " " << std::quoted (opt) << " \\\n " ;
87- }
88- out << " \n */\n " ;
89-
90- out << " /* swift-frontend-args:\n " ;
91- for (const auto & opt : config.patchedFrontendOptions ) {
92- out << " " << std::quoted (opt) << " \\\n " ;
93- }
94- out << " \n */\n " ;
95- }
96-
9783static void extractDeclarations (const SwiftExtractorConfiguration& config,
9884 swift::CompilerInstance& compiler,
9985 swift::ModuleDecl& module ,
@@ -103,12 +89,11 @@ static void extractDeclarations(const SwiftExtractorConfiguration& config,
10389 // The extractor can be called several times from different processes with
10490 // the same input file(s). Using `TargetFile` the first process will win, and the following
10591 // will just skip the work
106- auto trapTarget = TargetFile::create (filename + " .trap " , config. trapDir , config. getTempTrapDir () );
92+ auto trapTarget = createTargetTrapFile ( config, filename );
10793 if (!trapTarget) {
10894 // another process arrived first, nothing to do for us
10995 return ;
11096 }
111- dumpArgs (*trapTarget, config);
11297 TrapDomain trap{*trapTarget};
11398
11499 // TODO: remove this and recreate it with IPA when we have that
@@ -172,14 +157,6 @@ void codeql::extractSwiftFiles(const SwiftExtractorConfiguration& config,
172157 auto inputFiles = collectInputFilenames (compiler);
173158 auto modules = collectModules (compiler);
174159
175- // we want to make sure any following extractor run will not try to extract things from
176- // the swiftmodule files we are creating in this run, as those things will already have been
177- // extracted from source with more information. We do this by creating empty trap files.
178- // TargetFile semantics will ensure any following run trying to extract that swiftmodule will just
179- // skip doing it
180- for (const auto & output : config.outputSwiftModules ) {
181- TargetFile::create (output + " .trap" , config.trapDir , config.getTempTrapDir ());
182- }
183160 for (auto & module : modules) {
184161 bool isFromSourceFile = false ;
185162 for (auto file : module ->getFiles ()) {
0 commit comments