diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-04-02 19:40:33 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-04-02 19:40:33 -0400 |
| commit | 025a1475c45f0ba9d196e6584ea70d793a921c40 (patch) | |
| tree | 9b997e75f19a6379a284e65fa9d66519df214b0c /src/analyze.cpp | |
| parent | 6a7b75b73c502ecd6f34c497cc86bded02746cb2 (diff) | |
| download | zig-025a1475c45f0ba9d196e6584ea70d793a921c40.tar.gz zig-025a1475c45f0ba9d196e6584ea70d793a921c40.zip | |
emit better debug info for enums
fixes llvm assertion when building for windows
Diffstat (limited to 'src/analyze.cpp')
| -rw-r--r-- | src/analyze.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index 0f6f7ac799..394364c68f 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -6576,9 +6576,24 @@ static void resolve_llvm_types_enum(CodeGen *g, ZigType *enum_type) { assert(enum_type->data.enumeration.complete); if (enum_type->llvm_di_type != nullptr) return; + Scope *scope = &enum_type->data.enumeration.decls_scope->base; + ZigType *import = get_scope_import(scope); + AstNode *decl_node = enum_type->data.enumeration.decl_node; + if (!type_has_bits(enum_type)) { enum_type->llvm_type = g->builtin_types.entry_void->llvm_type; - enum_type->llvm_di_type = g->builtin_types.entry_void->llvm_di_type; + + 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; + enum_type->llvm_di_type = ZigLLVMCreateDebugStructType(g->dbuilder, + ZigLLVMFileToScope(import->data.structure.root_struct->di_file), + buf_ptr(&enum_type->name), + import->data.structure.root_struct->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, ""); return; } @@ -6587,9 +6602,6 @@ static void resolve_llvm_types_enum(CodeGen *g, ZigType *enum_type) { assert(enum_type->data.enumeration.fields); ZigLLVMDIEnumerator **di_enumerators = allocate<ZigLLVMDIEnumerator*>(field_count); - Scope *scope = &enum_type->data.enumeration.decls_scope->base; - ZigType *import = get_scope_import(scope); - for (uint32_t i = 0; i < field_count; i += 1) { TypeEnumField *enum_field = &enum_type->data.enumeration.fields[i]; @@ -6603,7 +6615,6 @@ static void resolve_llvm_types_enum(CodeGen *g, ZigType *enum_type) { enum_type->llvm_type = get_llvm_type(g, tag_int_type); // create debug type for tag - AstNode *decl_node = enum_type->data.enumeration.decl_node; uint64_t tag_debug_size_in_bits = tag_int_type->size_in_bits; uint64_t tag_debug_align_in_bits = 8*tag_int_type->abi_align; ZigLLVMDIType *tag_di_type = ZigLLVMCreateDebugEnumerationType(g->dbuilder, |
