gdb: add type::is_prototyped / type::set_is_prototyped

Add the `is_prototyped` and `set_is_prototyped` methods on `struct
type`, in order to remove the `TYPE_PROTOTYPED` macro.  In this patch,
the macro is changed to use the getter, so all the call sites of the
macro that are used as a setter are changed to use the setter method
directly.  The next patch will remove the macro completely.

gdb/ChangeLog:

	* gdbtypes.h (struct type) <is_prototyped, set_is_prototyped>:
	New methods.
	(TYPE_PROTOTYPED): Use type::is_prototyped, change all write
	call sites to use type::set_is_prototyped.

Change-Id: I6ba285250fae413f7c1bf2ffcb5a2cedc8e743da
This commit is contained in:
Simon Marchi 2020-09-14 11:08:00 -04:00
parent d218396806
commit 27e69b7aed
7 changed files with 27 additions and 10 deletions

View File

@ -1,3 +1,10 @@
2020-09-14 Simon Marchi <simon.marchi@efficios.com>
* gdbtypes.h (struct type) <is_prototyped, set_is_prototyped>:
New methods.
(TYPE_PROTOTYPED): Use type::is_prototyped, change all write
call sites to use type::set_is_prototyped.
2020-09-14 Simon Marchi <simon.marchi@efficios.com>
* gdbtypes.h (TYPE_TARGET_STUB): Remove, replace all

View File

@ -17665,7 +17665,7 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu)
ftype = lookup_function_type (type);
if (prototyped_function_p (die, cu))
TYPE_PROTOTYPED (ftype) = 1;
ftype->set_is_prototyped (true);
/* Store the calling convention in the type if it's available in
the subroutine die. Otherwise set the calling convention to

View File

@ -673,7 +673,7 @@ fake_method::fake_method (type_instance_flags flags,
--num_types;
/* Caller should have ensured this. */
gdb_assert (num_types == 0);
TYPE_PROTOTYPED (type) = 1;
type->set_is_prototyped (true);
}
}

View File

@ -560,10 +560,10 @@ lookup_function_type_with_arguments (struct type *type,
--nparams;
/* Caller should have ensured this. */
gdb_assert (nparams == 0);
TYPE_PROTOTYPED (fn) = 1;
fn->set_is_prototyped (true);
}
else
TYPE_PROTOTYPED (fn) = 1;
fn->set_is_prototyped (true);
}
fn->set_num_fields (nparams);

View File

@ -221,7 +221,7 @@ DEF_ENUM_FLAGS_TYPE (enum type_instance_flag_value, type_instance_flags);
to coerce the args, or to just do the standard conversions. This
is used with a short field. */
#define TYPE_PROTOTYPED(t) (TYPE_MAIN_TYPE (t)->flag_prototyped)
#define TYPE_PROTOTYPED(t) ((t)->is_prototyped ())
/* * FIXME drow/2002-06-03: Only used for methods, but applies as well
to functions. */
@ -834,7 +834,7 @@ struct main_type
unsigned int m_flag_nosign : 1;
unsigned int m_flag_stub : 1;
unsigned int m_flag_target_stub : 1;
unsigned int flag_prototyped : 1;
unsigned int m_flag_prototyped : 1;
unsigned int flag_varargs : 1;
unsigned int flag_vector : 1;
unsigned int flag_stub_supported : 1;
@ -1100,6 +1100,16 @@ struct type
this->main_type->m_flag_target_stub = target_is_stub;
}
bool is_prototyped () const
{
return this->main_type->m_flag_prototyped;
}
void set_is_prototyped (bool is_prototyped)
{
this->main_type->m_flag_prototyped = is_prototyped;
}
/* * Return the dynamic property of the requested KIND from this type's
list of dynamic properties. */
dynamic_prop *dyn_prop (dynamic_prop_node_kind kind) const;

View File

@ -786,7 +786,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
/* All functions in C++ have prototypes. For C we don't have enough
information in the debug info. */
if (s->language () == language_cplus)
TYPE_PROTOTYPED (SYMBOL_TYPE (s)) = 1;
SYMBOL_TYPE (s)->set_is_prototyped (true);
/* Create and enter a new lexical context. */
b = new_block (FUNCTION_BLOCK, s->language ());

View File

@ -958,7 +958,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
than the "declared-as" type for unprototyped functions, so
we treat all functions as if they were prototyped. This is used
primarily for promotion when calling the function from GDB. */
TYPE_PROTOTYPED (SYMBOL_TYPE (sym)) = 1;
SYMBOL_TYPE (sym)->set_is_prototyped (true);
/* fall into process_prototype_types. */
@ -1005,7 +1005,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
TYPE_FIELD_ARTIFICIAL (ftype, nparams++) = 0;
}
ftype->set_num_fields (nparams);
TYPE_PROTOTYPED (ftype) = 1;
ftype->set_is_prototyped (true);
}
break;
@ -1813,7 +1813,7 @@ read_type (const char **pp, struct objfile *objfile)
func_type->field (i).set_type (t->type);
}
func_type->set_num_fields (num_args);
TYPE_PROTOTYPED (func_type) = 1;
func_type->set_is_prototyped (true);
type = func_type;
break;