aboutsummaryrefslogtreecommitdiff
path: root/src/llvm_backend_stmt.cpp
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2026-02-02 11:33:21 +0000
committerGitHub <noreply@github.com>2026-02-02 11:33:21 +0000
commitb9e4007cb190c1a5d96e7786e726dcbcac1d08c9 (patch)
tree37abe1e7e329c02fa541f5d0534a1ac1ea0713f6 /src/llvm_backend_stmt.cpp
parentc85af4a454dac14a8b557fa80fe68f5bf1905673 (diff)
parent63c4faca75635c0203ff576d7392fe7a0f9bca6c (diff)
Merge pull request #6216 from odin-lang/bill/debug-info-fixes
Debug Info Fixes
Diffstat (limited to 'src/llvm_backend_stmt.cpp')
-rw-r--r--src/llvm_backend_stmt.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/llvm_backend_stmt.cpp b/src/llvm_backend_stmt.cpp
index 81755af2d..05ec10cda 100644
--- a/src/llvm_backend_stmt.cpp
+++ b/src/llvm_backend_stmt.cpp
@@ -847,6 +847,10 @@ gb_internal void lb_build_range_interval(lbProcedure *p, AstBinaryExpr *node,
lb_close_scope(p, lbDeferExit_Default, nullptr, node->left);
lb_pop_target_list(p);
+ if (p->debug_info != nullptr) {
+ LLVMSetCurrentDebugLocation2(p->builder, lb_debug_end_location_from_ast(p, rs->body));
+ }
+
if (check != nullptr) {
lb_emit_jump(p, check);
lb_start_block(p, check);
@@ -979,6 +983,9 @@ gb_internal void lb_build_range_tuple(lbProcedure *p, AstRangeStmt *rs, Scope *s
lb_close_scope(p, lbDeferExit_Default, nullptr, rs->body);
lb_pop_target_list(p);
+ if (p->debug_info != nullptr) {
+ LLVMSetCurrentDebugLocation2(p->builder, lb_debug_end_location_from_ast(p, rs->body));
+ }
lb_emit_jump(p, loop);
lb_start_block(p, done);
}
@@ -1108,6 +1115,9 @@ gb_internal void lb_build_range_stmt_struct_soa(lbProcedure *p, AstRangeStmt *rs
lb_close_scope(p, lbDeferExit_Default, nullptr, rs->body);
lb_pop_target_list(p);
+ if (p->debug_info != nullptr) {
+ LLVMSetCurrentDebugLocation2(p->builder, lb_debug_end_location_from_ast(p, rs->body));
+ }
lb_emit_jump(p, loop);
lb_start_block(p, done);
@@ -1330,6 +1340,9 @@ gb_internal void lb_build_range_stmt(lbProcedure *p, AstRangeStmt *rs, Scope *sc
lb_close_scope(p, lbDeferExit_Default, nullptr, rs->body);
lb_pop_target_list(p);
+ if (p->debug_info != nullptr) {
+ LLVMSetCurrentDebugLocation2(p->builder, lb_debug_end_location_from_ast(p, rs->body));
+ }
lb_emit_jump(p, loop);
lb_start_block(p, done);
}
@@ -1807,6 +1820,10 @@ gb_internal void lb_build_switch_stmt(lbProcedure *p, AstSwitchStmt *ss, Scope *
}
lbBlock *next_cond = nullptr;
+ if (p->debug_info != nullptr) {
+ LLVMSetCurrentDebugLocation2(p->builder, lb_debug_end_location_from_ast(p, clause));
+ }
+
for (Ast *expr : cc->list) {
expr = unparen_expr(expr);
@@ -3164,6 +3181,9 @@ gb_internal void lb_build_defer_stmt(lbProcedure *p, lbDefer const &d) {
if (d.kind == lbDefer_Node) {
lb_build_stmt(p, d.stmt);
} else if (d.kind == lbDefer_Proc) {
+ if (p->debug_info != nullptr && d.pos.line > 0) {
+ LLVMSetCurrentDebugLocation2(p->builder, lb_debug_location_from_token_pos(p, d.pos));
+ }
lb_emit_call(p, d.proc.deferred, d.proc.result_as_args);
}
}
@@ -3240,10 +3260,11 @@ gb_internal void lb_add_defer_node(lbProcedure *p, isize scope_index, Ast *stmt)
d->scope_index = scope_index;
d->context_stack_count = p->context_stack.count;
d->block = p->curr_block;
- d->stmt = stmt;
+ d->pos = ast_token(stmt).pos;
+ d->stmt = stmt;
}
-gb_internal void lb_add_defer_proc(lbProcedure *p, isize scope_index, lbValue deferred, Array<lbValue> const &result_as_args) {
+gb_internal void lb_add_defer_proc(lbProcedure *p, isize scope_index, lbValue deferred, Array<lbValue> const &result_as_args, TokenPos pos) {
Type *pt = base_type(p->type);
GB_ASSERT(pt->kind == Type_Proc);
if (pt->Proc.calling_convention == ProcCC_Odin) {
@@ -3254,6 +3275,7 @@ gb_internal void lb_add_defer_proc(lbProcedure *p, isize scope_index, lbValue de
d->kind = lbDefer_Proc;
d->scope_index = p->scope_index;
d->block = p->curr_block;
+ d->pos = pos;
d->context_stack_count = p->context_stack.count;
d->proc.deferred = deferred;
d->proc.result_as_args = result_as_args;