mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-21 01:12:32 +08:00
Use reference result of emplace_back
Starting with C++17, emplace_back returns a reference to the new object. This patch changes code that uses emplace_back followed by a call to back() to simply use this reference instead. Approved-By: Simon Marchi <simon.marchi@efficios.com>
This commit is contained in:
parent
029e52bac7
commit
b36a26343a
@ -462,8 +462,8 @@ processInt (struct parser_state *par_state, const char *base0,
|
||||
return FLOAT;
|
||||
}
|
||||
|
||||
int_storage.emplace_back (new gdb_mpz (std::move (result)));
|
||||
const gdb_mpz *value = int_storage.back ().get ();
|
||||
const gdb_mpz *value
|
||||
= int_storage.emplace_back (new gdb_mpz (std::move (result))).get ();
|
||||
|
||||
int int_bits = gdbarch_int_bit (par_state->gdbarch ());
|
||||
int long_bits = gdbarch_long_bit (par_state->gdbarch ());
|
||||
|
@ -255,8 +255,8 @@ ftrace_new_function (struct btrace_thread_info *btinfo,
|
||||
insn_offset = prev->insn_offset + ftrace_call_num_insn (prev);
|
||||
}
|
||||
|
||||
btinfo->functions.emplace_back (mfun, fun, number, insn_offset, level);
|
||||
return &btinfo->functions.back ();
|
||||
return &btinfo->functions.emplace_back (mfun, fun, number, insn_offset,
|
||||
level);
|
||||
}
|
||||
|
||||
/* Update the UP field of a function segment. */
|
||||
|
@ -661,8 +661,7 @@ buildsym_compunit::record_line (struct subfile *subfile, int line,
|
||||
return;
|
||||
}
|
||||
|
||||
subfile->line_vector_entries.emplace_back ();
|
||||
linetable_entry &e = subfile->line_vector_entries.back ();
|
||||
linetable_entry &e = subfile->line_vector_entries.emplace_back ();
|
||||
e.line = line;
|
||||
e.is_stmt = (flags & LEF_IS_STMT) != 0;
|
||||
e.set_unrelocated_pc (pc);
|
||||
@ -1134,8 +1133,7 @@ buildsym_compunit::augment_type_symtab ()
|
||||
struct context_stack *
|
||||
buildsym_compunit::push_context (int desc, CORE_ADDR valu)
|
||||
{
|
||||
m_context_stack.emplace_back ();
|
||||
struct context_stack *newobj = &m_context_stack.back ();
|
||||
struct context_stack *newobj = &m_context_stack.emplace_back ();
|
||||
|
||||
newobj->depth = desc;
|
||||
newobj->locals = m_local_symbols;
|
||||
|
@ -1200,8 +1200,7 @@ dwarf_expr_context::stack_empty_p () const
|
||||
void
|
||||
dwarf_expr_context::add_piece (ULONGEST size, ULONGEST offset)
|
||||
{
|
||||
this->m_pieces.emplace_back ();
|
||||
dwarf_expr_piece &p = this->m_pieces.back ();
|
||||
dwarf_expr_piece &p = this->m_pieces.emplace_back ();
|
||||
|
||||
p.location = this->m_location;
|
||||
p.size = size;
|
||||
|
@ -11552,15 +11552,9 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
|
||||
const char *fieldname = "";
|
||||
|
||||
if (die->tag == DW_TAG_inheritance)
|
||||
{
|
||||
fip->baseclasses.emplace_back ();
|
||||
new_field = &fip->baseclasses.back ();
|
||||
}
|
||||
new_field = &fip->baseclasses.emplace_back ();
|
||||
else
|
||||
{
|
||||
fip->fields.emplace_back ();
|
||||
new_field = &fip->fields.back ();
|
||||
}
|
||||
new_field = &fip->fields.emplace_back ();
|
||||
|
||||
new_field->offset = die->sect_off;
|
||||
|
||||
@ -12071,16 +12065,14 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
|
||||
/* Create a new fnfieldlist if necessary. */
|
||||
if (flp == nullptr)
|
||||
{
|
||||
fip->fnfieldlists.emplace_back ();
|
||||
flp = &fip->fnfieldlists.back ();
|
||||
flp = &fip->fnfieldlists.emplace_back ();
|
||||
flp->name = fieldname;
|
||||
i = fip->fnfieldlists.size () - 1;
|
||||
}
|
||||
|
||||
/* Create a new member function field and add it to the vector of
|
||||
fnfieldlists. */
|
||||
flp->fnfields.emplace_back ();
|
||||
fnp = &flp->fnfields.back ();
|
||||
fnp = &flp->fnfields.emplace_back ();
|
||||
|
||||
/* Delay processing of the physname until later. */
|
||||
if (cu->lang () == language_cplus)
|
||||
@ -12681,10 +12673,7 @@ handle_variant_part (struct die_info *die, struct type *type,
|
||||
{
|
||||
variant_part_builder *new_part;
|
||||
if (fi->current_variant_part == nullptr)
|
||||
{
|
||||
fi->variant_parts.emplace_back ();
|
||||
new_part = &fi->variant_parts.back ();
|
||||
}
|
||||
new_part = &fi->variant_parts.emplace_back ();
|
||||
else if (!fi->current_variant_part->processing_variant)
|
||||
{
|
||||
complaint (_("nested DW_TAG_variant_part seen "
|
||||
@ -12696,8 +12685,7 @@ handle_variant_part (struct die_info *die, struct type *type,
|
||||
else
|
||||
{
|
||||
variant_field ¤t = fi->current_variant_part->variants.back ();
|
||||
current.variant_parts.emplace_back ();
|
||||
new_part = ¤t.variant_parts.back ();
|
||||
new_part = ¤t.variant_parts.emplace_back ();
|
||||
}
|
||||
|
||||
/* When we recurse, we want callees to add to this new variant
|
||||
@ -12761,8 +12749,7 @@ handle_variant (struct die_info *die, struct type *type,
|
||||
= make_scoped_restore (&fi->current_variant_part->processing_variant,
|
||||
true);
|
||||
|
||||
fi->current_variant_part->variants.emplace_back ();
|
||||
variant_field &variant = fi->current_variant_part->variants.back ();
|
||||
variant_field &variant = fi->current_variant_part->variants.emplace_back ();
|
||||
variant.first_field = fi->fields.size ();
|
||||
|
||||
/* In a variant we want to get the discriminant and also add a
|
||||
@ -13157,8 +13144,7 @@ update_enumeration_type_from_children (struct die_info *die,
|
||||
flag_enum = 0;
|
||||
}
|
||||
|
||||
fields.emplace_back ();
|
||||
struct field &field = fields.back ();
|
||||
struct field &field = fields.emplace_back ();
|
||||
field.set_name (dwarf2_physname (name, child_die, cu));
|
||||
field.set_loc_enumval (value);
|
||||
}
|
||||
|
@ -789,12 +789,10 @@ gather_arguments (const char *name, shared_macro_buffer *src, int nargs,
|
||||
|
||||
for (;;)
|
||||
{
|
||||
shared_macro_buffer *arg;
|
||||
int depth;
|
||||
|
||||
/* Initialize the next argument. */
|
||||
args.emplace_back ();
|
||||
arg = &args.back ();
|
||||
shared_macro_buffer *arg = &args.emplace_back ();
|
||||
set_token (arg, src->text, src->text);
|
||||
|
||||
/* Gather the argument's tokens. */
|
||||
@ -819,8 +817,7 @@ gather_arguments (const char *name, shared_macro_buffer *src, int nargs,
|
||||
missing. Add an empty argument in this case. */
|
||||
if (nargs != -1 && args.size () == nargs - 1)
|
||||
{
|
||||
args.emplace_back ();
|
||||
arg = &args.back ();
|
||||
arg = &args.emplace_back ();
|
||||
set_token (arg, src->text, src->text);
|
||||
}
|
||||
|
||||
|
@ -4027,8 +4027,7 @@ start_thread (struct gdb_xml_parser *parser,
|
||||
char *id = (char *) xml_find_attribute (attributes, "id")->value.get ();
|
||||
ptid_t ptid = read_ptid (id, NULL);
|
||||
|
||||
data->items.emplace_back (ptid);
|
||||
thread_item &item = data->items.back ();
|
||||
thread_item &item = data->items.emplace_back (ptid);
|
||||
|
||||
attr = xml_find_attribute (attributes, "core");
|
||||
if (attr != NULL)
|
||||
|
@ -123,8 +123,7 @@ save_bookmark_command (const char *args, int from_tty)
|
||||
error (_("target_get_bookmark failed."));
|
||||
|
||||
/* Set up a bookmark struct. */
|
||||
all_bookmarks.emplace_back ();
|
||||
bookmark &b = all_bookmarks.back ();
|
||||
bookmark &b = all_bookmarks.emplace_back ();
|
||||
b.number = ++bookmark_count;
|
||||
b.pc = regcache_read_pc (regcache);
|
||||
b.sal = find_pc_line (b.pc, 0);
|
||||
|
@ -253,8 +253,7 @@ set_traceframe_context (frame_info_ptr trace_frame)
|
||||
struct trace_state_variable *
|
||||
create_trace_state_variable (const char *name)
|
||||
{
|
||||
tvariables.emplace_back (name, next_tsv_number++);
|
||||
return &tvariables.back ();
|
||||
return &tvariables.emplace_back (name, next_tsv_number++);
|
||||
}
|
||||
|
||||
/* Look for a trace state variable of the given name. */
|
||||
|
11
gdb/ui-out.c
11
gdb/ui-out.c
@ -905,10 +905,7 @@ buffer_group::write (const char *buf, long length_buf, ui_file *stream)
|
||||
&& m_buffered_output.back ().m_msg.back () != '\n')
|
||||
m_buffered_output.back ().m_msg.append (msg);
|
||||
else
|
||||
{
|
||||
m_buffered_output.emplace_back (msg);
|
||||
m_buffered_output.back ().m_stream = stream;
|
||||
}
|
||||
m_buffered_output.emplace_back (msg).m_stream = stream;
|
||||
prev = cur + 1;
|
||||
}
|
||||
}
|
||||
@ -918,8 +915,7 @@ buffer_group::write (const char *buf, long length_buf, ui_file *stream)
|
||||
void
|
||||
buffer_group::wrap_here (int indent, ui_file *stream)
|
||||
{
|
||||
m_buffered_output.emplace_back ("", indent);
|
||||
m_buffered_output.back ().m_stream = stream;
|
||||
m_buffered_output.emplace_back ("", indent).m_stream = stream;
|
||||
}
|
||||
|
||||
/* See ui-out.h. */
|
||||
@ -927,8 +923,7 @@ buffer_group::wrap_here (int indent, ui_file *stream)
|
||||
void
|
||||
buffer_group::flush_here (ui_file *stream)
|
||||
{
|
||||
m_buffered_output.emplace_back ("", -1, true);
|
||||
m_buffered_output.back ().m_stream = stream;
|
||||
m_buffered_output.emplace_back ("", -1, true).m_stream = stream;
|
||||
}
|
||||
|
||||
/* See ui-out.h. */
|
||||
|
@ -887,8 +887,7 @@ windows_make_so (const char *name, LPVOID load_addr)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
windows_process.solibs.emplace_back ();
|
||||
windows_solib *so = &windows_process.solibs.back ();
|
||||
windows_solib *so = &windows_process.solibs.emplace_back ();
|
||||
so->load_addr = load_addr;
|
||||
so->original_name = name;
|
||||
#ifndef __CYGWIN__
|
||||
|
@ -428,8 +428,7 @@ arrange_linetable (std::vector<linetable_entry> &old_linetable)
|
||||
if (old_linetable[ii].line == 0)
|
||||
{
|
||||
/* Function entry found. */
|
||||
fentries.emplace_back ();
|
||||
linetable_entry &e = fentries.back ();
|
||||
linetable_entry &e = fentries.emplace_back ();
|
||||
e.line = ii;
|
||||
e.is_stmt = true;
|
||||
e.set_unrelocated_pc (old_linetable[ii].unrelocated_pc ());
|
||||
|
Loading…
Reference in New Issue
Block a user