mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-03 14:18:47 +00:00
Add extra checks for -disallow-rtti
This commit is contained in:
@@ -624,6 +624,9 @@ struct lbGlobalVariable {
|
|||||||
};
|
};
|
||||||
|
|
||||||
lbProcedure *lb_create_startup_type_info(lbModule *m) {
|
lbProcedure *lb_create_startup_type_info(lbModule *m) {
|
||||||
|
if (build_context.disallow_rtti) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
LLVMPassManagerRef default_function_pass_manager = LLVMCreateFunctionPassManagerForModule(m->mod);
|
LLVMPassManagerRef default_function_pass_manager = LLVMCreateFunctionPassManagerForModule(m->mod);
|
||||||
lb_populate_function_pass_manager(m, default_function_pass_manager, false, build_context.optimization_level);
|
lb_populate_function_pass_manager(m, default_function_pass_manager, false, build_context.optimization_level);
|
||||||
LLVMFinalizeFunctionPassManager(default_function_pass_manager);
|
LLVMFinalizeFunctionPassManager(default_function_pass_manager);
|
||||||
@@ -711,7 +714,9 @@ lbProcedure *lb_create_startup_runtime(lbModule *main_module, lbProcedure *start
|
|||||||
|
|
||||||
lb_begin_procedure_body(p);
|
lb_begin_procedure_body(p);
|
||||||
|
|
||||||
LLVMBuildCall2(p->builder, LLVMGetElementType(lb_type(main_module, startup_type_info->type)), startup_type_info->value, nullptr, 0, "");
|
if (startup_type_info) {
|
||||||
|
LLVMBuildCall2(p->builder, LLVMGetElementType(lb_type(main_module, startup_type_info->type)), startup_type_info->value, nullptr, 0, "");
|
||||||
|
}
|
||||||
|
|
||||||
if (objc_names) {
|
if (objc_names) {
|
||||||
LLVMBuildCall2(p->builder, LLVMGetElementType(lb_type(main_module, objc_names->type)), objc_names->value, nullptr, 0, "");
|
LLVMBuildCall2(p->builder, LLVMGetElementType(lb_type(main_module, objc_names->type)), objc_names->value, nullptr, 0, "");
|
||||||
@@ -1394,7 +1399,7 @@ void lb_generate_code(lbGenerator *gen) {
|
|||||||
|
|
||||||
TIME_SECTION("LLVM Global Variables");
|
TIME_SECTION("LLVM Global Variables");
|
||||||
|
|
||||||
{
|
if (!build_context.disallow_rtti) {
|
||||||
lbModule *m = default_module;
|
lbModule *m = default_module;
|
||||||
|
|
||||||
{ // Add type info data
|
{ // Add type info data
|
||||||
|
|||||||
@@ -90,6 +90,8 @@ lbValue lb_typeid(lbModule *m, Type *type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
lbValue lb_type_info(lbModule *m, Type *type) {
|
lbValue lb_type_info(lbModule *m, Type *type) {
|
||||||
|
GB_ASSERT(!build_context.disallow_rtti);
|
||||||
|
|
||||||
type = default_type(type);
|
type = default_type(type);
|
||||||
|
|
||||||
isize index = lb_type_info_index(m->info, type);
|
isize index = lb_type_info_index(m->info, type);
|
||||||
@@ -108,6 +110,8 @@ lbValue lb_type_info(lbModule *m, Type *type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
lbValue lb_get_type_info_ptr(lbModule *m, Type *type) {
|
lbValue lb_get_type_info_ptr(lbModule *m, Type *type) {
|
||||||
|
GB_ASSERT(!build_context.disallow_rtti);
|
||||||
|
|
||||||
i32 index = cast(i32)lb_type_info_index(m->info, type);
|
i32 index = cast(i32)lb_type_info_index(m->info, type);
|
||||||
GB_ASSERT(index >= 0);
|
GB_ASSERT(index >= 0);
|
||||||
// gb_printf_err("%d %s\n", index, type_to_string(type));
|
// gb_printf_err("%d %s\n", index, type_to_string(type));
|
||||||
@@ -157,6 +161,10 @@ lbValue lb_type_info_member_tags_offset(lbProcedure *p, isize count) {
|
|||||||
|
|
||||||
|
|
||||||
void lb_setup_type_info_data(lbProcedure *p) { // NOTE(bill): Setup type_info data
|
void lb_setup_type_info_data(lbProcedure *p) { // NOTE(bill): Setup type_info data
|
||||||
|
if (build_context.disallow_rtti) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
lbModule *m = p->module;
|
lbModule *m = p->module;
|
||||||
CheckerInfo *info = m->info;
|
CheckerInfo *info = m->info;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user