linker: update MachO DebugSymbols to use the new line/column Decl API

This commit is contained in:
Andrew Kelley 2021-05-16 00:04:16 -07:00
parent ae04ec776d
commit c8b78706b7

View File

@ -1063,22 +1063,8 @@ pub fn commitDeclDebugInfo(
try leb.writeULEB128(dbg_line_buffer.writer(), text_block.size);
try dbg_line_buffer.append(DW.LNS_advance_line);
const line_off: u28 = blk: {
const tree = decl.container.file_scope.tree;
const node_tags = tree.nodes.items(.tag);
const node_datas = tree.nodes.items(.data);
const token_starts = tree.tokens.items(.start);
// TODO Look into improving the performance here by adding a token-index-to-line
// lookup table. Currently this involves scanning over the source code for newlines.
const fn_decl = decl.src_node;
assert(node_tags[fn_decl] == .fn_decl);
const block = node_datas[fn_decl].rhs;
const lbrace = tree.firstToken(block);
const rbrace = tree.lastToken(block);
const line_delta = std.zig.lineDelta(tree.source, token_starts[lbrace], token_starts[rbrace]);
break :blk @intCast(u28, line_delta);
};
const func = decl.val.castTag(.function).?.data;
const line_off = @intCast(u28, decl.src_line + func.lbrace_line);
try leb.writeULEB128(dbg_line_buffer.writer(), line_off);
}