aboutsummaryrefslogtreecommitdiff
path: root/gdb/compile
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2020-05-22 16:55:15 -0400
committerSimon Marchi <simon.marchi@efficios.com>2020-05-22 16:55:15 -0400
commit1f704f761b34e145f5eabdc222301ce6e9ec9102 (patch)
tree89c8b6dbf40b606ef045929b718d9271093057a3 /gdb/compile
parent5e33d5f4e1a5f2c3556ee31715ddc030d039b597 (diff)
downloadgdb-1f704f761b34e145f5eabdc222301ce6e9ec9102.zip
gdb-1f704f761b34e145f5eabdc222301ce6e9ec9102.tar.gz
gdb-1f704f761b34e145f5eabdc222301ce6e9ec9102.tar.bz2
gdb: remove TYPE_NFIELDS macro
Remove `TYPE_NFIELDS`, changing all the call sites to use `type::num_fields` directly. This is quite a big diff, but this was mostly done using sed and coccinelle. A few call sites were done by hand. gdb/ChangeLog: * gdbtypes.h (TYPE_NFIELDS): Remove. Change all cal sites to use type::num_fields instead. Change-Id: Ib73be4c36f9e770e0f729bac3b5257d7cb2f9591
Diffstat (limited to 'gdb/compile')
-rw-r--r--gdb/compile/compile-c-symbols.c2
-rw-r--r--gdb/compile/compile-c-types.c10
-rw-r--r--gdb/compile/compile-cplus-types.c8
-rw-r--r--gdb/compile/compile-object-load.c8
-rw-r--r--gdb/compile/compile-object-run.c10
5 files changed, 19 insertions, 19 deletions
diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c
index ab9f442..8b3cd37 100644
--- a/gdb/compile/compile-c-symbols.c
+++ b/gdb/compile/compile-c-symbols.c
@@ -526,7 +526,7 @@ generate_vla_size (compile_instance *compiler,
{
int i;
- for (i = 0; i < TYPE_NFIELDS (type); ++i)
+ for (i = 0; i < type->num_fields (); ++i)
if (!field_is_static (&TYPE_FIELD (type, i)))
generate_vla_size (compiler, stream, gdbarch, registers_used, pc,
TYPE_FIELD_TYPE (type, i), sym);
diff --git a/gdb/compile/compile-c-types.c b/gdb/compile/compile-c-types.c
index 8f6ed05..c4f5811 100644
--- a/gdb/compile/compile-c-types.c
+++ b/gdb/compile/compile-c-types.c
@@ -103,7 +103,7 @@ convert_struct_or_union (compile_c_instance *context, struct type *type)
}
context->insert_type (type, result);
- for (i = 0; i < TYPE_NFIELDS (type); ++i)
+ for (i = 0; i < type->num_fields (); ++i)
{
gcc_type field_type;
unsigned long bitsize = TYPE_FIELD_BITSIZE (type, i);
@@ -134,7 +134,7 @@ convert_enum (compile_c_instance *context, struct type *type)
TYPE_LENGTH (type));
result = context->plugin ().build_enum_type (int_type);
- for (i = 0; i < TYPE_NFIELDS (type); ++i)
+ for (i = 0; i < type->num_fields (); ++i)
{
context->plugin ().build_add_enum_constant
(result, TYPE_FIELD_NAME (type, i), TYPE_FIELD_ENUMVAL (type, i));
@@ -175,9 +175,9 @@ convert_func (compile_c_instance *context, struct type *type)
types. Those are impossible in C, though. */
return_type = context->convert_type (target_type);
- array.n_elements = TYPE_NFIELDS (type);
- array.elements = XNEWVEC (gcc_type, TYPE_NFIELDS (type));
- for (i = 0; i < TYPE_NFIELDS (type); ++i)
+ array.n_elements = type->num_fields ();
+ array.elements = XNEWVEC (gcc_type, type->num_fields ());
+ for (i = 0; i < type->num_fields (); ++i)
array.elements[i] = context->convert_type (TYPE_FIELD_TYPE (type, i));
result = context->plugin ().build_function_type (return_type,
diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c
index 523ab34..b2a4544 100644
--- a/gdb/compile/compile-cplus-types.c
+++ b/gdb/compile/compile-cplus-types.c
@@ -580,7 +580,7 @@ static void
compile_cplus_convert_struct_or_union_members
(compile_cplus_instance *instance, struct type *type, gcc_type comp_type)
{
- for (int i = TYPE_N_BASECLASSES (type); i < TYPE_NFIELDS (type); ++i)
+ for (int i = TYPE_N_BASECLASSES (type); i < type->num_fields (); ++i)
{
const char *field_name = TYPE_FIELD_NAME (type, i);
@@ -938,7 +938,7 @@ compile_cplus_convert_enum (compile_cplus_instance *instance, struct type *type,
? GCC_CP_FLAG_ENUM_SCOPED
: GCC_CP_FLAG_ENUM_NOFLAG),
nullptr, 0);
- for (int i = 0; i < TYPE_NFIELDS (type); ++i)
+ for (int i = 0; i < type->num_fields (); ++i)
{
gdb::unique_xmalloc_ptr<char> fname
= compile_cplus_instance::decl_name (TYPE_FIELD_NAME (type, i));
@@ -986,9 +986,9 @@ compile_cplus_convert_func (compile_cplus_instance *instance,
gcc_type return_type = instance->convert_type (target_type);
struct gcc_type_array array =
- { TYPE_NFIELDS (type), XNEWVEC (gcc_type, TYPE_NFIELDS (type)) };
+ { type->num_fields (), XNEWVEC (gcc_type, type->num_fields ()) };
int artificials = 0;
- for (int i = 0; i < TYPE_NFIELDS (type); ++i)
+ for (int i = 0; i < type->num_fields (); ++i)
{
if (strip_artificial && TYPE_FIELD_ARTIFICIAL (type, i))
{
diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c
index 76a9418..7f5f593 100644
--- a/gdb/compile/compile-object-load.c
+++ b/gdb/compile/compile-object-load.c
@@ -505,7 +505,7 @@ get_regs_type (struct symbol *func_sym, struct objfile *objfile)
struct type *regsp_type, *regs_type;
/* No register parameter present. */
- if (TYPE_NFIELDS (func_type) == 0)
+ if (func_type->num_fields () == 0)
return NULL;
regsp_type = check_typedef (TYPE_FIELD_TYPE (func_type, 0));
@@ -534,7 +534,7 @@ store_regs (struct type *regs_type, CORE_ADDR regs_base)
struct gdbarch *gdbarch = target_gdbarch ();
int fieldno;
- for (fieldno = 0; fieldno < TYPE_NFIELDS (regs_type); fieldno++)
+ for (fieldno = 0; fieldno < regs_type->num_fields (); fieldno++)
{
const char *reg_name = TYPE_FIELD_NAME (regs_type, fieldno);
ULONGEST reg_bitpos = TYPE_FIELD_BITPOS (regs_type, fieldno);
@@ -670,10 +670,10 @@ compile_object_load (const compile_file_names &file_names,
default:
internal_error (__FILE__, __LINE__, _("invalid scope %d"), scope);
}
- if (TYPE_NFIELDS (func_type) != expect_parameters)
+ if (func_type->num_fields () != expect_parameters)
error (_("Invalid %d parameters of function \"%s\" in compiled "
"module \"%s\"."),
- TYPE_NFIELDS (func_type), GCC_FE_WRAPPER_FUNCTION,
+ func_type->num_fields (), GCC_FE_WRAPPER_FUNCTION,
objfile_name (objfile));
if (!types_deeply_equal (expect_return_type, TYPE_TARGET_TYPE (func_type)))
error (_("Invalid return type of function \"%s\" in compiled "
diff --git a/gdb/compile/compile-object-run.c b/gdb/compile/compile-object-run.c
index cef1d06..d8e2853 100644
--- a/gdb/compile/compile-object-run.c
+++ b/gdb/compile/compile-object-run.c
@@ -153,23 +153,23 @@ compile_object_run (struct compile_module *module)
func_val = value_from_pointer (lookup_pointer_type (func_type),
BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (func_sym)));
- vargs = XALLOCAVEC (struct value *, TYPE_NFIELDS (func_type));
- if (TYPE_NFIELDS (func_type) >= 1)
+ vargs = XALLOCAVEC (struct value *, func_type->num_fields ());
+ if (func_type->num_fields () >= 1)
{
gdb_assert (regs_addr != 0);
vargs[current_arg] = value_from_pointer
(TYPE_FIELD_TYPE (func_type, current_arg), regs_addr);
++current_arg;
}
- if (TYPE_NFIELDS (func_type) >= 2)
+ if (func_type->num_fields () >= 2)
{
gdb_assert (data->out_value_addr != 0);
vargs[current_arg] = value_from_pointer
(TYPE_FIELD_TYPE (func_type, current_arg), data->out_value_addr);
++current_arg;
}
- gdb_assert (current_arg == TYPE_NFIELDS (func_type));
- auto args = gdb::make_array_view (vargs, TYPE_NFIELDS (func_type));
+ gdb_assert (current_arg == func_type->num_fields ());
+ auto args = gdb::make_array_view (vargs, func_type->num_fields ());
call_function_by_hand_dummy (func_val, NULL, args,
do_module_cleanup, data);
}