Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sema: make @src().line comptime-known #17688

Merged
merged 2 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/Sema.zig
Original file line number Diff line number Diff line change
Expand Up @@ -16883,10 +16883,7 @@ fn zirBuiltinSrc(
// fn_name: [:0]const u8,
func_name_val,
// line: u32,
try mod.intern(.{ .runtime_value = .{
.ty = .u32_type,
.val = (try mod.intValue(Type.u32, extra.line + 1)).toIntern(),
} }),
(try mod.intValue(Type.u32, extra.line + 1)).toIntern(),
// column: u32,
(try mod.intValue(Type.u32, extra.column + 1)).toIntern(),
};
Expand Down
36 changes: 16 additions & 20 deletions src/tracy.zig
Original file line number Diff line number Diff line change
Expand Up @@ -63,44 +63,40 @@ pub const Ctx = if (enable) ___tracy_c_zone_context else struct {
pub inline fn trace(comptime src: std.builtin.SourceLocation) Ctx {
if (!enable) return .{};

if (enable_callstack) {
return ___tracy_emit_zone_begin_callstack(&.{
const global = struct {
const loc: ___tracy_source_location_data = .{
.name = null,
.function = src.fn_name.ptr,
.file = src.file.ptr,
.line = src.line,
.color = 0,
}, callstack_depth, 1);
};
};

if (enable_callstack) {
return ___tracy_emit_zone_begin_callstack(&global.loc, callstack_depth, 1);
} else {
return ___tracy_emit_zone_begin(&.{
.name = null,
.function = src.fn_name.ptr,
.file = src.file.ptr,
.line = src.line,
.color = 0,
}, 1);
return ___tracy_emit_zone_begin(&global.loc, 1);
}
}

pub inline fn traceNamed(comptime src: std.builtin.SourceLocation, comptime name: [:0]const u8) Ctx {
if (!enable) return .{};

if (enable_callstack) {
return ___tracy_emit_zone_begin_callstack(&.{
const global = struct {
const loc: ___tracy_source_location_data = .{
.name = name.ptr,
.function = src.fn_name.ptr,
.file = src.file.ptr,
.line = src.line,
.color = 0,
}, callstack_depth, 1);
};
};

if (enable_callstack) {
return ___tracy_emit_zone_begin_callstack(&global.loc, callstack_depth, 1);
} else {
return ___tracy_emit_zone_begin(&.{
.name = name.ptr,
.function = src.fn_name.ptr,
.file = src.file.ptr,
.line = src.line,
.color = 0,
}, 1);
return ___tracy_emit_zone_begin(&global.loc, 1);
}
}

Expand Down
17 changes: 0 additions & 17 deletions test/cases/compile_errors/src_fields_runtime.zig

This file was deleted.