From dc8b011d616991da166ad83795bf0b7e90471bd3 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 2 Nov 2017 21:53:50 -0400 Subject: fix incorrect debug info for empty structs closes #579 now all tests pass for llvm master branch --- src/analyze.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/analyze.cpp') diff --git a/src/analyze.cpp b/src/analyze.cpp index 0bc3343f6c..4258a4d7d6 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -1712,8 +1712,21 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) { if (struct_type->zero_bits) { struct_type->type_ref = LLVMVoidType(); - ZigLLVMReplaceTemporary(g->dbuilder, struct_type->di_type, g->builtin_types.entry_void->di_type); - struct_type->di_type = g->builtin_types.entry_void->di_type; + + ImportTableEntry *import = get_scope_import(scope); + uint64_t debug_size_in_bits = 0; + uint64_t debug_align_in_bits = 0; + ZigLLVMDIType **di_element_types = nullptr; + size_t debug_field_count = 0; + ZigLLVMDIType *replacement_di_type = ZigLLVMCreateDebugStructType(g->dbuilder, + ZigLLVMFileToScope(import->di_file), + buf_ptr(&struct_type->name), + import->di_file, (unsigned)(decl_node->line + 1), + debug_size_in_bits, + debug_align_in_bits, + 0, nullptr, di_element_types, (int)debug_field_count, 0, nullptr, ""); + ZigLLVMReplaceTemporary(g->dbuilder, struct_type->di_type, replacement_di_type); + struct_type->di_type = replacement_di_type; return; } assert(struct_type->di_type); -- cgit v1.2.3