authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-03-18 22:39:03+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-03-19 11:20:38+02:00
log30e17cd5d0f3d3cfea689c25c870a378c4a9053b
tree1325006f0bc46ffeffa2548bfdbc47479be3b561
parentf19731948e934e8e9877729cab871ed05463d3c4

Sema: add debug info for inline function parameters


1 files changed, 30 insertions(+), 1 deletions(-)

src/Sema.zig+30-1
...@@ -4269,6 +4269,17 @@ fn zirDbgVar(...@@ -4269,6 +4269,17 @@ fn zirDbgVar(
42694269
4270 const str_op = sema.code.instructions.items(.data)[inst].str_op;4270 const str_op = sema.code.instructions.items(.data)[inst].str_op;
4271 const operand = sema.resolveInst(str_op.operand);4271 const operand = sema.resolveInst(str_op.operand);
4272 const name = str_op.getStr(sema.code);
4273 try sema.addDbgVar(block, operand, air_tag, name);
4274}
4275
4276fn addDbgVar(
4277 sema: *Sema,
4278 block: *Block,
4279 operand: Air.Inst.Ref,
4280 air_tag: Air.Inst.Tag,
4281 name: []const u8,
4282) CompileError!void {
4272 const operand_ty = sema.typeOf(operand);4283 const operand_ty = sema.typeOf(operand);
4273 switch (air_tag) {4284 switch (air_tag) {
4274 .dbg_var_ptr => {4285 .dbg_var_ptr => {
...@@ -4279,7 +4290,6 @@ fn zirDbgVar(...@@ -4279,7 +4290,6 @@ fn zirDbgVar(
4279 },4290 },
4280 else => unreachable,4291 else => unreachable,
4281 }4292 }
4282 const name = str_op.getStr(sema.code);
42834293
4284 // Add the name to the AIR.4294 // Add the name to the AIR.
4285 const name_extra_index = @intCast(u32, sema.air_extra.items.len);4295 const name_extra_index = @intCast(u32, sema.air_extra.items.len);
...@@ -4835,6 +4845,25 @@ fn analyzeCall(...@@ -4835,6 +4845,25 @@ fn analyzeCall(
4835 const new_func_resolved_ty = try Type.Tag.function.create(sema.arena, new_fn_info);4845 const new_func_resolved_ty = try Type.Tag.function.create(sema.arena, new_fn_info);
4836 if (!is_comptime_call) {4846 if (!is_comptime_call) {
4837 try sema.emitDbgInline(block, parent_func.?, module_fn, new_func_resolved_ty, .dbg_inline_begin);4847 try sema.emitDbgInline(block, parent_func.?, module_fn, new_func_resolved_ty, .dbg_inline_begin);
4848
4849 for (fn_info.param_body) |param| switch (zir_tags[param]) {
4850 .param, .param_comptime => {
4851 const inst_data = sema.code.instructions.items(.data)[param].pl_tok;
4852 const extra = sema.code.extraData(Zir.Inst.Param, inst_data.payload_index);
4853 const param_name = sema.code.nullTerminatedString(extra.data.name);
4854 const inst = sema.inst_map.get(param).?;
4855
4856 try sema.addDbgVar(block, inst, .dbg_var_val, param_name);
4857 },
4858 .param_anytype, .param_anytype_comptime => {
4859 const inst_data = sema.code.instructions.items(.data)[param].str_tok;
4860 const param_name = inst_data.get(sema.code);
4861 const inst = sema.inst_map.get(param).?;
4862
4863 try sema.addDbgVar(block, inst, .dbg_var_val, param_name);
4864 },
4865 else => continue,
4866 };
4838 }4867 }
48394868
4840 const result = result: {4869 const result = result: {