Rename ODIN_DISALLOW_RTTI to ODIN_NO_RTTI; Remove dead command line flags

This commit is contained in:
gingerBill
2023-06-12 14:53:05 +01:00
parent 52a926dd90
commit 296674e18b
12 changed files with 27 additions and 41 deletions
+1 -1
View File
@@ -132,7 +132,7 @@ type_info_core :: runtime.type_info_core
type_info_base_without_enum :: type_info_core type_info_base_without_enum :: type_info_core
when !ODIN_DISALLOW_RTTI { when !ODIN_NO_RTTI {
typeid_base :: runtime.typeid_base typeid_base :: runtime.typeid_base
typeid_core :: runtime.typeid_core typeid_core :: runtime.typeid_core
typeid_base_without_enum :: typeid_core typeid_base_without_enum :: typeid_core
+1 -1
View File
@@ -566,7 +566,7 @@ __type_info_of :: proc "contextless" (id: typeid) -> ^Type_Info #no_bounds_check
return &type_table[n] return &type_table[n]
} }
when !ODIN_DISALLOW_RTTI { when !ODIN_NO_RTTI {
typeid_base :: proc "contextless" (id: typeid) -> typeid { typeid_base :: proc "contextless" (id: typeid) -> typeid {
ti := type_info_of(id) ti := type_info_of(id)
ti = type_info_base(ti) ti = type_info_base(ti)
+1 -1
View File
@@ -122,7 +122,7 @@ matrix_bounds_check_error :: proc "contextless" (file: string, line, column: i32
} }
when ODIN_DISALLOW_RTTI { when ODIN_NO_RTTI {
type_assertion_check :: proc "contextless" (ok: bool, file: string, line, column: i32) { type_assertion_check :: proc "contextless" (ok: bool, file: string, line, column: i32) {
if ok { if ok {
return return
+2 -2
View File
@@ -5,7 +5,7 @@ _INTEGER_DIGITS :: "0123456789abcdefghijklmnopqrstuvwxyz"
@(private="file") @(private="file")
_INTEGER_DIGITS_VAR := _INTEGER_DIGITS _INTEGER_DIGITS_VAR := _INTEGER_DIGITS
when !ODIN_DISALLOW_RTTI { when !ODIN_NO_RTTI {
print_any_single :: proc "contextless" (arg: any) { print_any_single :: proc "contextless" (arg: any) {
x := arg x := arg
if loc, ok := x.(Source_Code_Location); ok { if loc, ok := x.(Source_Code_Location); ok {
@@ -234,7 +234,7 @@ print_caller_location :: proc "contextless" (using loc: Source_Code_Location) {
} }
} }
print_typeid :: proc "contextless" (id: typeid) { print_typeid :: proc "contextless" (id: typeid) {
when ODIN_DISALLOW_RTTI { when ODIN_NO_RTTI {
if id == nil { if id == nil {
print_string("nil") print_string("nil")
} else { } else {
+3 -3
View File
@@ -309,7 +309,7 @@ struct BuildContext {
bool copy_file_contents; bool copy_file_contents;
bool disallow_rtti; bool no_rtti;
bool dynamic_map_calls; bool dynamic_map_calls;
@@ -1227,8 +1227,8 @@ gb_internal void init_build_context(TargetMetrics *cross_target) {
if (bc->metrics.os == TargetOs_freestanding) { if (bc->metrics.os == TargetOs_freestanding) {
bc->no_entry_point = true; bc->no_entry_point = true;
} else { } else {
if (bc->disallow_rtti) { if (bc->no_rtti) {
gb_printf_err("-disallow-rtti is only allowed on freestanding targets\n"); gb_printf_err("-no-rtti is only allowed on freestanding targets\n");
gb_exit(1); gb_exit(1);
} }
} }
+2 -2
View File
@@ -2063,7 +2063,7 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As
if (c->scope->flags&ScopeFlag_Global) { if (c->scope->flags&ScopeFlag_Global) {
compiler_error("'type_info_of' Cannot be declared within the runtime package due to how the internals of the compiler works"); compiler_error("'type_info_of' Cannot be declared within the runtime package due to how the internals of the compiler works");
} }
if (build_context.disallow_rtti) { if (build_context.no_rtti) {
error(call, "'%.*s' has been disallowed", LIT(builtin_name)); error(call, "'%.*s' has been disallowed", LIT(builtin_name));
return false; return false;
} }
@@ -2106,7 +2106,7 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As
if (c->scope->flags&ScopeFlag_Global) { if (c->scope->flags&ScopeFlag_Global) {
compiler_error("'typeid_of' Cannot be declared within the runtime package due to how the internals of the compiler works"); compiler_error("'typeid_of' Cannot be declared within the runtime package due to how the internals of the compiler works");
} }
if (build_context.disallow_rtti) { if (build_context.no_rtti) {
error(call, "'%.*s' has been disallowed", LIT(builtin_name)); error(call, "'%.*s' has been disallowed", LIT(builtin_name));
return false; return false;
} }
+4 -4
View File
@@ -32,7 +32,7 @@ gb_internal bool is_operand_uninit(Operand o) {
} }
gb_internal bool check_rtti_type_disallowed(Token const &token, Type *type, char const *format) { gb_internal bool check_rtti_type_disallowed(Token const &token, Type *type, char const *format) {
if (build_context.disallow_rtti && type) { if (build_context.no_rtti && type) {
if (is_type_any(type)) { if (is_type_any(type)) {
gbString t = type_to_string(type); gbString t = type_to_string(type);
error(token, format, t); error(token, format, t);
@@ -1054,7 +1054,7 @@ gb_internal void init_universal(void) {
add_global_bool_constant("ODIN_TEST", bc->command_kind == Command_test); add_global_bool_constant("ODIN_TEST", bc->command_kind == Command_test);
add_global_bool_constant("ODIN_NO_ENTRY_POINT", bc->no_entry_point); add_global_bool_constant("ODIN_NO_ENTRY_POINT", bc->no_entry_point);
add_global_bool_constant("ODIN_FOREIGN_ERROR_PROCEDURES", bc->ODIN_FOREIGN_ERROR_PROCEDURES); add_global_bool_constant("ODIN_FOREIGN_ERROR_PROCEDURES", bc->ODIN_FOREIGN_ERROR_PROCEDURES);
add_global_bool_constant("ODIN_DISALLOW_RTTI", bc->disallow_rtti); add_global_bool_constant("ODIN_NO_RTTI", bc->no_rtti);
add_global_bool_constant("ODIN_VALGRIND_SUPPORT", bc->ODIN_VALGRIND_SUPPORT); add_global_bool_constant("ODIN_VALGRIND_SUPPORT", bc->ODIN_VALGRIND_SUPPORT);
@@ -1742,7 +1742,7 @@ gb_internal void add_implicit_entity(CheckerContext *c, Ast *clause, Entity *e)
gb_internal void add_type_info_type_internal(CheckerContext *c, Type *t); gb_internal void add_type_info_type_internal(CheckerContext *c, Type *t);
gb_internal void add_type_info_type(CheckerContext *c, Type *t) { gb_internal void add_type_info_type(CheckerContext *c, Type *t) {
if (build_context.disallow_rtti) { if (build_context.no_rtti) {
return; return;
} }
if (t == nullptr) { if (t == nullptr) {
@@ -2343,7 +2343,7 @@ gb_internal void generate_minimum_dependency_set(Checker *c, Entity *start) {
str_lit("__multi3"), str_lit("__multi3"),
); );
FORCE_ADD_RUNTIME_ENTITIES(!build_context.disallow_rtti, FORCE_ADD_RUNTIME_ENTITIES(!build_context.no_rtti,
// Odin types // Odin types
str_lit("Type_Info"), str_lit("Type_Info"),
+2 -2
View File
@@ -1048,7 +1048,7 @@ struct lbGlobalVariable {
}; };
gb_internal lbProcedure *lb_create_startup_type_info(lbModule *m) { gb_internal lbProcedure *lb_create_startup_type_info(lbModule *m) {
if (build_context.disallow_rtti) { if (build_context.no_rtti) {
return nullptr; return nullptr;
} }
Type *proc_type = alloc_type_proc(nullptr, nullptr, 0, nullptr, 0, false, ProcCC_CDecl); Type *proc_type = alloc_type_proc(nullptr, nullptr, 0, nullptr, 0, false, ProcCC_CDecl);
@@ -2170,7 +2170,7 @@ gb_internal bool lb_generate_code(lbGenerator *gen) {
TIME_SECTION("LLVM Global Variables"); TIME_SECTION("LLVM Global Variables");
if (!build_context.disallow_rtti) { if (!build_context.no_rtti) {
lbModule *m = default_module; lbModule *m = default_module;
{ // Add type info data { // Add type info data
+3 -3
View File
@@ -2984,7 +2984,7 @@ gb_internal lbValue lb_build_unary_and(lbProcedure *p, Ast *expr) {
isize arg_count = 6; isize arg_count = 6;
if (build_context.disallow_rtti) { if (build_context.no_rtti) {
arg_count = 4; arg_count = 4;
} }
@@ -2996,7 +2996,7 @@ gb_internal lbValue lb_build_unary_and(lbProcedure *p, Ast *expr) {
args[2] = lb_const_int(p->module, t_i32, pos.line); args[2] = lb_const_int(p->module, t_i32, pos.line);
args[3] = lb_const_int(p->module, t_i32, pos.column); args[3] = lb_const_int(p->module, t_i32, pos.column);
if (!build_context.disallow_rtti) { if (!build_context.no_rtti) {
args[4] = lb_typeid(p->module, src_type); args[4] = lb_typeid(p->module, src_type);
args[5] = lb_typeid(p->module, dst_type); args[5] = lb_typeid(p->module, dst_type);
} }
@@ -3012,7 +3012,7 @@ gb_internal lbValue lb_build_unary_and(lbProcedure *p, Ast *expr) {
} }
lbValue data_ptr = lb_emit_struct_ev(p, v, 0); lbValue data_ptr = lb_emit_struct_ev(p, v, 0);
if ((p->state_flags & StateFlag_no_type_assert) == 0) { if ((p->state_flags & StateFlag_no_type_assert) == 0) {
GB_ASSERT(!build_context.disallow_rtti); GB_ASSERT(!build_context.no_rtti);
lbValue any_id = lb_emit_struct_ev(p, v, 1); lbValue any_id = lb_emit_struct_ev(p, v, 1);
+3 -3
View File
@@ -15,7 +15,7 @@ gb_internal isize lb_type_info_index(CheckerInfo *info, Type *type, bool err_on_
} }
gb_internal lbValue lb_typeid(lbModule *m, Type *type) { gb_internal lbValue lb_typeid(lbModule *m, Type *type) {
GB_ASSERT(!build_context.disallow_rtti); GB_ASSERT(!build_context.no_rtti);
type = default_type(type); type = default_type(type);
@@ -92,7 +92,7 @@ gb_internal lbValue lb_typeid(lbModule *m, Type *type) {
} }
gb_internal lbValue lb_type_info(lbModule *m, Type *type) { gb_internal lbValue lb_type_info(lbModule *m, Type *type) {
GB_ASSERT(!build_context.disallow_rtti); GB_ASSERT(!build_context.no_rtti);
type = default_type(type); type = default_type(type);
@@ -141,7 +141,7 @@ gb_internal lbValue lb_type_info_member_tags_offset(lbProcedure *p, isize count)
gb_internal void lb_setup_type_info_data(lbProcedure *p) { // NOTE(bill): Setup type_info data gb_internal void lb_setup_type_info_data(lbProcedure *p) { // NOTE(bill): Setup type_info data
if (build_context.disallow_rtti) { if (build_context.no_rtti) {
return; return;
} }
+4 -4
View File
@@ -721,7 +721,7 @@ gb_internal lbValue lb_emit_union_cast(lbProcedure *p, lbValue value, Type *type
Type *dst_type = tuple->Tuple.variables[0]->type; Type *dst_type = tuple->Tuple.variables[0]->type;
isize arg_count = 7; isize arg_count = 7;
if (build_context.disallow_rtti) { if (build_context.no_rtti) {
arg_count = 4; arg_count = 4;
} }
@@ -733,7 +733,7 @@ gb_internal lbValue lb_emit_union_cast(lbProcedure *p, lbValue value, Type *type
args[2] = lb_const_int(m, t_i32, pos.line); args[2] = lb_const_int(m, t_i32, pos.line);
args[3] = lb_const_int(m, t_i32, pos.column); args[3] = lb_const_int(m, t_i32, pos.column);
if (!build_context.disallow_rtti) { if (!build_context.no_rtti) {
args[4] = lb_typeid(m, src_type); args[4] = lb_typeid(m, src_type);
args[5] = lb_typeid(m, dst_type); args[5] = lb_typeid(m, dst_type);
args[6] = lb_emit_conv(p, value_, t_rawptr); args[6] = lb_emit_conv(p, value_, t_rawptr);
@@ -797,7 +797,7 @@ gb_internal lbAddr lb_emit_any_cast_addr(lbProcedure *p, lbValue value, Type *ty
lbValue ok = lb_emit_load(p, lb_emit_struct_ep(p, v.addr, 1)); lbValue ok = lb_emit_load(p, lb_emit_struct_ep(p, v.addr, 1));
isize arg_count = 7; isize arg_count = 7;
if (build_context.disallow_rtti) { if (build_context.no_rtti) {
arg_count = 4; arg_count = 4;
} }
auto args = array_make<lbValue>(permanent_allocator(), arg_count); auto args = array_make<lbValue>(permanent_allocator(), arg_count);
@@ -807,7 +807,7 @@ gb_internal lbAddr lb_emit_any_cast_addr(lbProcedure *p, lbValue value, Type *ty
args[2] = lb_const_int(m, t_i32, pos.line); args[2] = lb_const_int(m, t_i32, pos.line);
args[3] = lb_const_int(m, t_i32, pos.column); args[3] = lb_const_int(m, t_i32, pos.column);
if (!build_context.disallow_rtti) { if (!build_context.no_rtti) {
args[4] = any_typeid; args[4] = any_typeid;
args[5] = dst_typeid; args[5] = dst_typeid;
args[6] = lb_emit_struct_ev(p, value, 0); args[6] = lb_emit_struct_ev(p, value, 0);
+1 -15
View File
@@ -655,7 +655,6 @@ enum BuildFlagKind {
BuildFlag_ShowDebugMessages, BuildFlag_ShowDebugMessages,
BuildFlag_Vet, BuildFlag_Vet,
BuildFlag_VetExtra, BuildFlag_VetExtra,
BuildFlag_UseLLVMApi,
BuildFlag_IgnoreUnknownAttributes, BuildFlag_IgnoreUnknownAttributes,
BuildFlag_ExtraLinkerFlags, BuildFlag_ExtraLinkerFlags,
BuildFlag_ExtraAssemblerFlags, BuildFlag_ExtraAssemblerFlags,
@@ -671,7 +670,6 @@ enum BuildFlagKind {
BuildFlag_DisallowDo, BuildFlag_DisallowDo,
BuildFlag_DefaultToNilAllocator, BuildFlag_DefaultToNilAllocator,
BuildFlag_InsertSemicolon,
BuildFlag_StrictStyle, BuildFlag_StrictStyle,
BuildFlag_StrictStyleInitOnly, BuildFlag_StrictStyleInitOnly,
BuildFlag_ForeignErrorProcedures, BuildFlag_ForeignErrorProcedures,
@@ -834,7 +832,6 @@ gb_internal bool parse_build_flags(Array<String> args) {
add_flag(&build_flags, BuildFlag_ShowDebugMessages, str_lit("show-debug-messages"), BuildFlagParam_None, Command_all); add_flag(&build_flags, BuildFlag_ShowDebugMessages, str_lit("show-debug-messages"), BuildFlagParam_None, Command_all);
add_flag(&build_flags, BuildFlag_Vet, str_lit("vet"), BuildFlagParam_None, Command__does_check); add_flag(&build_flags, BuildFlag_Vet, str_lit("vet"), BuildFlagParam_None, Command__does_check);
add_flag(&build_flags, BuildFlag_VetExtra, str_lit("vet-extra"), BuildFlagParam_None, Command__does_check); add_flag(&build_flags, BuildFlag_VetExtra, str_lit("vet-extra"), BuildFlagParam_None, Command__does_check);
add_flag(&build_flags, BuildFlag_UseLLVMApi, str_lit("llvm-api"), BuildFlagParam_None, Command__does_build);
add_flag(&build_flags, BuildFlag_IgnoreUnknownAttributes, str_lit("ignore-unknown-attributes"), BuildFlagParam_None, Command__does_check); add_flag(&build_flags, BuildFlag_IgnoreUnknownAttributes, str_lit("ignore-unknown-attributes"), BuildFlagParam_None, Command__does_check);
add_flag(&build_flags, BuildFlag_ExtraLinkerFlags, str_lit("extra-linker-flags"), BuildFlagParam_String, Command__does_build); add_flag(&build_flags, BuildFlag_ExtraLinkerFlags, str_lit("extra-linker-flags"), BuildFlagParam_String, Command__does_build);
add_flag(&build_flags, BuildFlag_ExtraAssemblerFlags, str_lit("extra-assembler-flags"), BuildFlagParam_String, Command__does_build); add_flag(&build_flags, BuildFlag_ExtraAssemblerFlags, str_lit("extra-assembler-flags"), BuildFlagParam_String, Command__does_build);
@@ -849,7 +846,6 @@ gb_internal bool parse_build_flags(Array<String> args) {
add_flag(&build_flags, BuildFlag_DisallowDo, str_lit("disallow-do"), BuildFlagParam_None, Command__does_check); add_flag(&build_flags, BuildFlag_DisallowDo, str_lit("disallow-do"), BuildFlagParam_None, Command__does_check);
add_flag(&build_flags, BuildFlag_DefaultToNilAllocator, str_lit("default-to-nil-allocator"), BuildFlagParam_None, Command__does_check); add_flag(&build_flags, BuildFlag_DefaultToNilAllocator, str_lit("default-to-nil-allocator"), BuildFlagParam_None, Command__does_check);
add_flag(&build_flags, BuildFlag_InsertSemicolon, str_lit("insert-semicolon"), BuildFlagParam_None, Command__does_check);
add_flag(&build_flags, BuildFlag_StrictStyle, str_lit("strict-style"), BuildFlagParam_None, Command__does_check); add_flag(&build_flags, BuildFlag_StrictStyle, str_lit("strict-style"), BuildFlagParam_None, Command__does_check);
add_flag(&build_flags, BuildFlag_StrictStyleInitOnly, str_lit("strict-style-init-only"), BuildFlagParam_None, Command__does_check); add_flag(&build_flags, BuildFlag_StrictStyleInitOnly, str_lit("strict-style-init-only"), BuildFlagParam_None, Command__does_check);
add_flag(&build_flags, BuildFlag_ForeignErrorProcedures, str_lit("foreign-error-procedures"), BuildFlagParam_None, Command__does_check); add_flag(&build_flags, BuildFlag_ForeignErrorProcedures, str_lit("foreign-error-procedures"), BuildFlagParam_None, Command__does_check);
@@ -1373,11 +1369,6 @@ gb_internal bool parse_build_flags(Array<String> args) {
build_context.vet_extra = true; build_context.vet_extra = true;
break; break;
} }
case BuildFlag_UseLLVMApi: {
gb_printf_err("-llvm-api flag is not required any more\n");
bad_flags = true;
break;
}
case BuildFlag_IgnoreUnknownAttributes: case BuildFlag_IgnoreUnknownAttributes:
build_context.ignore_unknown_attributes = true; build_context.ignore_unknown_attributes = true;
break; break;
@@ -1454,7 +1445,7 @@ gb_internal bool parse_build_flags(Array<String> args) {
gb_printf_err("'-disallow-rtti' has been replaced with '-no-rtti'\n"); gb_printf_err("'-disallow-rtti' has been replaced with '-no-rtti'\n");
bad_flags = true; bad_flags = true;
} }
build_context.disallow_rtti = true; build_context.no_rtti = true;
break; break;
case BuildFlag_DynamicMapCalls: case BuildFlag_DynamicMapCalls:
build_context.dynamic_map_calls = true; build_context.dynamic_map_calls = true;
@@ -1465,11 +1456,6 @@ gb_internal bool parse_build_flags(Array<String> args) {
case BuildFlag_ForeignErrorProcedures: case BuildFlag_ForeignErrorProcedures:
build_context.ODIN_FOREIGN_ERROR_PROCEDURES = true; build_context.ODIN_FOREIGN_ERROR_PROCEDURES = true;
break; break;
case BuildFlag_InsertSemicolon: {
gb_printf_err("-insert-semicolon flag is not required any more\n");
bad_flags = true;
break;
}
case BuildFlag_StrictStyle: { case BuildFlag_StrictStyle: {
if (build_context.strict_style_init_only) { if (build_context.strict_style_init_only) {
gb_printf_err("-strict-style and -strict-style-init-only cannot be used together\n"); gb_printf_err("-strict-style and -strict-style-init-only cannot be used together\n");