diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-03-10 18:07:28 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-03-10 18:07:28 -0400 |
| commit | 4cb55d3af6a71467b7d4399bedb961c81e9ad3d5 (patch) | |
| tree | bab3cda68f650e04b453d2fcfa6853e0af840c05 /src/codegen.cpp | |
| parent | b63b3dc75690b016309b19c9f91f454f5f7bf4bb (diff) | |
| parent | fec4555476e38d2eeb1dfb02572404b243acd0b2 (diff) | |
| download | zig-4cb55d3af6a71467b7d4399bedb961c81e9ad3d5.tar.gz zig-4cb55d3af6a71467b7d4399bedb961c81e9ad3d5.zip | |
Merge remote-tracking branch 'origin/master' into llvm8
Diffstat (limited to 'src/codegen.cpp')
| -rw-r--r-- | src/codegen.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp index 0620eb49d7..b996c2367a 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -3948,10 +3948,10 @@ static LLVMValueRef ir_render_asm(CodeGen *g, IrExecutable *executable, IrInstru static LLVMValueRef gen_non_null_bit(CodeGen *g, ZigType *maybe_type, LLVMValueRef maybe_handle) { assert(maybe_type->id == ZigTypeIdOptional); ZigType *child_type = maybe_type->data.maybe.child_type; - if (child_type->zero_bits) { + if (!type_has_bits(child_type)) { return maybe_handle; } else { - bool is_scalar = type_is_non_optional_pointer(child_type) || child_type->id == ZigTypeIdErrorSet; + bool is_scalar = !handle_is_ptr(maybe_type); if (is_scalar) { return LLVMBuildICmp(g->builder, LLVMIntNE, maybe_handle, LLVMConstNull(maybe_type->type_ref), ""); } else { @@ -3991,7 +3991,7 @@ static LLVMValueRef ir_render_optional_unwrap_ptr(CodeGen *g, IrExecutable *exec if (child_type->zero_bits) { return nullptr; } else { - bool is_scalar = type_is_non_optional_pointer(child_type) || child_type->id == ZigTypeIdErrorSet; + bool is_scalar = !handle_is_ptr(maybe_type); if (is_scalar) { return maybe_ptr; } else { @@ -4854,7 +4854,7 @@ static LLVMValueRef ir_render_maybe_wrap(CodeGen *g, IrExecutable *executable, I } LLVMValueRef payload_val = ir_llvm_value(g, instruction->value); - if (type_is_non_optional_pointer(child_type) || child_type->id == ZigTypeIdErrorSet) { + if (!handle_is_ptr(wanted_type)) { return payload_val; } @@ -8690,10 +8690,10 @@ static void get_c_type(CodeGen *g, GenH *gen_h, ZigType *type_entry, Buf *out_bu case ZigTypeIdOptional: { ZigType *child_type = type_entry->data.maybe.child_type; - if (child_type->zero_bits) { + if (!type_has_bits(child_type)) { buf_init_from_str(out_buf, "bool"); return; - } else if (type_is_non_optional_pointer(child_type)) { + } else if (type_is_nonnull_ptr(child_type)) { return get_c_type(g, gen_h, child_type, out_buf); } else { zig_unreachable(); |
