Commit c8b78706b7

Andrew Kelley <andrew@ziglang.org>
2021-05-16 09:04:16
linker: update MachO DebugSymbols to use the new line/column Decl API
1 parent ae04ec7
Changed files (1)
src
link
src/link/MachO/DebugSymbols.zig
@@ -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);
             }