commit e39c86399da565d3855d54b242bf7b5940e3924d (tree)
parent b59428e9f78b1f9f265c0ffdba79b128d77644d2
Author: Andrew Kelley <andrew@ziglang.org>
Date: Tue, 29 Mar 2022 20:08:28 -0700
link: half-hearted bug fix for decl_state field
The init()/commit() API of this field leads to the type of bug that this
commit fixes by defering an uncomfortably complex expression. I didn't
bother doing the equivalent fix in link/MachO.zig because instead I
think the `decl_state` field should be entirely removed from Dwarf.
Diffstat:
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/link/Dwarf.zig b/src/link/Dwarf.zig
@@ -91,7 +91,7 @@ pub const DeclState = struct {
};
}
- fn deinit(self: *DeclState, gpa: Allocator) void {
+ pub fn deinit(self: *DeclState, gpa: Allocator) void {
self.dbg_line.deinit();
self.dbg_info.deinit();
self.abbrev_type_arena.deinit();
diff --git a/src/link/Elf.zig b/src/link/Elf.zig
@@ -2342,6 +2342,12 @@ pub fn updateFunc(self: *Elf, module: *Module, func: *Module.Fn, air: Air, liven
if (self.dwarf) |*dw| {
try dw.initDeclState(decl);
}
+ defer if (self.dwarf) |*dw| {
+ if (dw.decl_state) |*ds| {
+ ds.deinit(dw.allocator);
+ dw.decl_state = null;
+ }
+ };
const res = if (self.dwarf) |*dw|
try codegen.generateFunction(&self.base, decl.srcLoc(), func, air, liveness, &code_buffer, .{