aboutsummaryrefslogtreecommitdiff
path: root/gdb/compile
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2021-01-22 12:21:09 -0500
committerSimon Marchi <simon.marchi@polymtl.ca>2021-01-22 12:21:09 -0500
commit5b7d941b90d1a232dc144dc14850dd2fb63c35da (patch)
treedf27382d780f8e646017f31cb26ea48922bade64 /gdb/compile
parentfe461d2f70ed618c39b887579d07f49f603c1de5 (diff)
downloadgdb-5b7d941b90d1a232dc144dc14850dd2fb63c35da.zip
gdb-5b7d941b90d1a232dc144dc14850dd2fb63c35da.tar.gz
gdb-5b7d941b90d1a232dc144dc14850dd2fb63c35da.tar.bz2
gdb: add owner-related methods to struct type
Add the following methods to struct type: * is_objfile_owned * set_owner (objfile and gdbarch overloads) * objfile and arch getters Rename the fields in main_type to ensure no other code accesses them directly. As usual, we can't make them actually private, but giving them the `m_` prefix will help making sure they are not accessed when not supposed to, by convention. Remove the TYPE_OWNER macro to ensure no code uses the type_owner struct directly. gdb/ChangeLog: * gdbtypes.h (TYPE_OBJFILE_OWNED): Adjust. (TYPE_OWNER): Remove. (TYPE_OBJFILE): Adjust. (struct main_type) <flag_objfile_owned>: Rename to... <m_flag_objfile_owned>: ... this. <owner>: Rename to... <m_owner>: ... this. (struct type) <is_objfile_owned, set_owner, objfile, arch>: New methods. (TYPE_ALLOC): Adjust. * gdbtypes.c (alloc_type): Adjust. (alloc_type_arch): Adjust. (alloc_type_copy): Adjust. (get_type_arch): Adjust. (smash_type): Adjust. (lookup_array_range_type): Adjust. (recursive_dump_type): Adjust. (copy_type_recursive): Adjust. * compile/compile-c-types.c (convert_func): Adjust. (convert_type_basic): Adjust. * compile/compile-cplus-types.c (compile_cplus_convert_func): Adjust. * language.c (language_arch_info::type_and_symbol::alloc_type_symbol): Adjust. Change-Id: I7f92e869d9f92e2402a3d3007dd0832e05aa6ac8
Diffstat (limited to 'gdb/compile')
-rw-r--r--gdb/compile/compile-c-types.c8
-rw-r--r--gdb/compile/compile-cplus-types.c4
2 files changed, 6 insertions, 6 deletions
diff --git a/gdb/compile/compile-c-types.c b/gdb/compile/compile-c-types.c
index eea0844..90de208 100644
--- a/gdb/compile/compile-c-types.c
+++ b/gdb/compile/compile-c-types.c
@@ -165,9 +165,9 @@ convert_func (compile_c_instance *context, struct type *type)
if (target_type == NULL)
{
if (TYPE_OBJFILE_OWNED (type))
- target_type = objfile_type (TYPE_OWNER (type).objfile)->builtin_int;
+ target_type = objfile_type (type->objfile ())->builtin_int;
else
- target_type = builtin_type (TYPE_OWNER (type).gdbarch)->builtin_int;
+ target_type = builtin_type (type->arch ())->builtin_int;
warning (_("function has unknown return type; assuming int"));
}
@@ -324,9 +324,9 @@ convert_type_basic (compile_c_instance *context, struct type *type)
built-in parser used to do, but at least warn. */
struct type *fallback;
if (TYPE_OBJFILE_OWNED (type))
- fallback = objfile_type (TYPE_OWNER (type).objfile)->builtin_int;
+ fallback = objfile_type (type->objfile ())->builtin_int;
else
- fallback = builtin_type (TYPE_OWNER (type).gdbarch)->builtin_int;
+ fallback = builtin_type (type->arch ())->builtin_int;
warning (_("variable has unknown type; assuming int"));
return convert_int (context, fallback);
}
diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c
index 5289f6f..ddb0d8a 100644
--- a/gdb/compile/compile-cplus-types.c
+++ b/gdb/compile/compile-cplus-types.c
@@ -971,9 +971,9 @@ compile_cplus_convert_func (compile_cplus_instance *instance,
if (target_type == nullptr)
{
if (TYPE_OBJFILE_OWNED (type))
- target_type = objfile_type (TYPE_OWNER (type).objfile)->builtin_int;
+ target_type = objfile_type (type->objfile ())->builtin_int;
else
- target_type = builtin_type (TYPE_OWNER (type).gdbarch)->builtin_int;
+ target_type = builtin_type (type->arch ())->builtin_int;
warning (_("function has unknown return type; assuming int"));
}