authorgravatar for kappaloris@gmail.comLoris Cro <kappaloris@gmail.com> 2022-01-21 17:42:48+01:00
committergravatar for kappaloris@gmail.comLoris Cro <kappaloris@gmail.com> 2022-01-21 22:00:57+01:00
log1f56ff8343ef07d2d04d4a596b3f03f61230a753
tree7c4d5c703f2c695a21c0a3e7b95aa0e17b9015f6
parent98fddd1c54171b080eb254527203b6f4e4e2f6ca

add support for more decl attributes in doc comment zir

The previous commit that implemented doc comment zir support for decls did not properly account for all the possible attribute keyword combinations (threadlocal, extern, and such).

1 files changed, 13 insertions(+), 2 deletions(-)

src/AstGen.zig+13-2
......@@ -3193,7 +3193,6 @@ fn fnDecl(
31933193 // missing function name already happened in scanDecls()
31943194 const fn_name_token = fn_proto.name_token orelse return error.AnalysisFail;
31953195 const fn_name_str_index = try astgen.identAsString(fn_name_token);
3196 const doc_comment_index = try astgen.docCommentAsString(fn_name_token - 1);
31973196
31983197 // We insert this at the beginning so that its instruction index marks the
31993198 // start of the top level declaration.
......@@ -3237,6 +3236,13 @@ fn fnDecl(
32373236 const maybe_inline_token = fn_proto.extern_export_inline_token orelse break :blk false;
32383237 break :blk token_tags[maybe_inline_token] == .keyword_inline;
32393238 };
3239
3240 const doc_comment_index = try astgen.docCommentAsString(fn_name_token - 1 -
3241 @boolToInt(is_pub) -
3242 @boolToInt(is_export) -
3243 @boolToInt(is_extern) -
3244 @boolToInt(has_inline_keyword)); // TODO subtract noinline too
3245
32403246 const has_section_or_addrspace = fn_proto.ast.section_expr != 0 or fn_proto.ast.addrspace_expr != 0;
32413247 wip_members.nextDecl(is_pub, is_export, fn_proto.ast.align_expr != 0, has_section_or_addrspace);
32423248
......@@ -3474,7 +3480,6 @@ fn globalVarDecl(
34743480
34753481 const name_token = var_decl.ast.mut_token + 1;
34763482 const name_str_index = try astgen.identAsString(name_token);
3477 const doc_comment_index = try astgen.docCommentAsString(var_decl.ast.mut_token);
34783483
34793484 var block_scope: GenZir = .{
34803485 .parent = scope,
......@@ -3522,6 +3527,12 @@ fn globalVarDecl(
35223527 break :blk lib_name_str.index;
35233528 } else 0;
35243529
3530 const doc_comment_index = try astgen.docCommentAsString(var_decl.ast.mut_token -
3531 @boolToInt(is_pub) -
3532 @boolToInt(is_export) -
3533 @boolToInt(lib_name != 0) -
3534 @boolToInt(is_threadlocal));
3535
35253536 assert(var_decl.comptime_token == null); // handled by parser
35263537
35273538 const var_inst: Zir.Inst.Ref = if (var_decl.ast.init_node != 0) vi: {