aboutsummaryrefslogtreecommitdiff
path: root/src/check_type.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-04-22 11:33:46 +0100
committergingerBill <bill@gingerbill.org>2021-04-22 11:33:46 +0100
commitb68b090f136d43c3501c4c9772bd4dd68399eb37 (patch)
treeb91b453f34e7079aa6482144a87015db35073ffa /src/check_type.cpp
parent542098dc6fbc871d44a5061bb871f93968d48e3e (diff)
Add intrinsics: overflow_add, overflow_sub, overflow_mul; Change byte swap behaviour in -llvm-api to be the same as the intrinsic
Diffstat (limited to 'src/check_type.cpp')
-rw-r--r--src/check_type.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp
index 612a11593..e3aac161c 100644
--- a/src/check_type.cpp
+++ b/src/check_type.cpp
@@ -2619,12 +2619,11 @@ i64 check_array_count(CheckerContext *ctx, Operand *o, Ast *e) {
}
Type *make_optional_ok_type(Type *value, bool typed) {
- // LEAK TODO(bill): probably don't reallocate everything here and reuse the same one for the same type if possible
- gbAllocator a = heap_allocator();
+ gbAllocator a = permanent_allocator();
Type *t = alloc_type_tuple();
- array_init(&t->Tuple.variables, a, 0, 2);
- array_add (&t->Tuple.variables, alloc_entity_field(nullptr, blank_token, value, false, 0));
- array_add (&t->Tuple.variables, alloc_entity_field(nullptr, blank_token, typed ? t_bool : t_untyped_bool, false, 1));
+ array_init(&t->Tuple.variables, a, 2);
+ t->Tuple.variables[0] = alloc_entity_field(nullptr, blank_token, value, false, 0);
+ t->Tuple.variables[1] = alloc_entity_field(nullptr, blank_token, typed ? t_bool : t_untyped_bool, false, 1);
return t;
}