@@ -379,6 +379,7 @@ fn cleanupUpdatedFiles(gpa: Allocator, updated_files: *std.AutoArrayHashMapUnman
379379pub fn updateZirRefs (pt : Zcu.PerThread ) Allocator.Error ! void {
380380 assert (pt .tid == .main );
381381 const zcu = pt .zcu ;
382+ const comp = zcu .comp ;
382383 const ip = & zcu .intern_pool ;
383384 const gpa = zcu .gpa ;
384385
@@ -435,8 +436,19 @@ pub fn updateZirRefs(pt: Zcu.PerThread) Allocator.Error!void {
435436
436437 const old_zir = file .prev_zir .?.* ;
437438 const new_zir = file .zir ;
438- const old_tag = old_zir .instructions .items (.tag );
439- const old_data = old_zir .instructions .items (.data );
439+ const old_tag = old_zir .instructions .items (.tag )[@intFromEnum (old_inst )];
440+ const old_data = old_zir .instructions .items (.data )[@intFromEnum (old_inst )];
441+
442+ switch (old_tag ) {
443+ .declaration = > {
444+ const old_line = old_zir .getDeclaration (old_inst ).src_line ;
445+ const new_line = new_zir .getDeclaration (new_inst ).src_line ;
446+ if (old_line != new_line ) {
447+ try comp .queueJob (.{ .update_line_number = tracked_inst_index });
448+ }
449+ },
450+ else = > {},
451+ }
440452
441453 if (old_zir .getAssociatedSrcHash (old_inst )) | old_hash | hash_changed : {
442454 if (new_zir .getAssociatedSrcHash (new_inst )) | new_hash | {
@@ -455,8 +467,8 @@ pub fn updateZirRefs(pt: Zcu.PerThread) Allocator.Error!void {
455467 }
456468
457469 // If this is a `struct_decl` etc, we must invalidate any outdated namespace dependencies.
458- const has_namespace = switch (old_tag [ @intFromEnum ( old_inst )] ) {
459- .extended = > switch (old_data [ @intFromEnum ( old_inst )] .extended .opcode ) {
470+ const has_namespace = switch (old_tag ) {
471+ .extended = > switch (old_data .extended .opcode ) {
460472 .struct_decl , .union_decl , .opaque_decl , .enum_decl = > true ,
461473 else = > false ,
462474 },
@@ -2517,8 +2529,6 @@ const ScanDeclIter = struct {
25172529 );
25182530 try comp .queueJob (.{ .analyze_comptime_unit = unit });
25192531 }
2520-
2521- // TODO: we used to do line number updates here, but this is an inappropriate place for this logic to live.
25222532 }
25232533};
25242534
@@ -3152,6 +3162,15 @@ pub fn linkerUpdateContainerType(pt: Zcu.PerThread, ty: InternPool.Index) !void
31523162 }
31533163}
31543164
3165+ pub fn linkerUpdateLineNumber (pt : Zcu.PerThread , ti : InternPool.TrackedInst.Index ) ! void {
3166+ if (pt .zcu .comp .bin_file ) | lf | {
3167+ lf .updateLineNumber (pt , ti ) catch | err | switch (err ) {
3168+ error .OutOfMemory = > return error .OutOfMemory ,
3169+ else = > | e | log .err ("update line number failed: {s}" , .{@errorName (e )}),
3170+ };
3171+ }
3172+ }
3173+
31553174pub fn reportRetryableAstGenError (
31563175 pt : Zcu.PerThread ,
31573176 src : Zcu.AstGenSrc ,
0 commit comments