Skip to content

Instantly share code, notes, and snippets.

@andrewrk
Created May 11, 2021 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewrk/14df655282b08e240d2637027c28d350 to your computer and use it in GitHub Desktop.
Save andrewrk/14df655282b08e240d2637027c28d350 to your computer and use it in GitHub Desktop.
reset error return trace index
if (instruction->operand != nullptr &&
instruction->operand->value->type->id != ZigTypeIdErrorSet &&
instruction->operand->value->type->id != ZigTypeIdErrorUnion)
{
// Reset error return trace index.
bool is_llvm_alloca = false;
LLVMValueRef err_ret_trace_ptr = get_cur_err_ret_trace_val(g, instruction->base.base.scope, &is_llvm_alloca);
if (err_ret_trace_ptr != nullptr) {
size_t index_field_index = g->stack_trace_type->data.structure.fields[0]->gen_index;
LLVMValueRef index_field_ptr = LLVMBuildStructGEP(g->builder, err_ret_trace_ptr, (unsigned)index_field_index, "");
LLVMValueRef zero = LLVMConstNull(g->builtin_types.entry_usize->llvm_type);
gen_store_untyped(g, zero, index_field_ptr, 0, false);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment