Use std::string and unique_xmalloc_ptr in compile/ code

Change various things in the compile/ code to use std::string or
unique_xmalloc_ptr as appropriate.  This allows the removal of some
cleanups.

ChangeLog
2017-09-03  Tom Tromey  <tom@tromey.com>

	* compile/compile.c (compile_register_name_mangled): Return
	std::string.
	* compile/compile-loc2c.c (pushf_register_address): Update.
	(pushf_register): Update.
	* compile/compile-c-types.c (convert_array): Update.
	* compile/compile-c-symbols.c (generate_vla_size): Update.
	(error_symbol_once): Use a gdb::unique_xmalloc_ptr.
	(symbol_substitution_name): Return a gdb::unique_xmalloc_ptr.
	(convert_one_symbol): Update.
	(generate_c_for_for_one_variable): Update.
	* compile/compile-c-support.c (c_get_range_decl_name): Return a
	std::string.
	(generate_register_struct): Update.
	* compile/compile-internal.h (c_get_range_decl_name): Return a
	std::string.
	(compile_register_name_mangled): Return std::string.
This commit is contained in:
Tom Tromey
2017-08-14 00:03:02 -06:00
parent 18e9961f02
commit 8f84fb0ee8
7 changed files with 56 additions and 54 deletions

View File

@@ -123,18 +123,17 @@ convert_array (struct compile_c_instance *context, struct type *type)
|| TYPE_HIGH_BOUND_KIND (range) == PROP_LOCLIST)
{
gcc_type result;
char *upper_bound;
if (TYPE_VECTOR (type))
return C_CTX (context)->c_ops->error (C_CTX (context),
_("variably-sized vector type"
" is not supported"));
upper_bound = c_get_range_decl_name (&TYPE_RANGE_DATA (range)->high);
std::string upper_bound
= c_get_range_decl_name (&TYPE_RANGE_DATA (range)->high);
result = C_CTX (context)->c_ops->build_vla_array_type (C_CTX (context),
element_type,
upper_bound);
xfree (upper_bound);
upper_bound.c_str ());
return result;
}
else