aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLoris Cro <kappaloris@gmail.com>2022-01-21 17:42:48 +0100
committerLoris Cro <kappaloris@gmail.com>2022-01-21 22:00:57 +0100
commit1f56ff8343ef07d2d04d4a596b3f03f61230a753 (patch)
tree7c4d5c703f2c695a21c0a3e7b95aa0e17b9015f6 /src
parent98fddd1c54171b080eb254527203b6f4e4e2f6ca (diff)
downloadzig-1f56ff8343ef07d2d04d4a596b3f03f61230a753.tar.gz
zig-1f56ff8343ef07d2d04d4a596b3f03f61230a753.zip
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).
Diffstat (limited to 'src')
-rw-r--r--src/AstGen.zig15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/AstGen.zig b/src/AstGen.zig
index 142806e74c..c6b4e6e866 100644
--- a/src/AstGen.zig
+++ b/src/AstGen.zig
@@ -3193,7 +3193,6 @@ fn fnDecl(
// missing function name already happened in scanDecls()
const fn_name_token = fn_proto.name_token orelse return error.AnalysisFail;
const fn_name_str_index = try astgen.identAsString(fn_name_token);
- const doc_comment_index = try astgen.docCommentAsString(fn_name_token - 1);
// We insert this at the beginning so that its instruction index marks the
// start of the top level declaration.
@@ -3237,6 +3236,13 @@ fn fnDecl(
const maybe_inline_token = fn_proto.extern_export_inline_token orelse break :blk false;
break :blk token_tags[maybe_inline_token] == .keyword_inline;
};
+
+ const doc_comment_index = try astgen.docCommentAsString(fn_name_token - 1 -
+ @boolToInt(is_pub) -
+ @boolToInt(is_export) -
+ @boolToInt(is_extern) -
+ @boolToInt(has_inline_keyword)); // TODO subtract noinline too
+
const has_section_or_addrspace = fn_proto.ast.section_expr != 0 or fn_proto.ast.addrspace_expr != 0;
wip_members.nextDecl(is_pub, is_export, fn_proto.ast.align_expr != 0, has_section_or_addrspace);
@@ -3474,7 +3480,6 @@ fn globalVarDecl(
const name_token = var_decl.ast.mut_token + 1;
const name_str_index = try astgen.identAsString(name_token);
- const doc_comment_index = try astgen.docCommentAsString(var_decl.ast.mut_token);
var block_scope: GenZir = .{
.parent = scope,
@@ -3522,6 +3527,12 @@ fn globalVarDecl(
break :blk lib_name_str.index;
} else 0;
+ const doc_comment_index = try astgen.docCommentAsString(var_decl.ast.mut_token -
+ @boolToInt(is_pub) -
+ @boolToInt(is_export) -
+ @boolToInt(lib_name != 0) -
+ @boolToInt(is_threadlocal));
+
assert(var_decl.comptime_token == null); // handled by parser
const var_inst: Zir.Inst.Ref = if (var_decl.ast.init_node != 0) vi: {