Skip to content

Commit dc8b011

Browse files
committedNov 3, 2017
fix incorrect debug info for empty structs
closes #579 now all tests pass for llvm master branch
1 parent abff1b6 commit dc8b011

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed
 

‎src/analyze.cpp

+15-2
Original file line numberDiff line numberDiff line change
@@ -1712,8 +1712,21 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {
17121712

17131713
if (struct_type->zero_bits) {
17141714
struct_type->type_ref = LLVMVoidType();
1715-
ZigLLVMReplaceTemporary(g->dbuilder, struct_type->di_type, g->builtin_types.entry_void->di_type);
1716-
struct_type->di_type = g->builtin_types.entry_void->di_type;
1715+
1716+
ImportTableEntry *import = get_scope_import(scope);
1717+
uint64_t debug_size_in_bits = 0;
1718+
uint64_t debug_align_in_bits = 0;
1719+
ZigLLVMDIType **di_element_types = nullptr;
1720+
size_t debug_field_count = 0;
1721+
ZigLLVMDIType *replacement_di_type = ZigLLVMCreateDebugStructType(g->dbuilder,
1722+
ZigLLVMFileToScope(import->di_file),
1723+
buf_ptr(&struct_type->name),
1724+
import->di_file, (unsigned)(decl_node->line + 1),
1725+
debug_size_in_bits,
1726+
debug_align_in_bits,
1727+
0, nullptr, di_element_types, (int)debug_field_count, 0, nullptr, "");
1728+
ZigLLVMReplaceTemporary(g->dbuilder, struct_type->di_type, replacement_di_type);
1729+
struct_type->di_type = replacement_di_type;
17171730
return;
17181731
}
17191732
assert(struct_type->di_type);

0 commit comments

Comments
 (0)
Please sign in to comment.