diff options
| author | Matthew Lugg <mlugg@mlugg.co.uk> | 2024-06-20 11:07:17 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-20 11:07:17 +0100 |
| commit | f73be120f4254c080c48081dfc5834a7ebc9d9cf (patch) | |
| tree | e70598bed09659eb61c230620c1ddf88c14db905 /src/codegen | |
| parent | ccd3cc3266762c1fea93cdc0190eaf71718d9e6a (diff) | |
| parent | 2b677d1660018434757f9c9efec3c712675e6c47 (diff) | |
| download | zig-f73be120f4254c080c48081dfc5834a7ebc9d9cf.tar.gz zig-f73be120f4254c080c48081dfc5834a7ebc9d9cf.zip | |
Merge pull request #20299 from mlugg/the-great-decl-split
The Great Decl Split (preliminary work): refactor source locations and eliminate `Sema.Block.src_decl`.
Diffstat (limited to 'src/codegen')
| -rw-r--r-- | src/codegen/c.zig | 3 | ||||
| -rw-r--r-- | src/codegen/c/Type.zig | 2 | ||||
| -rw-r--r-- | src/codegen/llvm.zig | 7 | ||||
| -rw-r--r-- | src/codegen/spirv.zig | 5 |
4 files changed, 7 insertions, 10 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig index 9514b826ea..b3a381b278 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -13,7 +13,6 @@ const Type = @import("../type.zig").Type; const C = link.File.C; const Decl = Zcu.Decl; const trace = @import("../tracy.zig").trace; -const LazySrcLoc = std.zig.LazySrcLoc; const Air = @import("../Air.zig"); const Liveness = @import("../Liveness.zig"); const InternPool = @import("../InternPool.zig"); @@ -638,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.srcLoc(zcu); + const src_loc = decl.navSrcLoc(zcu).upgrade(zcu); dg.error_msg = try Zcu.ErrorMsg.create(dg.gpa, src_loc, format, args); return error.AnalysisFail; } diff --git a/src/codegen/c/Type.zig b/src/codegen/c/Type.zig index d38cd5d400..3a0e3b42f8 100644 --- a/src/codegen/c/Type.zig +++ b/src/codegen/c/Type.zig @@ -2581,8 +2581,8 @@ pub const AlignAs = packed struct { const Alignment = @import("../../InternPool.zig").Alignment; const assert = std.debug.assert; const CType = @This(); -const DeclIndex = std.zig.DeclIndex; const Module = @import("../../Package/Module.zig"); const std = @import("std"); const Type = @import("../../type.zig").Type; const Zcu = @import("../../Module.zig"); +const DeclIndex = @import("../../InternPool.zig").DeclIndex; diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index d9818887e5..f61c817f07 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -22,7 +22,6 @@ const Air = @import("../Air.zig"); const Liveness = @import("../Liveness.zig"); const Value = @import("../Value.zig"); const Type = @import("../type.zig").Type; -const LazySrcLoc = std.zig.LazySrcLoc; const x86_64_abi = @import("../arch/x86_64/abi.zig"); const wasm_c_abi = @import("../arch/wasm/abi.zig"); const aarch64_c_abi = @import("../arch/aarch64/abi.zig"); @@ -2067,7 +2066,7 @@ pub const Object = struct { try o.builder.metadataString(name), file, scope, - owner_decl.src_node + 1, // Line + owner_decl.src_line + 1, // Line try o.lowerDebugType(int_ty), ty.abiSize(mod) * 8, (ty.abiAlignment(mod).toByteUnits() orelse 0) * 8, @@ -2237,7 +2236,7 @@ pub const Object = struct { try o.builder.metadataString(name), try o.getDebugFile(mod.namespacePtr(owner_decl.src_namespace).file_scope), try o.namespaceToDebugScope(owner_decl.src_namespace), - owner_decl.src_node + 1, // Line + owner_decl.src_line + 1, // Line .none, // Underlying type 0, // Size 0, // Align @@ -4729,7 +4728,7 @@ pub const DeclGen = struct { const o = dg.object; const gpa = o.gpa; const mod = o.module; - const src_loc = dg.decl.srcLoc(mod); + const src_loc = dg.decl.navSrcLoc(mod).upgrade(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 42a42b10e7..4f4a227048 100644 --- a/src/codegen/spirv.zig +++ b/src/codegen/spirv.zig @@ -9,7 +9,6 @@ const Module = @import("../Module.zig"); const Decl = Module.Decl; const Type = @import("../type.zig").Type; const Value = @import("../Value.zig"); -const LazySrcLoc = std.zig.LazySrcLoc; const Air = @import("../Air.zig"); const Liveness = @import("../Liveness.zig"); const InternPool = @import("../InternPool.zig"); @@ -414,7 +413,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).srcLoc(mod); + const src_loc = self.module.declPtr(self.decl_index).navSrcLoc(mod).upgrade(mod); assert(self.error_msg == null); self.error_msg = try Module.ErrorMsg.create(self.module.gpa, src_loc, format, args); return error.CodegenFail; @@ -6438,7 +6437,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).srcLoc(mod); + const src_loc = self.module.declPtr(self.decl_index).navSrcLoc(mod).upgrade(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); |
