1
Fork 0

Fix spans in LLVM-generated inline asm errors

Previously, incorrect spans were reported if inline assembly contained
CRLF (Windows) line endings.

Fixes #110885
This commit is contained in:
Amanieu d'Antras 2023-04-29 12:01:13 +01:00
parent af2c7e0f9b
commit bba2a1e071
2 changed files with 31 additions and 3 deletions

View file

@ -1821,9 +1821,15 @@ impl SharedEmitterMain {
let source = sess
.source_map()
.new_source_file(FileName::inline_asm_source_code(&buffer), buffer);
let source_span = Span::with_root_ctxt(source.start_pos, source.end_pos);
let spans: Vec<_> =
spans.iter().map(|sp| source_span.from_inner(*sp)).collect();
let spans: Vec<_> = spans
.iter()
.map(|sp| {
Span::with_root_ctxt(
source.normalized_byte_pos(sp.start as u32),
source.normalized_byte_pos(sp.end as u32),
)
})
.collect();
err.span_note(spans, "instantiated into assembly here");
}