| ... | ... | @@ -2152,6 +2152,15 @@ static LLVMValueRef gen_while_expr(CodeGen *g, AstNode *node) { |
| 2152 | 2152 | return nullptr; |
| 2153 | 2153 | } |
| 2154 | 2154 | |
| 2155 | static void gen_var_debug_decl(CodeGen *g, VariableTableEntry *var) { |
| 2156 | BlockContext *block_context = var->block_context; |
| 2157 | AstNode *source_node = block_context->node; |
| 2158 | LLVMZigDILocation *debug_loc = LLVMZigGetDebugLoc(source_node->line + 1, source_node->column + 1, |
| 2159 | block_context->di_scope); |
| 2160 | LLVMZigInsertDeclareAtEnd(g->dbuilder, var->value_ref, var->di_loc_var, debug_loc, |
| 2161 | LLVMGetInsertBlock(g->builder)); |
| 2162 | } |
| 2163 | |
| 2155 | 2164 | static LLVMValueRef gen_for_expr(CodeGen *g, AstNode *node) { |
| 2156 | 2165 | assert(node->type == NodeTypeForExpr); |
| 2157 | 2166 | assert(node->data.for_expr.array_expr); |
| ... | ... | @@ -2175,6 +2184,9 @@ static LLVMValueRef gen_for_expr(CodeGen *g, AstNode *node) { |
| 2175 | 2184 | LLVMValueRef array_val = gen_array_base_ptr(g, node->data.for_expr.array_expr); |
| 2176 | 2185 | add_debug_source_node(g, node); |
| 2177 | 2186 | LLVMBuildStore(g->builder, LLVMConstNull(index_var->type->type_ref), index_ptr); |
| 2187 | |
| 2188 | gen_var_debug_decl(g, index_var); |
| 2189 | |
| 2178 | 2190 | LLVMValueRef len_val; |
| 2179 | 2191 | TypeTableEntry *child_type; |
| 2180 | 2192 | if (array_type->id == TypeTableEntryIdArray) { |
| ... | ... | @@ -2203,6 +2215,7 @@ static LLVMValueRef gen_for_expr(CodeGen *g, AstNode *node) { |
| 2203 | 2215 | LLVMValueRef elem_val = handle_is_ptr(child_type) ? elem_ptr : LLVMBuildLoad(g->builder, elem_ptr, ""); |
| 2204 | 2216 | gen_assign_raw(g, node, BinOpTypeAssign, elem_var->value_ref, elem_val, |
| 2205 | 2217 | elem_var->type, child_type); |
| 2218 | gen_var_debug_decl(g, elem_var); |
| 2206 | 2219 | g->break_block_stack.append(end_block); |
| 2207 | 2220 | g->continue_block_stack.append(continue_block); |
| 2208 | 2221 | gen_expr(g, node->data.for_expr.body); |
| ... | ... | @@ -2335,10 +2348,7 @@ static LLVMValueRef gen_var_decl_raw(CodeGen *g, AstNode *source_node, AstNodeVa |
| 2335 | 2348 | } |
| 2336 | 2349 | } |
| 2337 | 2350 | |
| 2338 | | LLVMZigDILocation *debug_loc = LLVMZigGetDebugLoc(source_node->line + 1, source_node->column + 1, |
| 2339 | | source_node->block_context->di_scope); |
| 2340 | | LLVMZigInsertDeclareAtEnd(g->dbuilder, variable->value_ref, variable->di_loc_var, debug_loc, |
| 2341 | | LLVMGetInsertBlock(g->builder)); |
| 2351 | gen_var_debug_decl(g, variable); |
| 2342 | 2352 | return nullptr; |
| 2343 | 2353 | } |
| 2344 | 2354 | |
| ... | ... | @@ -3107,10 +3117,7 @@ static void do_code_gen(CodeGen *g) { |
| 3107 | 3117 | VariableTableEntry *variable = param_decl->data.param_decl.variable; |
| 3108 | 3118 | assert(variable); |
| 3109 | 3119 | |
| 3110 | | LLVMZigDILocation *debug_loc = LLVMZigGetDebugLoc(param_decl->line + 1, param_decl->column + 1, |
| 3111 | | fn_def_node->data.fn_def.block_context->di_scope); |
| 3112 | | LLVMZigInsertDeclareAtEnd(g->dbuilder, variable->value_ref, variable->di_loc_var, debug_loc, |
| 3113 | | entry_block); |
| 3120 | gen_var_debug_decl(g, variable); |
| 3114 | 3121 | } |
| 3115 | 3122 | |
| 3116 | 3123 | // allocate structs which are the result of casts |