diff --git a/nac3core/src/codegen/stmt.rs b/nac3core/src/codegen/stmt.rs index 29328807..d17045c8 100644 --- a/nac3core/src/codegen/stmt.rs +++ b/nac3core/src/codegen/stmt.rs @@ -26,12 +26,16 @@ pub fn gen_var<'ctx, 'a>( ctx: &mut CodeGenContext<'ctx, 'a>, ty: BasicTypeEnum<'ctx>, ) -> Result, String> { + let loc = ctx.builder.get_current_debug_location(); // put the alloca in init block let current = ctx.builder.get_insert_block().unwrap(); // position before the last branching instruction... ctx.builder.position_before(&ctx.init_bb.get_last_instruction().unwrap()); let ptr = ctx.builder.build_alloca(ty, "tmp"); ctx.builder.position_at_end(current); + if let Some(l) = loc { + ctx.builder.set_current_debug_location(ctx.ctx, l); + } Ok(ptr) }