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`.
This commit is contained in:
Matthew Lugg
2024-06-20 11:07:17 +01:00
committed by GitHub
34 changed files with 2989 additions and 3344 deletions

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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);