Skip to content

Commit

Permalink
Don't attach a top-level function to its file, but to the file's struct
Browse files Browse the repository at this point in the history
  • Loading branch information
tau-dev committed Jun 21, 2024
1 parent b75963f commit 0519f44
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/codegen/llvm.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1696,18 +1696,20 @@ pub const Object = struct {

const file, const subprogram = if (!wip.strip) debug_info: {
const file = try o.getDebugFile(namespace.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.src_line + 1;
const is_internal_linkage = decl.val.getExternFunc(zcu) == null and
!zcu.decl_exports.contains(decl_index);
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,
Expand All @@ -1724,6 +1726,7 @@ pub const Object = struct {
},
o.debug_compile_unit,
);

function_index.setSubprogram(subprogram, &o.builder);
break :debug_info .{ file, subprogram };
} else .{.none} ** 2;
Expand Down

0 comments on commit 0519f44

Please sign in to comment.