This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA 8/8] Add constructor and destructor to demangle_parse_info


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]