This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA 8/8] Add constructor and destructor to demangle_parse_info
- From: Pedro Alves <palves at redhat dot com>
- To: Tom Tromey <tom at tromey dot com>, gdb-patches at sourceware dot org
- Date: Fri, 2 Dec 2016 15:04:15 +0000
- Subject: Re: [RFA 8/8] Add constructor and destructor to demangle_parse_info
- Authentication-results: sourceware.org; auth=none
- References: <1480395946-10924-1-git-send-email-tom@tromey.com> <1480395946-10924-9-git-send-email-tom@tromey.com>
On 11/29/2016 05:05 AM, Tom Tromey wrote:
> @@ -646,7 +623,8 @@ mangled_name_to_comp (const char *mangled_name, int options,
>
> /* If we could demangle the name, parse it to build the component
> tree. */
> - info = cp_demangled_name_to_comp (demangled_name, NULL);
> + std::unique_ptr<demangle_parse_info> info
> + (cp_demangled_name_to_comp (demangled_name, NULL));
Style question:
When initializing a unique_ptr from a function that returns a
unique_ptr already, IMO, using = reads a little better
over ()s, like:
std::unique_ptr<demangle_parse_info> info
= cp_demangled_name_to_comp (demangled_name, NULL);
I.e., kind of like how you'd call make_unique with '=' instead
of
unique_ptr<T> foo (make_unique<T>());
which I've never seen.
I wonder whether that's just me?
> diff --git a/gdb/cp-support.h b/gdb/cp-support.h
> index ca7a7d4..ffccded 100644
> --- a/gdb/cp-support.h
> +++ b/gdb/cp-support.h
> @@ -58,6 +58,10 @@ struct demangle_parse_info
>
> /* Any temporary memory used during typedef replacement. */
> struct obstack obstack;
> +
> + demangle_parse_info ();
> +
> + ~demangle_parse_info ();
Put these before the data fields.
Otherwise LGTM.
Thanks,
Pedro Alves