From b4eb81230500e0e35f2017113eb4ed03be6acfb8 Mon Sep 17 00:00:00 2001 From: Tau Date: Fri, 21 Jun 2024 15:10:05 +0200 Subject: [PATCH] Don't attach a top-level function to its file, but to the file's struct --- src/codegen/llvm.zig | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 4018c9eead..f7472fe4bc 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -1642,17 +1642,19 @@ pub const Object = struct { const file, const subprogram = if (!wip.strip) debug_info: { const file = try o.getDebugFile(file_scope); - const scope = try o.namespaceToDebugScope(decl.src_namespace); + const scope = try o.lowerDebugType(zcu.declPtr(namespace.decl_index).val.toType(), false); const line_number = decl.navSrcLine(zcu) + 1; const is_internal_linkage = decl.val.getExternFunc(zcu) == null; const debug_decl_type = try o.lowerDebugType(decl.typeOf(zcu), true); + const decl_name = try o.builder.metadataString(decl.name.toSlice(ip)); + const link_name = try o.builder.metadataStringFromStrtabString(function_index.name(&o.builder)); const subprogram = try o.builder.debugSubprogram( file, scope, - try o.builder.metadataString(decl.name.toSlice(ip)), - try o.builder.metadataStringFromStrtabString(function_index.name(&o.builder)), + decl_name, + link_name, line_number, line_number + func.lbrace_line, debug_decl_type, @@ -1669,6 +1671,7 @@ pub const Object = struct { }, o.debug_compile_unit, ); + function_index.setSubprogram(subprogram, &o.builder); break :debug_info .{ file, subprogram }; } else .{.none} ** 2;