From 3a58708add38cd02b073bf6d35a0321d054ed387 Mon Sep 17 00:00:00 2001 From: ychenfo Date: Sat, 16 Apr 2022 00:05:28 +0800 Subject: [PATCH] fix debug info --- nac3core/src/codegen/stmt.rs | 4 ++++ 1 file changed, 4 insertions(+) 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) }