| ... | @@ -225,6 +225,14 @@ static AstNode *add_typedef_node(Context *c, TypeTableEntry *type_decl) { | ... | @@ -225,6 +225,14 @@ static AstNode *add_typedef_node(Context *c, TypeTableEntry *type_decl) { |
| 225 | return node; | 225 | return node; |
| 226 | } | 226 | } |
| 227 | | 227 | |
| | 228 | static AstNode *add_const_var_node(Context *c, Buf *name, TypeTableEntry *type_entry) { |
| | 229 | AstNode *node = create_var_decl_node(c, buf_ptr(name), make_type_node(c, type_entry)); |
| | 230 | |
| | 231 | c->global_type_table.put(name, type_entry); |
| | 232 | c->root->data.root.top_level_decls.append(node); |
| | 233 | return node; |
| | 234 | } |
| | 235 | |
| 228 | static TypeTableEntry *get_c_void_type(Context *c) { | 236 | static TypeTableEntry *get_c_void_type(Context *c) { |
| 229 | if (!c->c_void_type) { | 237 | if (!c->c_void_type) { |
| 230 | c->c_void_type = get_typedecl_type(c->codegen, "c_void", c->codegen->builtin_types.entry_u8); | 238 | c->c_void_type = get_typedecl_type(c->codegen, "c_void", c->codegen->builtin_types.entry_u8); |
| ... | @@ -625,8 +633,7 @@ static void visit_typedef_decl(Context *c, const TypedefNameDecl *typedef_decl) | ... | @@ -625,8 +633,7 @@ static void visit_typedef_decl(Context *c, const TypedefNameDecl *typedef_decl) |
| 625 | emit_warning(c, typedef_decl, "typedef %s - unresolved child type", buf_ptr(type_name)); | 633 | emit_warning(c, typedef_decl, "typedef %s - unresolved child type", buf_ptr(type_name)); |
| 626 | return; | 634 | return; |
| 627 | } | 635 | } |
| 628 | TypeTableEntry *decl_type = get_typedecl_type(c->codegen, buf_ptr(type_name), child_type); | 636 | add_const_var_node(c, type_name, child_type); |
| 629 | add_typedef_node(c, decl_type); | | |
| 630 | } | 637 | } |
| 631 | | 638 | |
| 632 | static void add_alias(Context *c, const char *new_name, const char *target_name) { | 639 | static void add_alias(Context *c, const char *new_name, const char *target_name) { |
| ... | @@ -803,7 +810,15 @@ static TypeTableEntry *resolve_record_decl(Context *c, const RecordDecl *record_ | ... | @@ -803,7 +810,15 @@ static TypeTableEntry *resolve_record_decl(Context *c, const RecordDecl *record_ |
| 803 | c->struct_type_table.put(bare_name, struct_type); | 810 | c->struct_type_table.put(bare_name, struct_type); |
| 804 | | 811 | |
| 805 | RecordDecl *record_def = record_decl->getDefinition(); | 812 | RecordDecl *record_def = record_decl->getDefinition(); |
| | 813 | unsigned line = c->source_node ? c->source_node->line : 0; |
| 806 | if (!record_def) { | 814 | if (!record_def) { |
| | 815 | LLVMZigDIType *replacement_di_type = LLVMZigCreateDebugForwardDeclType(c->codegen->dbuilder, |
| | 816 | LLVMZigTag_DW_structure_type(), buf_ptr(full_type_name), |
| | 817 | LLVMZigFileToScope(c->import->di_file), c->import->di_file, line); |
| | 818 | |
| | 819 | LLVMZigReplaceTemporary(c->codegen->dbuilder, struct_type->di_type, replacement_di_type); |
| | 820 | struct_type->di_type = replacement_di_type; |
| | 821 | |
| 807 | return struct_type; | 822 | return struct_type; |
| 808 | } | 823 | } |
| 809 | | 824 | |
| ... | @@ -835,7 +850,6 @@ static TypeTableEntry *resolve_record_decl(Context *c, const RecordDecl *record_ | ... | @@ -835,7 +850,6 @@ static TypeTableEntry *resolve_record_decl(Context *c, const RecordDecl *record_ |
| 835 | uint64_t offset_in_bits = 0; | 850 | uint64_t offset_in_bits = 0; |
| 836 | | 851 | |
| 837 | uint32_t i = 0; | 852 | uint32_t i = 0; |
| 838 | unsigned line = c->source_node ? c->source_node->line : 0; | | |
| 839 | for (auto it = record_def->field_begin(), | 853 | for (auto it = record_def->field_begin(), |
| 840 | it_end = record_def->field_end(); | 854 | it_end = record_def->field_end(); |
| 841 | it != it_end; ++it, i += 1) | 855 | it != it_end; ++it, i += 1) |