authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-04-02 19:40:33-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-04-02 19:40:33-04:00
log025a1475c45f0ba9d196e6584ea70d793a921c40
tree9b997e75f19a6379a284e65fa9d66519df214b0c
parent6a7b75b73c502ecd6f34c497cc86bded02746cb2
signaturelock-open Commit is signed but in an unrecognized format.

emit better debug info for enums

fixes llvm assertion when building for windows

1 files changed, 16 insertions(+), 5 deletions(-)

src/analyze.cpp+16-5
......@@ -6576,9 +6576,24 @@ static void resolve_llvm_types_enum(CodeGen *g, ZigType *enum_type) {
65766576 assert(enum_type->data.enumeration.complete);
65776577 if (enum_type->llvm_di_type != nullptr) return;
65786578
6579 Scope *scope = &enum_type->data.enumeration.decls_scope->base;
6580 ZigType *import = get_scope_import(scope);
6581 AstNode *decl_node = enum_type->data.enumeration.decl_node;
6582
65796583 if (!type_has_bits(enum_type)) {
65806584 enum_type->llvm_type = g->builtin_types.entry_void->llvm_type;
6581 enum_type->llvm_di_type = g->builtin_types.entry_void->llvm_di_type;
6585
6586 uint64_t debug_size_in_bits = 0;
6587 uint64_t debug_align_in_bits = 0;
6588 ZigLLVMDIType **di_element_types = nullptr;
6589 size_t debug_field_count = 0;
6590 enum_type->llvm_di_type = ZigLLVMCreateDebugStructType(g->dbuilder,
6591 ZigLLVMFileToScope(import->data.structure.root_struct->di_file),
6592 buf_ptr(&enum_type->name),
6593 import->data.structure.root_struct->di_file, (unsigned)(decl_node->line + 1),
6594 debug_size_in_bits,
6595 debug_align_in_bits,
6596 0, nullptr, di_element_types, (int)debug_field_count, 0, nullptr, "");
65826597 return;
65836598 }
65846599
......@@ -6587,9 +6602,6 @@ static void resolve_llvm_types_enum(CodeGen *g, ZigType *enum_type) {
65876602 assert(enum_type->data.enumeration.fields);
65886603 ZigLLVMDIEnumerator **di_enumerators = allocate<ZigLLVMDIEnumerator*>(field_count);
65896604
6590 Scope *scope = &enum_type->data.enumeration.decls_scope->base;
6591 ZigType *import = get_scope_import(scope);
6592
65936605 for (uint32_t i = 0; i < field_count; i += 1) {
65946606 TypeEnumField *enum_field = &enum_type->data.enumeration.fields[i];
65956607
......@@ -6603,7 +6615,6 @@ static void resolve_llvm_types_enum(CodeGen *g, ZigType *enum_type) {
66036615 enum_type->llvm_type = get_llvm_type(g, tag_int_type);
66046616
66056617 // create debug type for tag
6606 AstNode *decl_node = enum_type->data.enumeration.decl_node;
66076618 uint64_t tag_debug_size_in_bits = tag_int_type->size_in_bits;
66086619 uint64_t tag_debug_align_in_bits = 8*tag_int_type->abi_align;
66096620 ZigLLVMDIType *tag_di_type = ZigLLVMCreateDebugEnumerationType(g->dbuilder,