aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.zig
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2024-06-30 03:00:07 +0100
committermlugg <mlugg@mlugg.co.uk>2024-07-04 21:01:41 +0100
commitded5c759f83a4da355a128dd4d7f5e22cbd3cabe (patch)
treeb862bbdf36b892e9c39f472c6759f084c87d64b2 /src/codegen.zig
parent089bbd6588d82ccda0646e756006cf5787eadef2 (diff)
downloadzig-ded5c759f83a4da355a128dd4d7f5e22cbd3cabe.tar.gz
zig-ded5c759f83a4da355a128dd4d7f5e22cbd3cabe.zip
Zcu: store `LazySrcLoc` in error messages
This change modifies `Zcu.ErrorMsg` to store a `Zcu.LazySrcLoc` rather than a `Zcu.SrcLoc`. Everything else is dominoes. The reason for this change is incremental compilation. If a failed `AnalUnit` is up-to-date on an update, we want to re-use the old error messages. However, the file containing the error location may have been modified, and `SrcLoc` cannot survive such a modification. `LazySrcLoc` is designed to be correct across incremental updates. Therefore, we defer source location resolution until `Compilation` gathers the compile errors into the `ErrorBundle`.
Diffstat (limited to 'src/codegen.zig')
-rw-r--r--src/codegen.zig22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/codegen.zig b/src/codegen.zig
index b8662ed15b..769e8f7cd5 100644
--- a/src/codegen.zig
+++ b/src/codegen.zig
@@ -47,7 +47,7 @@ pub const DebugInfoOutput = union(enum) {
pub fn generateFunction(
lf: *link.File,
- src_loc: Module.SrcLoc,
+ src_loc: Module.LazySrcLoc,
func_index: InternPool.Index,
air: Air,
liveness: Liveness,
@@ -79,7 +79,7 @@ pub fn generateFunction(
pub fn generateLazyFunction(
lf: *link.File,
- src_loc: Module.SrcLoc,
+ src_loc: Module.LazySrcLoc,
lazy_sym: link.File.LazySymbol,
code: *std.ArrayList(u8),
debug_output: DebugInfoOutput,
@@ -105,7 +105,7 @@ fn writeFloat(comptime F: type, f: F, target: Target, endian: std.builtin.Endian
pub fn generateLazySymbol(
bin_file: *link.File,
- src_loc: Module.SrcLoc,
+ src_loc: Module.LazySrcLoc,
lazy_sym: link.File.LazySymbol,
// TODO don't use an "out" parameter like this; put it in the result instead
alignment: *Alignment,
@@ -171,7 +171,7 @@ pub fn generateLazySymbol(
pub fn generateSymbol(
bin_file: *link.File,
- src_loc: Module.SrcLoc,
+ src_loc: Module.LazySrcLoc,
val: Value,
code: *std.ArrayList(u8),
debug_output: DebugInfoOutput,
@@ -618,7 +618,7 @@ pub fn generateSymbol(
fn lowerPtr(
bin_file: *link.File,
- src_loc: Module.SrcLoc,
+ src_loc: Module.LazySrcLoc,
ptr_val: InternPool.Index,
code: *std.ArrayList(u8),
debug_output: DebugInfoOutput,
@@ -683,7 +683,7 @@ const RelocInfo = struct {
fn lowerAnonDeclRef(
lf: *link.File,
- src_loc: Module.SrcLoc,
+ src_loc: Module.LazySrcLoc,
anon_decl: InternPool.Key.Ptr.BaseAddr.AnonDecl,
code: *std.ArrayList(u8),
debug_output: DebugInfoOutput,
@@ -730,7 +730,7 @@ fn lowerAnonDeclRef(
fn lowerDeclRef(
lf: *link.File,
- src_loc: Module.SrcLoc,
+ src_loc: Module.LazySrcLoc,
decl_index: InternPool.DeclIndex,
code: *std.ArrayList(u8),
debug_output: DebugInfoOutput,
@@ -814,7 +814,7 @@ pub const GenResult = union(enum) {
fn fail(
gpa: Allocator,
- src_loc: Module.SrcLoc,
+ src_loc: Module.LazySrcLoc,
comptime format: []const u8,
args: anytype,
) Allocator.Error!GenResult {
@@ -825,7 +825,7 @@ pub const GenResult = union(enum) {
fn genDeclRef(
lf: *link.File,
- src_loc: Module.SrcLoc,
+ src_loc: Module.LazySrcLoc,
val: Value,
ptr_decl_index: InternPool.DeclIndex,
) CodeGenError!GenResult {
@@ -931,7 +931,7 @@ fn genDeclRef(
fn genUnnamedConst(
lf: *link.File,
- src_loc: Module.SrcLoc,
+ src_loc: Module.LazySrcLoc,
val: Value,
owner_decl_index: InternPool.DeclIndex,
) CodeGenError!GenResult {
@@ -970,7 +970,7 @@ fn genUnnamedConst(
pub fn genTypedValue(
lf: *link.File,
- src_loc: Module.SrcLoc,
+ src_loc: Module.LazySrcLoc,
val: Value,
owner_decl_index: InternPool.DeclIndex,
) CodeGenError!GenResult {