From add53228b2ee93f7374a815ce1c4e5a86b7b9d28 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 18 Jan 2018 12:22:27 +0000 Subject: `-no-bounds-check` --- src/ir.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/ir.cpp') diff --git a/src/ir.cpp b/src/ir.cpp index ecaa5bbd4..dae3e94d6 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -3585,6 +3585,9 @@ irValue *ir_emit_logical_binary_expr(irProcedure *proc, AstNode *expr) { void ir_emit_bounds_check(irProcedure *proc, Token token, irValue *index, irValue *len) { + if (build_context.no_bounds_check) { + return; + } if ((proc->module->stmt_state_flags & StmtStateFlag_no_bounds_check) != 0) { return; } @@ -3610,6 +3613,9 @@ void ir_emit_bounds_check(irProcedure *proc, Token token, irValue *index, irValu } void ir_emit_slice_bounds_check(irProcedure *proc, Token token, irValue *low, irValue *high, bool is_substring) { + if (build_context.no_bounds_check) { + return; + } if ((proc->module->stmt_state_flags & StmtStateFlag_no_bounds_check) != 0) { return; } @@ -3628,11 +3634,13 @@ void ir_emit_slice_bounds_check(irProcedure *proc, Token token, irValue *low, ir args[3] = low; args[4] = high; - char const *func = is_substring ? "__substring_expr_error" : "__slice_expr_error"; - ir_emit_global_call(proc, func, args, 5); + ir_emit_global_call(proc, "__slice_expr_error", args, 5); } void ir_emit_dynamic_array_bounds_check(irProcedure *proc, Token token, irValue *low, irValue *high, irValue *max) { + if (build_context.no_bounds_check) { + return; + } if ((proc->module->stmt_state_flags & StmtStateFlag_no_bounds_check) != 0) { return; } -- cgit v1.2.3