authorgravatar for der.teufel.mail@gmail.comKrzysztof Wolicki <der.teufel.mail@gmail.com> 2023-05-09 10:52:51+02:00
committergravatar for der.teufel.mail@gmail.comKrzysztof Wolicki <der.teufel.mail@gmail.com> 2023-05-09 10:52:51+02:00
loga714f07022cb8a5d98e700090990111a7d1e234a
treefb4330961e23653bf3611c923bcac515917e203a
parent9c8b9719cb0757eb1035af0692ab89b0f2c13579

autodoc: Fix tag type for unions; Fix backing int for packed structs


1 files changed, 9 insertions(+), 6 deletions(-)

src/Autodoc.zig+9-6
...@@ -2594,12 +2594,12 @@ fn walkInstruction(...@@ -2594,12 +2594,12 @@ fn walkInstruction(
25942594
2595 // We delay analysis because union tags can refer to2595 // We delay analysis because union tags can refer to
2596 // decls defined inside the union itself.2596 // decls defined inside the union itself.
2597 const tag_type_ref: Ref = if (small.has_tag_type) blk: {2597 const tag_type_ref: ?Ref = if (small.has_tag_type) blk: {
2598 const tag_type = file.zir.extra[extra_index];2598 const tag_type = file.zir.extra[extra_index];
2599 extra_index += 1;2599 extra_index += 1;
2600 const tag_ref = @intToEnum(Ref, tag_type);2600 const tag_ref = @intToEnum(Ref, tag_type);
2601 break :blk tag_ref;2601 break :blk tag_ref;
2602 } else .none;2602 } else null;
26032603
2604 const body_len = if (small.has_body_len) blk: {2604 const body_len = if (small.has_body_len) blk: {
2605 const body_len = file.zir.extra[extra_index];2605 const body_len = file.zir.extra[extra_index];
...@@ -2626,13 +2626,13 @@ fn walkInstruction(...@@ -2626,13 +2626,13 @@ fn walkInstruction(
2626 );2626 );
26272627
2628 // Analyze the tag once all decls have been analyzed2628 // Analyze the tag once all decls have been analyzed
2629 const tag_type = try self.walkRef(2629 const tag_type = if (tag_type_ref) |tt_ref| (try self.walkRef(
2630 file,2630 file,
2631 &scope,2631 &scope,
2632 parent_src,2632 parent_src,
2633 tag_type_ref,2633 tt_ref,
2634 false,2634 false,
2635 );2635 )).expr else null;
26362636
2637 // Fields2637 // Fields
2638 extra_index += body_len;2638 extra_index += body_len;
...@@ -2664,7 +2664,7 @@ fn walkInstruction(...@@ -2664,7 +2664,7 @@ fn walkInstruction(
2664 .privDecls = priv_decl_indexes.items,2664 .privDecls = priv_decl_indexes.items,
2665 .pubDecls = decl_indexes.items,2665 .pubDecls = decl_indexes.items,
2666 .fields = field_type_refs.items,2666 .fields = field_type_refs.items,
2667 .tag = tag_type.expr,2667 .tag = tag_type,
2668 .auto_enum = small.auto_enum_tag,2668 .auto_enum = small.auto_enum_tag,
2669 .parent_container = parent_scope.enclosing_type,2669 .parent_container = parent_scope.enclosing_type,
2670 },2670 },
...@@ -2855,6 +2855,9 @@ fn walkInstruction(...@@ -2855,6 +2855,9 @@ fn walkInstruction(
2855 break :blk fields_len;2855 break :blk fields_len;
2856 } else 0;2856 } else 0;
28572857
2858 // We don't care about decls yet
2859 if (small.has_decls_len) extra_index += 1;
2860
2858 var backing_int: ?DocData.Expr = null;2861 var backing_int: ?DocData.Expr = null;
2859 if (small.has_backing_int) {2862 if (small.has_backing_int) {
2860 const backing_int_body_len = file.zir.extra[extra_index];2863 const backing_int_body_len = file.zir.extra[extra_index];