Skip to content

Commit 2aae4cf

Browse files
committed
fix #no_nil in debug info
Fixes #4664
1 parent 30bb225 commit 2aae4cf

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/llvm_backend_debug.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ gb_internal LLVMMetadataRef lb_debug_union(lbModule *m, Type *type, String name,
415415
LLVMMetadataRef member_scope = lb_get_llvm_metadata(m, bt->Union.scope);
416416
unsigned element_count = cast(unsigned)bt->Union.variants.count;
417417
if (index_offset > 0) {
418+
GB_ASSERT(index_offset == 1);
418419
element_count += 1;
419420
}
420421

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

440-
unsigned field_index = cast(unsigned)(index_offset+j);
441-
442-
char name[16] = {};
443-
gb_snprintf(name, gb_size_of(name), "v%u", field_index);
441+
char name[32] = {};
442+
gb_snprintf(name, gb_size_of(name), "v%td", j);
444443
isize name_len = gb_strlen(name);
445444

446-
elements[field_index] = LLVMDIBuilderCreateMemberType(
445+
elements[index_offset+j] = LLVMDIBuilderCreateMemberType(
447446
m->debug_builder, member_scope,
448447
name, name_len,
449448
file, line,

0 commit comments

Comments
 (0)