| ... | @@ -16898,8 +16898,9 @@ static IrInstGen *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrInstSrc | ... | @@ -16898,8 +16898,9 @@ static IrInstGen *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrInstSrc |
| 16898 | if (target_type->id == ZigTypeIdEnumLiteral) { | 16898 | if (target_type->id == ZigTypeIdEnumLiteral) { |
| 16899 | IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr); | 16899 | IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr); |
| 16900 | Buf *field_name = target->value->data.x_enum_literal; | 16900 | Buf *field_name = target->value->data.x_enum_literal; |
| 16901 | ZigValue *array_val = create_const_str_lit(ira->codegen, field_name)->data.x_ptr.data.ref.pointee; | 16901 | result->value = create_sentineled_str_lit( |
| 16902 | init_const_slice(ira->codegen, result->value, array_val, 0, buf_len(field_name), true); | 16902 | ira->codegen, field_name, |
| | 16903 | ira->codegen->intern.for_zero_byte()); |
| 16903 | return result; | 16904 | return result; |
| 16904 | } | 16905 | } |
| 16905 | | 16906 | |
| ... | @@ -16918,9 +16919,10 @@ static IrInstGen *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrInstSrc | ... | @@ -16918,9 +16919,10 @@ static IrInstGen *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrInstSrc |
| 16918 | | 16919 | |
| 16919 | if (can_fold_enum_type(target_type)) { | 16920 | if (can_fold_enum_type(target_type)) { |
| 16920 | TypeEnumField *only_field = &target_type->data.enumeration.fields[0]; | 16921 | TypeEnumField *only_field = &target_type->data.enumeration.fields[0]; |
| 16921 | ZigValue *array_val = create_const_str_lit(ira->codegen, only_field->name)->data.x_ptr.data.ref.pointee; | | |
| 16922 | IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr); | 16922 | IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr); |
| 16923 | init_const_slice(ira->codegen, result->value, array_val, 0, buf_len(only_field->name), true); | 16923 | result->value = create_sentineled_str_lit( |
| | 16924 | ira->codegen, only_field->name, |
| | 16925 | ira->codegen->intern.for_zero_byte()); |
| 16924 | return result; | 16926 | return result; |
| 16925 | } | 16927 | } |
| 16926 | | 16928 | |
| ... | @@ -16936,16 +16938,17 @@ static IrInstGen *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrInstSrc | ... | @@ -16936,16 +16938,17 @@ static IrInstGen *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrInstSrc |
| 16936 | buf_sprintf("no tag by value %s", buf_ptr(int_buf))); | 16938 | buf_sprintf("no tag by value %s", buf_ptr(int_buf))); |
| 16937 | return ira->codegen->invalid_inst_gen; | 16939 | return ira->codegen->invalid_inst_gen; |
| 16938 | } | 16940 | } |
| 16939 | ZigValue *array_val = create_const_str_lit(ira->codegen, field->name)->data.x_ptr.data.ref.pointee; | | |
| 16940 | IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr); | 16941 | IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr); |
| 16941 | init_const_slice(ira->codegen, result->value, array_val, 0, buf_len(field->name), true); | 16942 | result->value = create_sentineled_str_lit( |
| | 16943 | ira->codegen, field->name, |
| | 16944 | ira->codegen->intern.for_zero_byte()); |
| 16942 | return result; | 16945 | return result; |
| 16943 | } | 16946 | } |
| 16944 | | 16947 | |
| 16945 | ZigType *u8_ptr_type = get_pointer_to_type_extra( | 16948 | ZigType *u8_ptr_type = get_pointer_to_type_extra2( |
| 16946 | ira->codegen, ira->codegen->builtin_types.entry_u8, | 16949 | ira->codegen, ira->codegen->builtin_types.entry_u8, |
| 16947 | true, false, PtrLenUnknown, | 16950 | true, false, PtrLenUnknown, 0, 0, 0, false, |
| 16948 | 0, 0, 0, false); | 16951 | VECTOR_INDEX_NONE, nullptr, ira->codegen->intern.for_zero_byte()); |
| 16949 | ZigType *result_type = get_slice_type(ira->codegen, u8_ptr_type); | 16952 | ZigType *result_type = get_slice_type(ira->codegen, u8_ptr_type); |
| 16950 | return ir_build_tag_name_gen(ira, &instruction->base.base, target, result_type); | 16953 | return ir_build_tag_name_gen(ira, &instruction->base.base, target, result_type); |
| 16951 | } | 16954 | } |