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(
25942594
25952595 // We delay analysis because union tags can refer to
25962596 // 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: {
25982598 const tag_type = file.zir.extra[extra_index];
25992599 extra_index += 1;
26002600 const tag_ref = @intToEnum(Ref, tag_type);
26012601 break :blk tag_ref;
2602 } else .none;
2602 } else null;
26032603
26042604 const body_len = if (small.has_body_len) blk: {
26052605 const body_len = file.zir.extra[extra_index];
......@@ -2626,13 +2626,13 @@ fn walkInstruction(
26262626 );
26272627
26282628 // 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(
26302630 file,
26312631 &scope,
26322632 parent_src,
2633 tag_type_ref,
2633 tt_ref,
26342634 false,
2635 );
2635 )).expr else null;
26362636
26372637 // Fields
26382638 extra_index += body_len;
......@@ -2664,7 +2664,7 @@ fn walkInstruction(
26642664 .privDecls = priv_decl_indexes.items,
26652665 .pubDecls = decl_indexes.items,
26662666 .fields = field_type_refs.items,
2667 .tag = tag_type.expr,
2667 .tag = tag_type,
26682668 .auto_enum = small.auto_enum_tag,
26692669 .parent_container = parent_scope.enclosing_type,
26702670 },
......@@ -2855,6 +2855,9 @@ fn walkInstruction(
28552855 break :blk fields_len;
28562856 } else 0;
28572857
2858 // We don't care about decls yet
2859 if (small.has_decls_len) extra_index += 1;
2860
28582861 var backing_int: ?DocData.Expr = null;
28592862 if (small.has_backing_int) {
28602863 const backing_int_body_len = file.zir.extra[extra_index];