Add filenames to stack traces (#5623)

To make it easier to identify crashing files when testing multiple.

```
(elided)
3.	Check::Context
          filename: duplicate_name_same_line.carbon
          NodeStack:
(elided)
```
This commit is contained in:
Jon Ross-Perkins
2025-06-06 17:29:08 +00:00
committed by GitHub
parent 5b68b8338e
commit 1b55459da6
2 changed files with 6 additions and 0 deletions
+3
View File
@@ -845,6 +845,9 @@ auto CompilationUnit::GetParseTreeAndSubtrees()
auto CompilationUnit::LogCall(llvm::StringLiteral logging_label,
llvm::StringLiteral timing_label,
llvm::function_ref<auto()->void> fn) -> void {
PrettyStackTraceFunction trace_file([&](llvm::raw_ostream& out) {
out << "filename: " << input_filename_ << "\n";
});
CARBON_VLOG("*** {0}: {1} ***\n", logging_label, input_filename_);
Timings::ScopedTiming timing(timings_ ? &*timings_ : nullptr, timing_label);
fn();