mirror of
https://github.com/github/codeql.git
synced 2026-04-26 09:15:12 +02:00
Swift: make trap domain logger names more informative
This commit is contained in:
@@ -12,10 +12,12 @@ namespace codeql {
|
||||
// Abstracts a given trap output file, with its own universe of trap labels
|
||||
class TrapDomain {
|
||||
TargetFile out;
|
||||
Logger logger{out.target().filename()};
|
||||
Logger logger{getLoggerName()};
|
||||
|
||||
public:
|
||||
explicit TrapDomain(TargetFile&& out) : out{std::move(out)} {}
|
||||
explicit TrapDomain(TargetFile&& out) : out{std::move(out)} {
|
||||
LOG_DEBUG("writing trap file with target {}", this->out.target());
|
||||
}
|
||||
|
||||
template <typename Entry>
|
||||
void emit(const Entry& e) {
|
||||
@@ -84,6 +86,17 @@ class TrapDomain {
|
||||
(oss << ... << keyParts);
|
||||
assignKey(label, oss.str());
|
||||
}
|
||||
|
||||
std::string getLoggerName() {
|
||||
// packaged swift modules are typically structured as
|
||||
// `Module.swiftmodule/<arch_triple>.swiftmodule`, so the parent is more informative
|
||||
// We use `Module.swiftmodule/.trap` then
|
||||
if (auto parent = out.target().parent_path(); parent.extension() == ".swiftmodule") {
|
||||
return parent.filename() / ".trap";
|
||||
} else {
|
||||
return out.target().filename();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace codeql
|
||||
|
||||
Reference in New Issue
Block a user