aboutsummaryrefslogtreecommitdiff
path: root/src/analyze.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-11-02 21:53:50 -0400
committerAndrew Kelley <superjoe30@gmail.com>2017-11-02 21:57:55 -0400
commitdc8b011d616991da166ad83795bf0b7e90471bd3 (patch)
treed931c6d99ce0d7a8a90a615530592e34405c2d41 /src/analyze.cpp
parentabff1b688420eb30d98145d8bc48e7d08f259885 (diff)
downloadzig-dc8b011d616991da166ad83795bf0b7e90471bd3.tar.gz
zig-dc8b011d616991da166ad83795bf0b7e90471bd3.zip
fix incorrect debug info for empty structs
closes #579 now all tests pass for llvm master branch
Diffstat (limited to 'src/analyze.cpp')
-rw-r--r--src/analyze.cpp17
1 files changed, 15 insertions, 2 deletions
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);