From bac132bc8fb320620ca5ad554ce515ccb7e4dad1 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 7 Jun 2022 17:48:53 -0700 Subject: introduce std.debug.Trace And use it to debug a LazySrcLoc in stage2 that is set to a bogus value. The actual fix in this commit is: ```diff - try sema.emitBackwardBranch(&child_block, call_src); + try sema.emitBackwardBranch(block, call_src); ``` --- src/codegen/c.zig | 2 +- src/codegen/llvm.zig | 2 +- src/codegen/spirv.zig | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/codegen') diff --git a/src/codegen/c.zig b/src/codegen/c.zig index 4c2239b306..45191f3107 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -363,7 +363,7 @@ pub const DeclGen = struct { fn fail(dg: *DeclGen, comptime format: []const u8, args: anytype) error{ AnalysisFail, OutOfMemory } { @setCold(true); - const src: LazySrcLoc = .{ .node_offset = 0 }; + const src = LazySrcLoc.nodeOffset(0); const src_loc = src.toSrcLoc(dg.decl); dg.error_msg = try Module.ErrorMsg.create(dg.module.gpa, src_loc, format, args); return error.AnalysisFail; diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 188c2f6f11..60803eff69 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -2163,7 +2163,7 @@ pub const DeclGen = struct { fn todo(self: *DeclGen, comptime format: []const u8, args: anytype) Error { @setCold(true); assert(self.err_msg == null); - const src_loc = @as(LazySrcLoc, .{ .node_offset = 0 }).toSrcLoc(self.decl); + const src_loc = LazySrcLoc.nodeOffset(0).toSrcLoc(self.decl); self.err_msg = try Module.ErrorMsg.create(self.gpa, src_loc, "TODO (LLVM): " ++ format, args); return error.CodegenFail; } diff --git a/src/codegen/spirv.zig b/src/codegen/spirv.zig index 0dc39db134..9879bc7f35 100644 --- a/src/codegen/spirv.zig +++ b/src/codegen/spirv.zig @@ -184,7 +184,7 @@ pub const DeclGen = struct { fn fail(self: *DeclGen, comptime format: []const u8, args: anytype) Error { @setCold(true); - const src: LazySrcLoc = .{ .node_offset = 0 }; + const src = LazySrcLoc.nodeOffset(0); const src_loc = src.toSrcLoc(self.decl); assert(self.error_msg == null); self.error_msg = try Module.ErrorMsg.create(self.module.gpa, src_loc, format, args); @@ -193,7 +193,7 @@ pub const DeclGen = struct { fn todo(self: *DeclGen, comptime format: []const u8, args: anytype) Error { @setCold(true); - const src: LazySrcLoc = .{ .node_offset = 0 }; + const src = LazySrcLoc.nodeOffset(0); const src_loc = src.toSrcLoc(self.decl); assert(self.error_msg == null); self.error_msg = try Module.ErrorMsg.create(self.module.gpa, src_loc, "TODO (SPIR-V): " ++ format, args); -- cgit v1.2.3