1212#include " swift/extractor/translators/SwiftVisitor.h"
1313#include " swift/extractor/TargetTrapFile.h"
1414#include " swift/extractor/SwiftBuiltinSymbols.h"
15- #include " swift/extractor/infra/Path.h"
15+ #include " swift/extractor/infra/file/ Path.h"
1616
1717using namespace codeql ;
1818using namespace std ::string_literals;
@@ -28,27 +28,23 @@ static void ensureDirectory(const char* label, const fs::path& dir) {
2828}
2929
3030static void archiveFile (const SwiftExtractorConfiguration& config, swift::SourceFile& file) {
31- ensureDirectory ( " TRAP " , config. trapDir );
32- ensureDirectory ( " source archive " , config.sourceArchiveDir );
31+ auto source = codeql::resolvePath (file. getFilename () );
32+ auto destination = config.sourceArchiveDir / source. relative_path ( );
3333
34- fs::path srcFilePath = codeql::getCodeQLPath (file.getFilename ());
35- auto dstFilePath = config.sourceArchiveDir ;
36- dstFilePath += srcFilePath;
37-
38- ensureDirectory (" source archive destination" , dstFilePath.parent_path ());
34+ ensureDirectory (" source archive destination" , destination.parent_path ());
3935
4036 std::error_code ec;
41- fs::copy (srcFilePath, dstFilePath , fs::copy_options::overwrite_existing, ec);
37+ fs::copy (source, destination , fs::copy_options::overwrite_existing, ec);
4238
4339 if (ec) {
44- std::cerr << " Cannot archive source file " << srcFilePath << " -> " << dstFilePath << " : "
40+ std::cerr << " Cannot archive source file " << source << " -> " << destination << " : "
4541 << ec.message () << " \n " ;
4642 }
4743}
4844
4945static fs::path getFilename (swift::ModuleDecl& module , swift::SourceFile* primaryFile) {
5046 if (primaryFile) {
51- return primaryFile->getFilename (). str ( );
47+ return resolvePath ( primaryFile->getFilename ());
5248 }
5349 // PCM clang module
5450 if (module .isNonSwiftModule ()) {
@@ -57,7 +53,7 @@ static fs::path getFilename(swift::ModuleDecl& module, swift::SourceFile* primar
5753 // Moreover, pcm files may come from caches located in different directories, but are
5854 // unambiguously identified by the base file name, so we can discard the absolute directory
5955 fs::path filename = " /pcms" ;
60- filename /= getCodeQLPath ( module .getModuleFilename ()) .filename ();
56+ filename /= fs::path{std::string_view{ module .getModuleFilename ()}} .filename ();
6157 filename += " -" ;
6258 filename += module .getName ().str ();
6359 return filename;
@@ -66,13 +62,13 @@ static fs::path getFilename(swift::ModuleDecl& module, swift::SourceFile* primar
6662 // The Builtin module has an empty filename, let's fix that
6763 return " /__Builtin__" ;
6864 }
69- auto filename = getCodeQLPath ( module .getModuleFilename () );
65+ std::string_view filename = module .getModuleFilename ();
7066 // there is a special case of a module without an actual filename reporting `<imports>`: in this
7167 // case we want to avoid the `<>` characters, in case a dirty DB is imported on Windows
7268 if (filename == " <imports>" ) {
7369 return " /__imports__" ;
7470 }
75- return filename;
71+ return resolvePath ( filename) ;
7672}
7773
7874/* The builtin module is special, as it does not publish any top-level declaration
0 commit comments