| ... | @@ -838,6 +838,16 @@ static void visit_enum_decl(Context *c, const EnumDecl *enum_decl) { | ... | @@ -838,6 +838,16 @@ static void visit_enum_decl(Context *c, const EnumDecl *enum_decl) { |
| 838 | | 838 | |
| 839 | } | 839 | } |
| 840 | | 840 | |
| | 841 | static void replace_with_fwd_decl(Context *c, TypeTableEntry *struct_type, Buf *full_type_name) { |
| | 842 | unsigned line = c->source_node ? c->source_node->line : 0; |
| | 843 | LLVMZigDIType *replacement_di_type = LLVMZigCreateDebugForwardDeclType(c->codegen->dbuilder, |
| | 844 | LLVMZigTag_DW_structure_type(), buf_ptr(full_type_name), |
| | 845 | LLVMZigFileToScope(c->import->di_file), c->import->di_file, line); |
| | 846 | |
| | 847 | LLVMZigReplaceTemporary(c->codegen->dbuilder, struct_type->di_type, replacement_di_type); |
| | 848 | struct_type->di_type = replacement_di_type; |
| | 849 | } |
| | 850 | |
| 841 | static TypeTableEntry *resolve_record_decl(Context *c, const RecordDecl *record_decl) { | 851 | static TypeTableEntry *resolve_record_decl(Context *c, const RecordDecl *record_decl) { |
| 842 | const char *raw_name = decl_name(record_decl); | 852 | const char *raw_name = decl_name(record_decl); |
| 843 | | 853 | |
| ... | @@ -869,13 +879,7 @@ static TypeTableEntry *resolve_record_decl(Context *c, const RecordDecl *record_ | ... | @@ -869,13 +879,7 @@ static TypeTableEntry *resolve_record_decl(Context *c, const RecordDecl *record_ |
| 869 | RecordDecl *record_def = record_decl->getDefinition(); | 879 | RecordDecl *record_def = record_decl->getDefinition(); |
| 870 | unsigned line = c->source_node ? c->source_node->line : 0; | 880 | unsigned line = c->source_node ? c->source_node->line : 0; |
| 871 | if (!record_def) { | 881 | if (!record_def) { |
| 872 | LLVMZigDIType *replacement_di_type = LLVMZigCreateDebugForwardDeclType(c->codegen->dbuilder, | 882 | replace_with_fwd_decl(c, struct_type, full_type_name); |
| 873 | LLVMZigTag_DW_structure_type(), buf_ptr(full_type_name), | | |
| 874 | LLVMZigFileToScope(c->import->di_file), c->import->di_file, line); | | |
| 875 | | | |
| 876 | LLVMZigReplaceTemporary(c->codegen->dbuilder, struct_type->di_type, replacement_di_type); | | |
| 877 | struct_type->di_type = replacement_di_type; | | |
| 878 | | | |
| 879 | return struct_type; | 883 | return struct_type; |
| 880 | } | 884 | } |
| 881 | | 885 | |
| ... | @@ -890,6 +894,7 @@ static TypeTableEntry *resolve_record_decl(Context *c, const RecordDecl *record_ | ... | @@ -890,6 +894,7 @@ static TypeTableEntry *resolve_record_decl(Context *c, const RecordDecl *record_ |
| 890 | | 894 | |
| 891 | if (field_decl->isBitField()) { | 895 | if (field_decl->isBitField()) { |
| 892 | emit_warning(c, field_decl, "struct %s demoted to typedef - has bitfield\n", buf_ptr(bare_name)); | 896 | emit_warning(c, field_decl, "struct %s demoted to typedef - has bitfield\n", buf_ptr(bare_name)); |
| | 897 | replace_with_fwd_decl(c, struct_type, full_type_name); |
| 893 | return struct_type; | 898 | return struct_type; |
| 894 | } | 899 | } |
| 895 | } | 900 | } |
| ... | @@ -918,6 +923,7 @@ static TypeTableEntry *resolve_record_decl(Context *c, const RecordDecl *record_ | ... | @@ -918,6 +923,7 @@ static TypeTableEntry *resolve_record_decl(Context *c, const RecordDecl *record_ |
| 918 | | 923 | |
| 919 | if (field_type->id == TypeTableEntryIdInvalid) { | 924 | if (field_type->id == TypeTableEntryIdInvalid) { |
| 920 | emit_warning(c, field_decl, "struct %s demoted to typedef - unresolved type\n", buf_ptr(bare_name)); | 925 | emit_warning(c, field_decl, "struct %s demoted to typedef - unresolved type\n", buf_ptr(bare_name)); |
| | 926 | replace_with_fwd_decl(c, struct_type, full_type_name); |
| 921 | return struct_type; | 927 | return struct_type; |
| 922 | } | 928 | } |
| 923 | | 929 | |