Skip to content

Commit acaa6a5

Browse files
committed
Swift: make trap domain logger names more informative
1 parent a5162b0 commit acaa6a5

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

swift/extractor/trap/TrapDomain.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ namespace codeql {
1212
// Abstracts a given trap output file, with its own universe of trap labels
1313
class TrapDomain {
1414
TargetFile out;
15-
Logger logger{out.target().filename()};
15+
Logger logger{getLoggerName()};
1616

1717
public:
18-
explicit TrapDomain(TargetFile&& out) : out{std::move(out)} {}
18+
explicit TrapDomain(TargetFile&& out) : out{std::move(out)} {
19+
LOG_DEBUG("writing trap file with target {}", this->out.target());
20+
}
1921

2022
template <typename Entry>
2123
void emit(const Entry& e) {
@@ -84,6 +86,17 @@ class TrapDomain {
8486
(oss << ... << keyParts);
8587
assignKey(label, oss.str());
8688
}
89+
90+
std::string getLoggerName() {
91+
// packaged swift modules are typically structured as
92+
// `Module.swiftmodule/<arch_triple>.swiftmodule`, so the parent is more informative
93+
// We use `Module.swiftmodule/.trap` then
94+
if (auto parent = out.target().parent_path(); parent.extension() == ".swiftmodule") {
95+
return parent.filename() / ".trap";
96+
} else {
97+
return out.target().filename();
98+
}
99+
}
87100
};
88101

89102
} // namespace codeql

0 commit comments

Comments
 (0)