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"
1516
1617using namespace codeql ;
1718using namespace std ::string_literals;
1819namespace fs = std::filesystem;
1920
20- static fs::path toPath (llvm::StringRef s) {
21- return {static_cast <std::string_view>(s)};
22- }
23-
2421static void ensureDirectory (const char * label, const fs::path& dir) {
2522 std::error_code ec;
2623 fs::create_directories (dir, ec);
@@ -34,7 +31,7 @@ static void archiveFile(const SwiftExtractorConfiguration& config, swift::Source
3431 ensureDirectory (" TRAP" , config.trapDir );
3532 ensureDirectory (" source archive" , config.sourceArchiveDir );
3633
37- fs::path srcFilePath = fs::absolute ( toPath ( file.getFilename () ));
34+ fs::path srcFilePath = codeql::getCodeQLPath ( file.getFilename ());
3835 auto dstFilePath = config.sourceArchiveDir ;
3936 dstFilePath += srcFilePath;
4037
@@ -60,7 +57,7 @@ static fs::path getFilename(swift::ModuleDecl& module, swift::SourceFile* primar
6057 // Moreover, pcm files may come from caches located in different directories, but are
6158 // unambiguously identified by the base file name, so we can discard the absolute directory
6259 fs::path filename = " /pcms" ;
63- filename /= toPath (module .getModuleFilename ()).filename ();
60+ filename /= getCodeQLPath (module .getModuleFilename ()).filename ();
6461 filename += " -" ;
6562 filename += module .getName ().str ();
6663 return filename;
@@ -69,7 +66,7 @@ static fs::path getFilename(swift::ModuleDecl& module, swift::SourceFile* primar
6966 // The Builtin module has an empty filename, let's fix that
7067 return " /__Builtin__" ;
7168 }
72- auto filename = toPath (module .getModuleFilename ());
69+ auto filename = getCodeQLPath (module .getModuleFilename ());
7370 // there is a special case of a module without an actual filename reporting `<imports>`: in this
7471 // case we want to avoid the `<>` characters, in case a dirty DB is imported on Windows
7572 if (filename == " <imports>" ) {
0 commit comments