commit a714f07022cb8a5d98e700090990111a7d1e234a (tree)
parent 9c8b9719cb0757eb1035af0692ab89b0f2c13579
Author: Krzysztof Wolicki <der.teufel.mail@gmail.com>
Date: Tue, 9 May 2023 10:52:51 +0200
autodoc: Fix tag type for unions; Fix backing int for packed structs
Diffstat:
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/Autodoc.zig b/src/Autodoc.zig
@@ -2594,12 +2594,12 @@ fn walkInstruction(
// We delay analysis because union tags can refer to
// decls defined inside the union itself.
- const tag_type_ref: Ref = if (small.has_tag_type) blk: {
+ const tag_type_ref: ?Ref = if (small.has_tag_type) blk: {
const tag_type = file.zir.extra[extra_index];
extra_index += 1;
const tag_ref = @intToEnum(Ref, tag_type);
break :blk tag_ref;
- } else .none;
+ } else null;
const body_len = if (small.has_body_len) blk: {
const body_len = file.zir.extra[extra_index];
@@ -2626,13 +2626,13 @@ fn walkInstruction(
);
// Analyze the tag once all decls have been analyzed
- const tag_type = try self.walkRef(
+ const tag_type = if (tag_type_ref) |tt_ref| (try self.walkRef(
file,
&scope,
parent_src,
- tag_type_ref,
+ tt_ref,
false,
- );
+ )).expr else null;
// Fields
extra_index += body_len;
@@ -2664,7 +2664,7 @@ fn walkInstruction(
.privDecls = priv_decl_indexes.items,
.pubDecls = decl_indexes.items,
.fields = field_type_refs.items,
- .tag = tag_type.expr,
+ .tag = tag_type,
.auto_enum = small.auto_enum_tag,
.parent_container = parent_scope.enclosing_type,
},
@@ -2855,6 +2855,9 @@ fn walkInstruction(
break :blk fields_len;
} else 0;
+ // We don't care about decls yet
+ if (small.has_decls_len) extra_index += 1;
+
var backing_int: ?DocData.Expr = null;
if (small.has_backing_int) {
const backing_int_body_len = file.zir.extra[extra_index];