Skip to content

Commit

Permalink
remove raw new and delete (lcompilers#2018)
Browse files Browse the repository at this point in the history
  • Loading branch information
kabra1110 committed Jun 24, 2023
1 parent 4010031 commit dbee8ff
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/libasr/codegen/asr_to_llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2263,10 +2263,8 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
ASR::Tuple_t* tuple_type_right = ASR::down_cast<ASR::Tuple_t>(ASRUtils::expr_type(x.m_right));
std::string type_code_right = ASRUtils::get_type_code(tuple_type_right->m_type,
tuple_type_right->n_type);
ASR::Tuple_t* tuple_type = new ASR::Tuple_t();
tuple_type->n_type = tuple_type_left->n_type + tuple_type_right->n_type;
tuple_type->m_type = new ASR::ttype_t*[tuple_type->n_type];

Vec<ASR::ttype_t*> v_type;
v_type.reserve(al, tuple_type_left->n_type + tuple_type_right->n_type);
std::string type_code = type_code_left + type_code_right;
std::vector<llvm::Type*> llvm_el_types;
ASR::storage_typeType m_storage = ASR::storage_typeType::Default;
Expand All @@ -2279,7 +2277,7 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
nullptr,
m_storage, is_array_type, is_malloc_array_type,
is_list, m_dims, n_dims, a_kind));
tuple_type->m_type[i] = tuple_type_left->m_type[i];
v_type.push_back(al, tuple_type_left->m_type[i]);
}
is_array_type = false; is_malloc_array_type = false;
is_list = false;
Expand All @@ -2290,14 +2288,14 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
nullptr,
m_storage, is_array_type, is_malloc_array_type,
is_list, m_dims, n_dims, a_kind));
tuple_type->m_type[tuple_type_left->n_type + i] = tuple_type_right->m_type[i];
v_type.push_back(al, tuple_type_right->m_type[i]);
}
llvm::Type* concat_tuple_type = tuple_api->get_tuple_type(type_code, llvm_el_types);
llvm::Value* concat_tuple = builder->CreateAlloca(concat_tuple_type, nullptr, "concat_tuple");
ASR::Tuple_t* tuple_type = (ASR::Tuple_t*)(ASR::make_Tuple_t(
al, x.base.base.loc, v_type.p, v_type.n));
tuple_api->concat(left, right, tuple_type_left, tuple_type_right, concat_tuple,
tuple_type, *module, name2memidx);
delete[] tuple_type->m_type;
delete tuple_type;
tmp = concat_tuple;
}

Expand Down

0 comments on commit dbee8ff

Please sign in to comment.