diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-08-08 19:16:21 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-08-08 19:16:21 -0700 |
| commit | 1a500b969943dc6a4c549fdcbd72659702e867a2 (patch) | |
| tree | b65d3f11b30e1c43f0a63636fe908929e83b0c27 /lib/std/builtin.zig | |
| parent | 50b36e84fab023ec418eb794d6a5b4510ac6b984 (diff) | |
| download | zig-1a500b969943dc6a4c549fdcbd72659702e867a2.tar.gz zig-1a500b969943dc6a4c549fdcbd72659702e867a2.zip | |
Sema: avoid error return traces when possible
stage2 was adding bogus error return trace frames when an error was not
being returned. This commit makes several improvements:
* Make a runtime check if necessary to only emit a frame into the error
return trace when an actual error is returned.
* Use the `analyzeIsNonErrComptimeOnly` machinery to avoid runtime
checks when it is compile-time-known that the value is an error, or a
non-error.
* Make std.builtin.returnError take a non-optional stack trace pointer.
closes #12174
Diffstat (limited to 'lib/std/builtin.zig')
| -rw-r--r-- | lib/std/builtin.zig | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig index 047c65439c..ef716c6972 100644 --- a/lib/std/builtin.zig +++ b/lib/std/builtin.zig @@ -867,10 +867,9 @@ pub fn panicOutOfBounds(index: usize, len: usize) noreturn { std.debug.panic("attempt to index out of bound: index {d}, len {d}", .{ index, len }); } -pub noinline fn returnError(maybe_st: ?*StackTrace) void { +pub noinline fn returnError(st: *StackTrace) void { @setCold(true); @setRuntimeSafety(false); - const st = maybe_st orelse return; addErrRetTraceAddr(st, @returnAddress()); } |
