aboutsummaryrefslogtreecommitdiff
path: root/src/Sema.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-01-23 18:31:55 -0500
committerGitHub <noreply@github.com>2022-01-23 18:31:55 -0500
commit12c2de6ee205857e9ca0bcef4aa4d901fc5cc772 (patch)
tree491f15df20182f428a92533e8efc2530c73c9dc2 /src/Sema.zig
parentf1b91bb41b2d810ecabf4c69cad91b24b3846b77 (diff)
parent8a697262099d64b2ff222dc9271493fe3b5f2b76 (diff)
downloadzig-12c2de6ee205857e9ca0bcef4aa4d901fc5cc772.tar.gz
zig-12c2de6ee205857e9ca0bcef4aa4d901fc5cc772.zip
Merge pull request #10662 from ziglang/doc-comments-zir
Doc comments zir
Diffstat (limited to 'src/Sema.zig')
-rw-r--r--src/Sema.zig18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index d3802a1784..6a2085cf3f 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -1916,6 +1916,9 @@ fn zirEnumDecl(
const field_name_zir = sema.code.nullTerminatedString(sema.code.extra[extra_index]);
extra_index += 1;
+ // doc comment
+ extra_index += 1;
+
// This string needs to outlive the ZIR code.
const field_name = try new_decl_arena_allocator.dupe(u8, field_name_zir);
@@ -2103,7 +2106,6 @@ fn zirErrorSetDecl(
const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
const src = inst_data.src();
const extra = sema.code.extraData(Zir.Inst.ErrorSetDecl, inst_data.payload_index);
- const fields = sema.code.extra[extra.end..][0..extra.data.fields_len];
var new_decl_arena = std.heap.ArenaAllocator.init(gpa);
errdefer new_decl_arena.deinit();
@@ -2121,8 +2123,12 @@ fn zirErrorSetDecl(
errdefer sema.mod.abortAnonDecl(new_decl);
var names = Module.ErrorSet.NameMap{};
- try names.ensureUnusedCapacity(new_decl_arena_allocator, fields.len);
- for (fields) |str_index| {
+ try names.ensureUnusedCapacity(new_decl_arena_allocator, extra.data.fields_len);
+
+ var extra_index = @intCast(u32, extra.end);
+ const extra_index_end = extra_index + (extra.data.fields_len * 2);
+ while (extra_index < extra_index_end) : (extra_index += 2) { // +2 to skip over doc_string
+ const str_index = sema.code.extra[extra_index];
const name = try new_decl_arena_allocator.dupe(u8, sema.code.nullTerminatedString(str_index));
// TODO: This check should be performed in AstGen instead.
@@ -16313,6 +16319,9 @@ fn semaStructFields(
const field_type_ref = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]);
extra_index += 1;
+ // doc_comment
+ extra_index += 1;
+
// This string needs to outlive the ZIR code.
const field_name = try decl_arena_allocator.dupe(u8, field_name_zir);
const field_ty: Type = if (field_type_ref == .none)
@@ -16502,6 +16511,9 @@ fn semaUnionFields(mod: *Module, union_obj: *Module.Union) CompileError!void {
const field_name_zir = zir.nullTerminatedString(zir.extra[extra_index]);
extra_index += 1;
+ // doc_comment
+ extra_index += 1;
+
const field_type_ref: Zir.Inst.Ref = if (has_type) blk: {
const field_type_ref = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]);
extra_index += 1;