Skip to content

Commit

Permalink
fix #no_nil in debug info
Browse files Browse the repository at this point in the history
Fixes #4664
  • Loading branch information
laytan committed Jan 8, 2025
1 parent 30bb225 commit 2aae4cf
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/llvm_backend_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ gb_internal LLVMMetadataRef lb_debug_union(lbModule *m, Type *type, String name,
LLVMMetadataRef member_scope = lb_get_llvm_metadata(m, bt->Union.scope);
unsigned element_count = cast(unsigned)bt->Union.variants.count;
if (index_offset > 0) {
GB_ASSERT(index_offset == 1);
element_count += 1;
}

Expand All @@ -437,13 +438,11 @@ gb_internal LLVMMetadataRef lb_debug_union(lbModule *m, Type *type, String name,
for_array(j, bt->Union.variants) {
Type *variant = bt->Union.variants[j];

unsigned field_index = cast(unsigned)(index_offset+j);

char name[16] = {};
gb_snprintf(name, gb_size_of(name), "v%u", field_index);
char name[32] = {};
gb_snprintf(name, gb_size_of(name), "v%td", j);
isize name_len = gb_strlen(name);

elements[field_index] = LLVMDIBuilderCreateMemberType(
elements[index_offset+j] = LLVMDIBuilderCreateMemberType(
m->debug_builder, member_scope,
name, name_len,
file, line,
Expand Down

0 comments on commit 2aae4cf

Please sign in to comment.