This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Make dwarf_expr_piece::pieces an std::vector
- From: Pedro Alves <palves at redhat dot com>
- To: Simon Marchi <simon dot marchi at ericsson dot com>, gdb-patches at sourceware dot org
- Cc: arnez at linux dot vnet dot ibm dot com
- Date: Thu, 14 Sep 2017 10:21:05 +0100
- Subject: Re: [PATCH] Make dwarf_expr_piece::pieces an std::vector
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=palves at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A24AF81DE4
- References: <1505376948-22860-1-git-send-email-simon.marchi@ericsson.com>
On 09/14/2017 09:15 AM, Simon Marchi wrote:
> static struct piece_closure *
> allocate_piece_closure (struct dwarf2_per_cu_data *per_cu,
> - int n_pieces, struct dwarf_expr_piece *pieces,
> + const std::vector<dwarf_expr_piece> &&pieces,
const rval reference looks odd -- you can't really move
the internal elements out of a const vector. I think ...
> struct frame_info *frame)
> {
> - struct piece_closure *c = XCNEW (struct piece_closure);
> + struct piece_closure *c = new piece_closure;
> int i;
>
> c->refc = 1;
> c->per_cu = per_cu;
> - c->n_pieces = n_pieces;
> - c->pieces = XCNEWVEC (struct dwarf_expr_piece, n_pieces);
> + c->pieces = std::move (pieces);
... this isn't really moving, but actually copying, because
you'll end up calling 'std::vector(const std::vector &)', not
'std::vector(std::vector &&)'.
I wonder if there's ever a case for 'const T &&' parameters,
and if GCC could warn about them. At least in non-template
functions.
Thanks,
Pedro Alves