tobogganSe connecter

louise

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

Codegen: #line directives pointing at .til lines (issue #35)

C compiler errors, sanitizer reports and debuggers showed lines of the
generated C. Core now keeps a source span on each `let` (the innermost
HIR expression it was lowered for; a let pattern's bindings at the
pattern) and on each function (its definition, or the lambda or call
site it was made for), and the C backend, given the source files,
emits `#line N "file.til"` directives from them.

All the C of one statement belongs to one source line, but C numbers
the lines after a directive N, N+1, ...: so every further line of a
located function gets its own `#line N`. Directives only go between
whole lines, so `TL_MUSTTAIL return ...;` keeps its attribute with its
statement. Glue (closure entries, main, dictionaries, derived methods)
comes first in the file and keeps its own line numbers, so nothing has
to point back into the generated file. TILC_NO_LINE_DIRECTIVES turns
the directives off, to debug the C by its own lines.

Tests: the place of each C line of a function, a C compiler error and
(with clang) a UBSan report pointing at the .til line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

olivier · il y a 1 mois · 65002517d346b5b0c4a11226e0e80ef2dddce84d

Parents d413b91

18 fichiers modifiés, 522 ajouts, 77 suppressions

Mcrates/tilc_codegen_c/src/emit.rs+123−7
Mcrates/tilc_codegen_c/src/lib.rs+27−6
Acrates/tilc_codegen_c/tests/common/mod.rs+17−0
Acrates/tilc_codegen_c/tests/lines.rs+222−0
Mcrates/tilc_codegen_c/tests/native.rs+4−14
Mcrates/tilc_perceus/src/borrow.rs+4−4
Mcrates/tilc_perceus/src/specialise.rs+19−11
Mcrates/tilc_perceus/src/verify.rs+2−2
Mcrates/tilc_perceus/tests/programs.rs+2−0