diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-10-27 14:52:00 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-10-27 14:52:00 -0700 |
| commit | e494ce760428cde79b63e9a9016c4af06484eef3 (patch) | |
| tree | 3205a2de5e327e61883c1d2dec37e027fe079842 /src/Sema.zig | |
| parent | c1a5ff34f3f68a2a0bc32828ab483328cd436fea (diff) | |
| download | zig-e494ce760428cde79b63e9a9016c4af06484eef3.tar.gz zig-e494ce760428cde79b63e9a9016c4af06484eef3.zip | |
stage2: fix small memory leak of test_functions when using `zig test`
The way `zig test` works is that it uses a stand-in
var test_functions: []const TestFn = undefined;
during semantic analysis, but then just before codegen, it swaps out the
value with a constant like this:
const test_functions: []const TestFn = .{foo, bar, baz, etc};
Before this commit, the `Module.Variable` associated with the stand-in
value was leaked; now it is properly cleaned up before being replaced.
Diffstat (limited to 'src/Sema.zig')
| -rw-r--r-- | src/Sema.zig | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index 87216348f2..83b81ef174 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -10762,6 +10762,11 @@ fn zirVarExtended( } const new_var = try sema.gpa.create(Module.Var); + + log.debug("created variable {*} owner_decl: {*} ({s})", .{ + new_var, sema.owner_decl, sema.owner_decl.name, + }); + new_var.* = .{ .owner_decl = sema.owner_decl, .init = init_val, |
