mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 07:54:41 +01:00
Improve backtrace for lowering crashes. (#5651)
Factor out the logic for mapping from a `LocId` into a diagnostic
location from check into sem_ir so it can be reused by lowering. Include
the function and instruction being lowered in the pretty stack trace.
Example stack trace:
```carbon
2. filename: examples/sieve.carbon
3. core/prelude/types/int.carbon:213:3: lowering function Core.Op(Core.IntLiteral as Core.ImplicitAs(i32))
fn Op[addr self: Self*](other: Self) = "int.sadd_assign";
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4. core/prelude/operators/arithmetic.carbon:22:27: lowering call
fn Op[addr self: Self*](other: Other);
^~~~~~~~~~~~
```
This commit is contained in:
@@ -377,7 +377,7 @@ auto CheckUnit::ProcessNodeIds() -> bool {
|
||||
const auto& tree = tree_and_subtrees_getter_();
|
||||
auto converted = tree.NodeToDiagnosticLoc(node_id, /*token_only=*/false);
|
||||
converted.loc.FormatLocation(output);
|
||||
output << "checking " << context_.parse_tree().node_kind(node_id) << "\n";
|
||||
output << "Checking " << context_.parse_tree().node_kind(node_id) << "\n";
|
||||
// Crash output has a tab indent; try to indent slightly past that.
|
||||
converted.loc.FormatSnippet(output, /*indent=*/10);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user