Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Keep source-remapped diagnostics within proven original spans

Aperta
#40 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
cpp
Ambito
backend

Direzione di ricerca

Start with src/Driver/SourceRemap.cpp and trace parseSourceRemap, remapInsideEntry, and the public remapSourceLocation path. Reproduce the reported schema-1 case, then inspect how standalone remaps and report, text/JSON, and package debug outputs represent provenance. Done means the requested distinctions and bounds policy are consistent across those paths, with coverage for the listed span, newline, Unicode, synthetic, and exact-map cases.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Problem

remapSourceLocation can return an originalLocation outside the declared original span. On dev at d43047c2a407a9bd1a90f21d1df0dd94507a698d, remapInsideEntry translates offsets and line/column deltas without checking the original bounds or mapping fidelity.

This affects repository porting generally. CrossTL emits file-level provenance when a translation does not preserve source lines. Treating that association as an affine byte mapping produces false diagnostic locations, particularly for generated helpers. The defect was found while reviewing MLX translation evidence, but the reproducer has no MLX dependency.

Reproduction

Parse this schema-1 document with parseSourceRemap:

{
  "schemaVersion": 1,
  "generatedFile": "generated.cgl",
  "mappings": [{
    "generated": {"file":"generated.cgl","line":1,"column":1,"offset":0,"length":100,"endLine":1,"endColumn":101,"endOffset":100},
    "original": {"file":"original.metal","line":1,"column":1,"offset":0,"length":10,"endLine":1,"endColumn":11,"endOffset":10}
  }]
}

Call remapSourceLocation with SourceLocation{"generated.cgl", 1, 81, 80, 5, 1, 86, 85}. Parsing succeeds without diagnostics. The result is original.metal, offsets 80:85, columns 81:86, even though the entire original span is 0:10, columns 1:11.

Reproduced locally with both the existing compiler library and a fresh compilation of src/Driver/SourceRemap.cpp from the stated commit linked to the library's support code. The source reducer calls the public parser and remapper directly.

Requested Contract

  • Never produce a remapped diagnostic outside its original span. Preserve the generated location when correspondence is not established; clamping to the original end is not an accurate fix.
  • Distinguish exact diagnostic correspondence from coarse file provenance, heuristic candidates, synthetic code and unmapped code. Specify how standalone sidecars carry that distinction, since schema 1 has no granularity field.
  • Apply the same policy to standalone remaps, report metadata, text/JSON diagnostics and package debug metadata. Preserve provenance without presenting it as an exact originalLocation.
  • Retain compatibility for valid exact schema-1 maps. Document behavior for legacy unequal spans rather than assuming equal span length proves semantic correspondence.
  • Cover shorter original spans, multiline expansion, newline normalization, Unicode byte offsets, synthetic helpers and unchanged exact mappings.

Related tracking: #27. Translator-side defect: CrossGL/crosstl#2131. CrossTL is correcting its guessed line mappings independently; compiler release availability is not required for that correction.

Lingua principale
C++
Stelle
0
Fork
0
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di CrossGL/compiler

Tutte le issue di CrossGL/compiler

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.