Skip to content

Commit

Permalink
Merge pull request ziglang#22260 from jacobly0/dwarf-cleanup
Browse files Browse the repository at this point in the history
Dwarf: cleanup
  • Loading branch information
andrewrk authored Dec 18, 2024
2 parents 12d64c4 + 98f6399 commit 4ae101c
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 145 deletions.
18 changes: 18 additions & 0 deletions lib/std/zig/AstGen.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4151,6 +4151,8 @@ fn fnDecl(
};
defer fn_gz.unstack();

const decl_column = astgen.source_column;

// Set this now, since parameter types, return type, etc may be generic.
const prev_within_fn = astgen.within_fn;
defer astgen.within_fn = prev_within_fn;
Expand Down Expand Up @@ -4523,6 +4525,7 @@ fn fnDecl(
hash,
.{ .named = fn_name_token },
decl_gz.decl_line,
decl_column,
is_pub,
is_export,
&decl_gz,
Expand Down Expand Up @@ -4568,6 +4571,8 @@ fn globalVarDecl(
};
defer block_scope.unstack();

const decl_column = astgen.source_column;

const is_pub = var_decl.visib_token != null;
const is_export = blk: {
const maybe_export_token = var_decl.extern_export_token orelse break :blk false;
Expand Down Expand Up @@ -4693,6 +4698,7 @@ fn globalVarDecl(
hash,
.{ .named = name_token },
block_scope.decl_line,
decl_column,
is_pub,
is_export,
&block_scope,
Expand Down Expand Up @@ -4738,6 +4744,8 @@ fn comptimeDecl(
};
defer decl_block.unstack();

const decl_column = astgen.source_column;

const block_result = try fullBodyExpr(&decl_block, &decl_block.base, .{ .rl = .none }, body_node, .normal);
if (decl_block.isEmpty() or !decl_block.refIsNoReturn(block_result)) {
_ = try decl_block.addBreak(.break_inline, decl_inst, .void_value);
Expand All @@ -4750,6 +4758,7 @@ fn comptimeDecl(
hash,
.@"comptime",
decl_block.decl_line,
decl_column,
false,
false,
&decl_block,
Expand Down Expand Up @@ -4797,6 +4806,8 @@ fn usingnamespaceDecl(
};
defer decl_block.unstack();

const decl_column = astgen.source_column;

const namespace_inst = try typeExpr(&decl_block, &decl_block.base, type_expr);
_ = try decl_block.addBreak(.break_inline, decl_inst, namespace_inst);

Expand All @@ -4807,6 +4818,7 @@ fn usingnamespaceDecl(
hash,
.@"usingnamespace",
decl_block.decl_line,
decl_column,
is_pub,
false,
&decl_block,
Expand Down Expand Up @@ -4849,6 +4861,8 @@ fn testDecl(
};
defer decl_block.unstack();

const decl_column = astgen.source_column;

const main_tokens = tree.nodes.items(.main_token);
const token_tags = tree.tokens.items(.tag);
const test_token = main_tokens[node];
Expand Down Expand Up @@ -5013,6 +5027,7 @@ fn testDecl(
hash,
test_name,
decl_block.decl_line,
decl_column,
false,
false,
&decl_block,
Expand Down Expand Up @@ -14013,6 +14028,7 @@ fn addFailedDeclaration(
@splat(0), // use a fixed hash to represent an AstGen failure; we don't care about source changes if AstGen still failed!
name,
gz.astgen.source_line,
gz.astgen.source_column,
is_pub,
false, // we don't care about exports since semantic analysis will fail
&decl_gz,
Expand All @@ -14027,6 +14043,7 @@ fn setDeclaration(
src_hash: std.zig.SrcHash,
name: DeclarationName,
src_line: u32,
src_column: u32,
is_pub: bool,
is_export: bool,
value_gz: *GenZir,
Expand Down Expand Up @@ -14079,6 +14096,7 @@ fn setDeclaration(
.@"usingnamespace" => .@"usingnamespace",
},
.src_line = src_line,
.src_column = src_column,
.flags = .{
.value_body_len = @intCast(value_len),
.is_pub = is_pub,
Expand Down
1 change: 1 addition & 0 deletions lib/std/zig/Zir.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2636,6 +2636,7 @@ pub const Inst = struct {
/// The name of this `Decl`. Also indicates whether it is a test, comptime block, etc.
name: Name,
src_line: u32,
src_column: u32,
flags: Flags,

pub const Flags = packed struct(u32) {
Expand Down
2 changes: 1 addition & 1 deletion src/InternPool.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5365,7 +5365,7 @@ pub const Tag = enum(u8) {
.@"trailing.field_is_comptime_bits.?" = .@"payload.flags.any_comptime_fields",
.@"trailing.field_is_comptime_bits.?.len" = .@"(payload.fields_len + 31) / 32",
.@"trailing.field_index.?" = .@"!payload.flags.is_extern",
.@"trailing.field_index.?.len" = .@"!payload.flags.is_extern",
.@"trailing.field_index.?.len" = .@"payload.fields_len",
.@"trailing.field_offset.len" = .@"payload.fields_len",
},
},
Expand Down
Loading

0 comments on commit 4ae101c

Please sign in to comment.