Skip to content

Commit 6963394

Browse files
authored
Merge pull request #9920 from github/alexdenisov/colocate-pcms
Swift: put all the PCM traps into the same place
2 parents 9876c39 + 50e1ffd commit 6963394

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

swift/extractor/SwiftExtractor.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "swift/extractor/infra/TargetFile.h"
1818

1919
using namespace codeql;
20+
using namespace std::string_literals;
2021

2122
static void archiveFile(const SwiftExtractorConfiguration& config, swift::SourceFile& file) {
2223
if (std::error_code ec = llvm::sys::fs::create_directories(config.trapDir)) {
@@ -53,12 +54,16 @@ static std::string getFilename(swift::ModuleDecl& module, swift::SourceFile* pri
5354
if (primaryFile) {
5455
return primaryFile->getFilename().str();
5556
}
56-
// Several modules with different name might come from .pcm (clang module) files
57-
// In this case we want to differentiate them
58-
std::string filename = module.getModuleFilename().str();
59-
filename += "-";
60-
filename += module.getName().str();
61-
return filename;
57+
// PCM clang module
58+
if (module.isNonSwiftModule()) {
59+
// Several modules with different name might come from .pcm (clang module) files
60+
// In this case we want to differentiate them
61+
std::string filename = "/pcms/"s + llvm::sys::path::filename(module.getModuleFilename()).str();
62+
filename += "-";
63+
filename += module.getName().str();
64+
return filename;
65+
}
66+
return module.getModuleFilename().str();
6267
}
6368

6469
static llvm::SmallVector<swift::Decl*> getTopLevelDecls(swift::ModuleDecl& module,

0 commit comments

Comments
 (0)