aboutsummaryrefslogtreecommitdiff
path: root/src/codegen
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
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')
-rw-r--r--src/codegen/c.zig2
-rw-r--r--src/codegen/llvm.zig2
-rw-r--r--src/codegen/spirv.zig4
3 files changed, 4 insertions, 4 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig
index a8e58a1055..6bd8bcc6fc 100644
--- a/src/codegen/c.zig
+++ b/src/codegen/c.zig
@@ -637,7 +637,7 @@ pub const DeclGen = struct {
const zcu = dg.zcu;
const decl_index = dg.pass.decl;
const decl = zcu.declPtr(decl_index);
- const src_loc = decl.navSrcLoc(zcu).upgrade(zcu);
+ const src_loc = decl.navSrcLoc(zcu);
dg.error_msg = try Zcu.ErrorMsg.create(dg.gpa, src_loc, format, args);
return error.AnalysisFail;
}
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
index 6fe7adf33c..c65158a88a 100644
--- a/src/codegen/llvm.zig
+++ b/src/codegen/llvm.zig
@@ -4644,7 +4644,7 @@ pub const DeclGen = struct {
const o = dg.object;
const gpa = o.gpa;
const mod = o.module;
- const src_loc = dg.decl.navSrcLoc(mod).upgrade(mod);
+ const src_loc = dg.decl.navSrcLoc(mod);
dg.err_msg = try Module.ErrorMsg.create(gpa, src_loc, "TODO (LLVM): " ++ format, args);
return error.CodegenFail;
}
diff --git a/src/codegen/spirv.zig b/src/codegen/spirv.zig
index 54b7b381cf..494ec0737e 100644
--- a/src/codegen/spirv.zig
+++ b/src/codegen/spirv.zig
@@ -415,7 +415,7 @@ const DeclGen = struct {
pub fn fail(self: *DeclGen, comptime format: []const u8, args: anytype) Error {
@setCold(true);
const mod = self.module;
- const src_loc = self.module.declPtr(self.decl_index).navSrcLoc(mod).upgrade(mod);
+ const src_loc = self.module.declPtr(self.decl_index).navSrcLoc(mod);
assert(self.error_msg == null);
self.error_msg = try Module.ErrorMsg.create(self.module.gpa, src_loc, format, args);
return error.CodegenFail;
@@ -6439,7 +6439,7 @@ const DeclGen = struct {
// TODO: Translate proper error locations.
assert(as.errors.items.len != 0);
assert(self.error_msg == null);
- const src_loc = self.module.declPtr(self.decl_index).navSrcLoc(mod).upgrade(mod);
+ const src_loc = self.module.declPtr(self.decl_index).navSrcLoc(mod);
self.error_msg = try Module.ErrorMsg.create(self.module.gpa, src_loc, "failed to assemble SPIR-V inline assembly", .{});
const notes = try self.module.gpa.alloc(Module.ErrorMsg, as.errors.items.len);