Commit 1d7861a36e
Changed files (4)
lib
std
crypto
lib/std/crypto/sha2.zig
@@ -167,8 +167,7 @@ fn Sha2_32(comptime params: Sha2Params32) type {
const rr = d.s[0 .. params.out_len / 32];
for (rr) |s, j| {
- // TODO https://github.com/ziglang/zig/issues/863
- mem.writeIntSliceBig(u32, out[4 * j .. 4 * j + 4], s);
+ mem.writeIntBig(u32, out[4 * j ..][0..4], s);
}
}
@@ -509,8 +508,7 @@ fn Sha2_64(comptime params: Sha2Params64) type {
const rr = d.s[0 .. params.out_len / 64];
for (rr) |s, j| {
- // TODO https://github.com/ziglang/zig/issues/863
- mem.writeIntSliceBig(u64, out[8 * j .. 8 * j + 8], s);
+ mem.writeIntBig(u64, out[8 * j ..][0..8], s);
}
}
src/all_types.hpp
@@ -3711,6 +3711,7 @@ struct IrInstGenSlice {
IrInstGen *start;
IrInstGen *end;
IrInstGen *result_loc;
+ ZigValue *sentinel;
bool safety_check_on;
};
src/codegen.cpp
@@ -5425,17 +5425,9 @@ static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutableGen *executable, IrI
return nullptr;
}
- ZigValue *sentinel = nullptr;
- if (result_type->id == ZigTypeIdPointer) {
- ZigType *result_array_type = result_type->data.pointer.child_type;
- ir_assert(result_array_type->id == ZigTypeIdArray, &instruction->base);
- sentinel = result_array_type->data.array.sentinel;
- } else if (result_type->id == ZigTypeIdStruct) {
- ZigType *res_slice_ptr_type = result_type->data.structure.fields[slice_ptr_index]->type_entry;
- sentinel = res_slice_ptr_type->data.pointer.sentinel;
- } else {
- zig_unreachable();
- }
+ // This is not whether the result type has a sentinel, but whether there should be a sentinel check,
+ // e.g. if they used [a..b :s] syntax.
+ ZigValue *sentinel = instruction->sentinel;
if (array_type->id == ZigTypeIdArray ||
(array_type->id == ZigTypeIdPointer && array_type->data.pointer.ptr_len == PtrLenSingle))
src/ir.cpp
@@ -3732,7 +3732,8 @@ static IrInstSrc *ir_build_slice_src(IrBuilderSrc *irb, Scope *scope, AstNode *s
}
static IrInstGen *ir_build_slice_gen(IrAnalyze *ira, IrInst *source_instruction, ZigType *slice_type,
- IrInstGen *ptr, IrInstGen *start, IrInstGen *end, bool safety_check_on, IrInstGen *result_loc)
+ IrInstGen *ptr, IrInstGen *start, IrInstGen *end, bool safety_check_on, IrInstGen *result_loc,
+ ZigValue *sentinel)
{
IrInstGenSlice *instruction = ir_build_inst_gen<IrInstGenSlice>(
&ira->new_irb, source_instruction->scope, source_instruction->source_node);
@@ -3742,6 +3743,7 @@ static IrInstGen *ir_build_slice_gen(IrAnalyze *ira, IrInst *source_instruction,
instruction->end = end;
instruction->safety_check_on = safety_check_on;
instruction->result_loc = result_loc;
+ instruction->sentinel = sentinel;
ir_ref_inst_gen(ptr, ira->new_irb.current_basic_block);
ir_ref_inst_gen(start, ira->new_irb.current_basic_block);
@@ -26667,7 +26669,7 @@ done_with_return_type:
}
return ir_build_slice_gen(ira, &instruction->base.base, return_type, ptr_ptr,
- casted_start, end, instruction->safety_check_on, result_loc);
+ casted_start, end, instruction->safety_check_on, result_loc, sentinel_val);
}
static IrInstGen *ir_analyze_instruction_has_field(IrAnalyze *ira, IrInstSrcHasField *instruction) {