mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-03 19:52:30 +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) {
|
||||
case LLVMStructTypeKind:
|
||||
case LLVMArrayTypeKind:
|
||||
// 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);
|
||||
if (is_type_tuple(type)) {
|
||||
// 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;
|
||||
default:
|
||||
LLVMBuildStore(p->builder, LLVMConstNull(lb_type(p->module, type)), ptr);
|
||||
|
||||
Reference in New Issue
Block a user