mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
Keep ASAN happy on type assertions
This commit is contained in:
@@ -124,8 +124,16 @@ gb_internal void lb_mem_zero_ptr(lbProcedure *p, LLVMValueRef ptr, Type *type, u
|
|||||||
switch (kind) {
|
switch (kind) {
|
||||||
case LLVMStructTypeKind:
|
case LLVMStructTypeKind:
|
||||||
case LLVMArrayTypeKind:
|
case LLVMArrayTypeKind:
|
||||||
// NOTE(bill): Enforce zeroing through memset to make sure padding is zeroed too
|
if (is_type_tuple(type)) {
|
||||||
lb_mem_zero_ptr_internal(p, ptr, lb_const_int(p->module, t_int, sz).value, alignment, false);
|
// NOTE(bill): even though this should be safe, to keep ASAN happy, do not zero the implicit padding at the end
|
||||||
|
GB_ASSERT(type->kind == Type_Tuple);
|
||||||
|
i64 n = type->Tuple.variables.count-1;
|
||||||
|
i64 end_offset = type->Tuple.offsets[n] + type_size_of(type->Tuple.variables[n]->type);
|
||||||
|
lb_mem_zero_ptr_internal(p, ptr, lb_const_int(p->module, t_int, end_offset).value, alignment, false);
|
||||||
|
} else {
|
||||||
|
// NOTE(bill): Enforce zeroing through memset to make sure padding is zeroed too
|
||||||
|
lb_mem_zero_ptr_internal(p, ptr, lb_const_int(p->module, t_int, sz).value, alignment, false);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LLVMBuildStore(p->builder, LLVMConstNull(lb_type(p->module, type)), ptr);
|
LLVMBuildStore(p->builder, LLVMConstNull(lb_type(p->module, type)), ptr);
|
||||||
|
|||||||
Reference in New Issue
Block a user