From 0c49b30a9011f9f43cc27915d3a4e08a9994f84e Mon Sep 17 00:00:00 2001 From: David Mak Date: Fri, 6 Oct 2023 11:32:38 +0800 Subject: [PATCH] core: Restore debug info before function call is invoked Previously, the IR which sets up the call to the target function will have its debug location pointing at the last argument of the function call instead of the function call itself. --- nac3core/src/codegen/expr.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/nac3core/src/codegen/expr.rs b/nac3core/src/codegen/expr.rs index 779a0e105..734f6e76b 100644 --- a/nac3core/src/codegen/expr.rs +++ b/nac3core/src/codegen/expr.rs @@ -365,6 +365,15 @@ impl<'ctx, 'a> CodeGenContext<'ctx, 'a> { let mut loc_params: Vec> = Vec::new(); let mut return_slot = None; + let loc = self.debug_info.0.create_debug_location( + self.ctx, + self.current_loc.row as u32, + self.current_loc.column as u32, + self.debug_info.2, + None, + ); + self.builder.set_current_debug_location(loc); + if fun.count_params() > 0 { let sret_id = Attribute::get_named_enum_kind_id("sret"); let byref_id = Attribute::get_named_enum_kind_id("byref"); @@ -1648,6 +1657,10 @@ pub fn gen_expr<'ctx, 'a, G: CodeGenerator>( _ => unreachable!("option must be static or ptr") } } + + // Reset current_loc back to the location of the call + ctx.current_loc = expr.location; + return Ok(generator .gen_call( ctx,