| ... | ... | @@ -3548,7 +3548,7 @@ pub fn declIterator(zir: Zir, decl_inst: Zir.Inst.Index) DeclIterator { |
| 3548 | 3548 | const datas = zir.instructions.items(.data); |
| 3549 | 3549 | switch (tags[@intFromEnum(decl_inst)]) { |
| 3550 | 3550 | // Functions are allowed and yield no iterations. |
| 3551 | | // There is one case matching this in the extended instruction set below. |
| 3551 | // This is because they are returned by `findDecls`. |
| 3552 | 3552 | .func, .func_inferred, .func_fancy => return .{ |
| 3553 | 3553 | .extra_index = undefined, |
| 3554 | 3554 | .decls_remaining = 0, |
| ... | ... | @@ -3558,6 +3558,13 @@ pub fn declIterator(zir: Zir, decl_inst: Zir.Inst.Index) DeclIterator { |
| 3558 | 3558 | .extended => { |
| 3559 | 3559 | const extended = datas[@intFromEnum(decl_inst)].extended; |
| 3560 | 3560 | switch (extended.opcode) { |
| 3561 | // Reifications are allowed and yield no iterations. |
| 3562 | // This is because they are returned by `findDecls`. |
| 3563 | .reify => return .{ |
| 3564 | .extra_index = undefined, |
| 3565 | .decls_remaining = 0, |
| 3566 | .zir = zir, |
| 3567 | }, |
| 3561 | 3568 | .struct_decl => { |
| 3562 | 3569 | const small: Inst.StructDecl.Small = @bitCast(extended.small); |
| 3563 | 3570 | var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.StructDecl).Struct.fields.len); |
| ... | ... | @@ -3690,6 +3697,17 @@ pub fn findDecls(zir: Zir, gpa: Allocator, list: *std.ArrayListUnmanaged(Inst.In |
| 3690 | 3697 | if (bodies.addrspace_body) |b| try zir.findDeclsBody(gpa, list, &found_defers, b); |
| 3691 | 3698 | } |
| 3692 | 3699 | |
| 3700 | /// Like `findDecls`, but only considers the `main_struct_inst` instruction. This may return more than |
| 3701 | /// just that instruction because it will also traverse fields. |
| 3702 | pub fn findDeclsRoot(zir: Zir, gpa: Allocator, list: *std.ArrayListUnmanaged(Inst.Index)) !void { |
| 3703 | list.clearRetainingCapacity(); |
| 3704 | |
| 3705 | var found_defers: std.AutoHashMapUnmanaged(u32, void) = .{}; |
| 3706 | defer found_defers.deinit(gpa); |
| 3707 | |
| 3708 | try zir.findDeclsInner(gpa, list, &found_defers, .main_struct_inst); |
| 3709 | } |
| 3710 | |
| 3693 | 3711 | fn findDeclsInner( |
| 3694 | 3712 | zir: Zir, |
| 3695 | 3713 | gpa: Allocator, |