| author | |
| committer | |
| log | 22c52f1eb67a46e60be876fda332ad7d2f338ee7 |
| tree | 8aad02e3a9116d450dfc0350e5c1bb3feb8a1d6e |
| parent | 4514661cfef1cd0090ba9888b69037af3ef9805a |
3 files changed, 18 insertions(+), 2 deletions(-)
src/analyze.cpp+12| ... | ... | @@ -506,6 +506,16 @@ static void preview_fn_def(CodeGen *g, ImportTableEntry *import, AstNode *node, |
| 506 | 506 | fn_table_entry->internal_linkage = is_internal; |
| 507 | 507 | fn_table_entry->calling_convention = is_internal ? LLVMFastCallConv : LLVMCCallConv; |
| 508 | 508 | fn_table_entry->label_table.init(8); |
| 509 | fn_table_entry->member_of_struct = struct_type; | |
| 510 | ||
| 511 | if (struct_type) { | |
| 512 | buf_resize(&fn_table_entry->symbol_name, 0); | |
| 513 | buf_appendf(&fn_table_entry->symbol_name, "%s_%s", | |
| 514 | buf_ptr(&struct_type->name), | |
| 515 | buf_ptr(proto_name)); | |
| 516 | } else { | |
| 517 | buf_init_from_buf(&fn_table_entry->symbol_name, proto_name); | |
| 518 | } | |
| 509 | 519 | |
| 510 | 520 | g->fn_protos.append(fn_table_entry); |
| 511 | 521 | g->fn_defs.append(fn_table_entry); |
| ... | ... | @@ -556,6 +566,8 @@ static void preview_function_declarations(CodeGen *g, ImportTableEntry *import, |
| 556 | 566 | fn_table_entry->import_entry = import; |
| 557 | 567 | fn_table_entry->label_table.init(8); |
| 558 | 568 | |
| 569 | buf_init_from_buf(&fn_table_entry->symbol_name, &fn_proto->data.fn_proto.name); | |
| 570 | ||
| 559 | 571 | resolve_function_proto(g, fn_proto, fn_table_entry, import); |
| 560 | 572 | |
| 561 | 573 | Buf *name = &fn_proto->data.fn_proto.name; |
src/analyze.hpp+2| ... | ... | @@ -138,6 +138,8 @@ struct FnTableEntry { |
| 138 | 138 | ZigList<FnAttrId> fn_attr_list; |
| 139 | 139 | // Required to be a pre-order traversal of the AST. (parents must come before children) |
| 140 | 140 | ZigList<BlockContext *> all_block_contexts; |
| 141 | TypeTableEntry *member_of_struct; | |
| 142 | Buf symbol_name; | |
| 141 | 143 | |
| 142 | 144 | // reminder: hash tables must be initialized before use |
| 143 | 145 | HashMap<Buf *, LabelTableEntry *, buf_hash, buf_eql_buf> label_table; |
src/codegen.cpp+4-2| ... | ... | @@ -1503,7 +1503,8 @@ static void do_code_gen(CodeGen *g) { |
| 1503 | 1503 | gen_param_index += 1; |
| 1504 | 1504 | } |
| 1505 | 1505 | LLVMTypeRef function_type = LLVMFunctionType(ret_type, param_types, param_count, fn_proto->is_var_args); |
| 1506 | LLVMValueRef fn = LLVMAddFunction(g->module, buf_ptr(&fn_proto->name), function_type); | |
| 1506 | ||
| 1507 | LLVMValueRef fn = LLVMAddFunction(g->module, buf_ptr(&fn_table_entry->symbol_name), function_type); | |
| 1507 | 1508 | |
| 1508 | 1509 | for (int attr_i = 0; attr_i < fn_table_entry->fn_attr_list.length; attr_i += 1) { |
| 1509 | 1510 | FnAttrId attr_id = fn_table_entry->fn_attr_list.at(attr_i); |
| ... | ... | @@ -1542,7 +1543,8 @@ static void do_code_gen(CodeGen *g) { |
| 1542 | 1543 | unsigned flags = 0; |
| 1543 | 1544 | bool is_optimized = g->build_type == CodeGenBuildTypeRelease; |
| 1544 | 1545 | LLVMZigDISubprogram *subprogram = LLVMZigCreateFunction(g->dbuilder, |
| 1545 | import->block_context->di_scope, buf_ptr(&fn_proto->name), "", import->di_file, line_number, | |
| 1546 | import->block_context->di_scope, buf_ptr(&fn_table_entry->symbol_name), "", | |
| 1547 | import->di_file, line_number, | |
| 1546 | 1548 | create_di_function_type(g, fn_proto, import->di_file), fn_table_entry->internal_linkage, |
| 1547 | 1549 | is_definition, scope_line, flags, is_optimized, fn); |
| 1548 | 1550 |