aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-06-10 17:28:25 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-06-10 17:28:25 -0400
commitb9c033ae1ac9c21a5729407b9a6ede88854654aa (patch)
tree421fbef2eaa5eecb2a83907779585b8a91c3ecd7 /src/codegen.cpp
parent4f085b8d2c8ffb03dd15b789ad5867904faae13d (diff)
downloadzig-b9c033ae1ac9c21a5729407b9a6ede88854654aa.tar.gz
zig-b9c033ae1ac9c21a5729407b9a6ede88854654aa.zip
result location semantics for error union wrapping an error
Diffstat (limited to 'src/codegen.cpp')
-rw-r--r--src/codegen.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp
index 69b234d160..ce844806d9 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -4977,20 +4977,19 @@ static LLVMValueRef ir_render_err_wrap_code(CodeGen *g, IrExecutable *executable
assert(wanted_type->id == ZigTypeIdErrorUnion);
- ZigType *payload_type = wanted_type->data.error_union.payload_type;
- ZigType *err_set_type = wanted_type->data.error_union.err_set_type;
+ LLVMValueRef err_val = ir_llvm_value(g, instruction->operand);
- LLVMValueRef err_val = ir_llvm_value(g, instruction->value);
-
- if (!type_has_bits(payload_type) || !type_has_bits(err_set_type))
+ if (!handle_is_ptr(wanted_type))
return err_val;
- assert(instruction->tmp_ptr);
+ LLVMValueRef result_loc = ir_llvm_value(g, instruction->result_loc);
- LLVMValueRef err_tag_ptr = LLVMBuildStructGEP(g->builder, instruction->tmp_ptr, err_union_err_index, "");
+ LLVMValueRef err_tag_ptr = LLVMBuildStructGEP(g->builder, result_loc, err_union_err_index, "");
gen_store_untyped(g, err_val, err_tag_ptr, 0, false);
- return instruction->tmp_ptr;
+ // TODO store undef to the payload
+
+ return result_loc;
}
static LLVMValueRef ir_render_err_wrap_payload(CodeGen *g, IrExecutable *executable, IrInstructionErrWrapPayload *instruction) {
@@ -6841,9 +6840,6 @@ static void do_code_gen(CodeGen *g) {
slot = &ref_instruction->tmp_ptr;
assert(instruction->value.type->id == ZigTypeIdPointer);
slot_type = instruction->value.type->data.pointer.child_type;
- } else if (instruction->id == IrInstructionIdErrWrapCode) {
- IrInstructionErrWrapCode *err_wrap_code_instruction = (IrInstructionErrWrapCode *)instruction;
- slot = &err_wrap_code_instruction->tmp_ptr;
} else if (instruction->id == IrInstructionIdCmpxchgGen) {
IrInstructionCmpxchgGen *cmpxchg_instruction = (IrInstructionCmpxchgGen *)instruction;
slot = &cmpxchg_instruction->tmp_ptr;