aboutsummaryrefslogtreecommitdiff
path: root/gdb/compile/compile-loc2c.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-08-14 00:03:02 -0600
committerTom Tromey <tom@tromey.com>2017-09-03 13:03:10 -0600
commit8f84fb0ee87e8f149523e13815c58e1b664d184f (patch)
tree24e32c98b3a0c898b7a32bf905b23f4b38f4f79e /gdb/compile/compile-loc2c.c
parent18e9961f02b326923553f34682f4dcca0f25702e (diff)
downloadgdb-8f84fb0ee87e8f149523e13815c58e1b664d184f.zip
gdb-8f84fb0ee87e8f149523e13815c58e1b664d184f.tar.gz
gdb-8f84fb0ee87e8f149523e13815c58e1b664d184f.tar.bz2
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.
Diffstat (limited to 'gdb/compile/compile-loc2c.c')
-rw-r--r--gdb/compile/compile-loc2c.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/gdb/compile/compile-loc2c.c b/gdb/compile/compile-loc2c.c
index ead1003..7ec6f67 100644
--- a/gdb/compile/compile-loc2c.c
+++ b/gdb/compile/compile-loc2c.c
@@ -515,15 +515,12 @@ pushf_register_address (int indent, string_file &stream,
unsigned char *registers_used,
struct gdbarch *gdbarch, int regnum)
{
- char *regname = compile_register_name_mangled (gdbarch, regnum);
- struct cleanup *cleanups = make_cleanup (xfree, regname);
+ std::string regname = compile_register_name_mangled (gdbarch, regnum);
registers_used[regnum] = 1;
pushf (indent, stream,
"(" GCC_UINTPTR ") &" COMPILE_I_SIMPLE_REGISTER_ARG_NAME "->%s",
- regname);
-
- do_cleanups (cleanups);
+ regname.c_str ());
}
/* Emit code that pushes a register's value on the stack.
@@ -536,19 +533,16 @@ pushf_register (int indent, string_file &stream,
unsigned char *registers_used,
struct gdbarch *gdbarch, int regnum, uint64_t offset)
{
- char *regname = compile_register_name_mangled (gdbarch, regnum);
- struct cleanup *cleanups = make_cleanup (xfree, regname);
+ std::string regname = compile_register_name_mangled (gdbarch, regnum);
registers_used[regnum] = 1;
if (offset == 0)
pushf (indent, stream, COMPILE_I_SIMPLE_REGISTER_ARG_NAME "->%s",
- regname);
+ regname.c_str ());
else
pushf (indent, stream,
COMPILE_I_SIMPLE_REGISTER_ARG_NAME "->%s + (" GCC_UINTPTR ") %s",
- regname, hex_string (offset));
-
- do_cleanups (cleanups);
+ regname.c_str (), hex_string (offset));
}
/* Compile a DWARF expression to C code.