Skip to content

Commit

Permalink
'#no_nil' I am actually disappointed in myself
Browse files Browse the repository at this point in the history
  • Loading branch information
laytan committed Jan 8, 2025
1 parent b3c3595 commit 2620721
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/llvm_backend_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,12 @@ gb_internal LLVMMetadataRef lb_debug_union(lbModule *m, Type *type, String name,
lb_set_llvm_metadata(m, type, temp_forward_decl);

isize index_offset = 1;
isize variant_offset = 1;
if (is_type_union_maybe_pointer(bt)) {
index_offset = 0;
variant_offset = 0;
} else if (bt->Union.kind == UnionType_no_nil) {
variant_offset = 0;
}

LLVMMetadataRef member_scope = lb_get_llvm_metadata(m, bt->Union.scope);
Expand Down Expand Up @@ -438,13 +442,8 @@ gb_internal LLVMMetadataRef lb_debug_union(lbModule *m, Type *type, String name,
for_array(j, bt->Union.variants) {
Type *variant = bt->Union.variants[j];

ptrdiff_t variant_index = j;
if (bt->Union.kind != UnionType_no_nil) {
variant_index += 1;
}

char name[32] = {};
gb_snprintf(name, gb_size_of(name), "v%td", variant_index);
gb_snprintf(name, gb_size_of(name), "v%td", variant_offset+j);
isize name_len = gb_strlen(name);

elements[index_offset+j] = LLVMDIBuilderCreateMemberType(
Expand Down

0 comments on commit 2620721

Please sign in to comment.