Handle unknown lines in DebugInfo (#4252)

Mainly, changes the default from -1 to 0 in DiagnosticLoc, still trying
to keep reusing that. Nothing except for the lowered output is affected,
so I think this is fine.

Also, have lowering consistently call GetDiagnosticLoc.

Pulls in one of the CHECKs suggested from #4251 

Co-authored-by: David Blaikie <dblaikie@gmail.com>
This commit is contained in:
Jon Ross-Perkins
2024-09-04 21:25:02 +00:00
committed by GitHub
co-authored by David Blaikie
parent 97e98bcc5a
commit 1412ecd3f4
9 changed files with 35 additions and 20 deletions
+4 -1
View File
@@ -98,7 +98,10 @@ auto FunctionContext::LowerInst(SemIR::InstId inst_id) -> void {
CARBON_VLOG() << "Lowering " << inst_id << ": " << inst << "\n";
builder_.getInserter().SetCurrentInstId(inst_id);
if (di_subprogram_) {
auto loc = file_context_->GetDiagnosticLoc(inst_id);
auto loc = file_context_->GetLocForDI(inst_id);
CARBON_CHECK(loc.filename == di_subprogram_->getFile()->getFilename())
<< "Instructions located in a different file from their enclosing "
"function aren't handled yet";
builder_.SetCurrentDebugLocation(
llvm::DILocation::get(builder_.getContext(), loc.line_number,
loc.column_number, di_subprogram_));