Compare commits

..

1 Commits

Author SHA1 Message Date
95e50753bf Compile the compiler
All checks were successful
CI / ci (RelWithDebInfo, ubuntu-latest) (pull_request) Successful in 5m32s
CI / ci (MinSizeRel, ubuntu-latest) (pull_request) Successful in 5m38s
CI / ci (Release, ubuntu-latest) (pull_request) Successful in 5m24s
CI / ci (Debug, ubuntu-latest) (pull_request) Successful in 19m29s
2025-06-20 09:30:56 -06:00

View File

@ -7094,7 +7094,7 @@ fn void emit_macro_instantiation(Module* module, Value* value)
} }
} }
fn void analyze_statement(Module* module, Scope* scope, Statement* statement, u32* last_line, u32* last_column, LLVMMetadataRef* last_debug_location); fn void analyze_statement(Module* module, Scope* scope, Statement* statement);
fn void analyze_block(Module* module, Block* block) fn void analyze_block(Module* module, Block* block)
{ {
@ -7110,7 +7110,7 @@ fn void analyze_block(Module* module, Block* block)
for (auto* statement = block->first_statement; statement; statement = statement->next) for (auto* statement = block->first_statement; statement; statement = statement->next)
{ {
analyze_statement(module, &block->scope, statement, &last_line, &last_column, &last_debug_location); analyze_statement(module, &block->scope, statement);
} }
} }
@ -8220,7 +8220,7 @@ fn void analyze_value(Module* module, Value* value, Type* expected_type, TypeKin
emit_value(module, value, type_kind, must_be_constant); emit_value(module, value, type_kind, must_be_constant);
} }
fn void analyze_statement(Module* module, Scope* scope, Statement* statement, u32* last_line, u32* last_column, LLVMMetadataRef* last_debug_location) fn void analyze_statement(Module* module, Scope* scope, Statement* statement)
{ {
Global* parent_function_global; Global* parent_function_global;
if (module->current_function) if (module->current_function)
@ -8239,16 +8239,12 @@ fn void analyze_statement(Module* module, Scope* scope, Statement* statement, u3
auto* llvm_function = parent_function_global->variable.storage->llvm; auto* llvm_function = parent_function_global->variable.storage->llvm;
assert(llvm_function); assert(llvm_function);
LLVMMetadataRef statement_location = 0;
if (module->has_debug_info) if (module->has_debug_info)
{ {
if (statement->line != *last_line || statement->column != *last_column) statement_location = LLVMDIBuilderCreateDebugLocation(module->llvm.context, statement->line, statement->column, scope->llvm, module->llvm.inlined_at);
{ LLVMSetCurrentDebugLocation2(module->llvm.builder, statement_location);
auto new_location = LLVMDIBuilderCreateDebugLocation(module->llvm.context, statement->line, statement->column, scope->llvm, module->llvm.inlined_at);
*last_debug_location = new_location;
LLVMSetCurrentDebugLocation2(module->llvm.builder, new_location);
*last_line = statement->line;
*last_column = statement->column;
}
} }
switch (statement->id) switch (statement->id)
@ -8280,7 +8276,7 @@ fn void analyze_statement(Module* module, Scope* scope, Statement* statement, u3
{ {
if (module->has_debug_info) if (module->has_debug_info)
{ {
LLVMSetCurrentDebugLocation2(module->llvm.builder, *last_debug_location); LLVMSetCurrentDebugLocation2(module->llvm.builder, statement_location);
} }
auto return_alloca = module->current_function->variable.storage->function.llvm.return_alloca; auto return_alloca = module->current_function->variable.storage->function.llvm.return_alloca;
@ -8347,7 +8343,7 @@ fn void analyze_statement(Module* module, Scope* scope, Statement* statement, u3
LLVMBuildCondBr(module->llvm.builder, llvm_condition, taken_block, not_taken_block); LLVMBuildCondBr(module->llvm.builder, llvm_condition, taken_block, not_taken_block);
LLVMPositionBuilderAtEnd(module->llvm.builder, taken_block); LLVMPositionBuilderAtEnd(module->llvm.builder, taken_block);
analyze_statement(module, scope, statement->if_st.if_statement, last_line, last_column, last_debug_location); analyze_statement(module, scope, statement->if_st.if_statement);
if (LLVMGetInsertBlock(module->llvm.builder)) if (LLVMGetInsertBlock(module->llvm.builder))
{ {
@ -8358,7 +8354,7 @@ fn void analyze_statement(Module* module, Scope* scope, Statement* statement, u3
auto else_statement = statement->if_st.else_statement; auto else_statement = statement->if_st.else_statement;
if (else_statement) if (else_statement)
{ {
analyze_statement(module, scope, else_statement, last_line, last_column, last_debug_location); analyze_statement(module, scope, else_statement);
} }
if (LLVMGetInsertBlock(module->llvm.builder)) if (LLVMGetInsertBlock(module->llvm.builder))
@ -8993,7 +8989,7 @@ fn void analyze_statement(Module* module, Scope* scope, Statement* statement, u3
assert(!local); assert(!local);
analyze_statement(module, &statement->for_each.scope, statement->for_each.predicate, last_line, last_column, last_debug_location); analyze_statement(module, &statement->for_each.scope, statement->for_each.predicate);
if (LLVMGetInsertBlock(module->llvm.builder)) if (LLVMGetInsertBlock(module->llvm.builder))
{ {
@ -9097,7 +9093,7 @@ fn void analyze_statement(Module* module, Scope* scope, Statement* statement, u3
LLVMBuildCondBr(module->llvm.builder, index_compare, body_block, exit_block); LLVMBuildCondBr(module->llvm.builder, index_compare, body_block, exit_block);
LLVMPositionBuilderAtEnd(module->llvm.builder, body_block); LLVMPositionBuilderAtEnd(module->llvm.builder, body_block);
analyze_statement(module, &statement->for_each.scope, statement->for_each.predicate, last_line, last_column, last_debug_location); analyze_statement(module, &statement->for_each.scope, statement->for_each.predicate);
if (LLVMGetInsertBlock(module->llvm.builder)) if (LLVMGetInsertBlock(module->llvm.builder))
{ {