From c8b23b3f89fbb0ed28d6b78f775b0038d8604798 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 28 Nov 2016 21:39:47 -0700 Subject: Add constructor and destructor to demangle_parse_info This adds a constructor and destructor to demangle_parse_info, and then changes all the users to use them. This removes make_cleanup_cp_demangled_name_parse_free and its single use. 2017-01-10 Tom Tromey * python/py-type.c (typy_legacy_template_argument): Update. * cp-support.h (struct demangle_parse_info) (demangle_parse_info, ~demangle_parse_info): Declare new members. (cp_demangled_name_to_comp): Return unique_ptr. (cp_demangled_name_parse_free) (make_cleanup_cp_demangled_name_parse_free) (cp_new_demangle_parse_info): Remove. * cp-support.c (do_demangled_name_parse_free_cleanup) (make_cleanup_cp_demangled_name_parse_free): Remove. (inspect_type, cp_canonicalize_string_full) (cp_canonicalize_string): Update. (mangled_name_to_comp): Change return type. (cp_class_name_from_physname, method_name_from_physname) (cp_func_name, cp_remove_params): Update. * cp-name-parser.y (demangle_parse_info): New constructor, from cp_new_demangle_parse_info. (~demangle_parse_info): New destructor, from cp_demangled_name_parse_free. (cp_merge_demangle_parse_infos): Update. (cp_demangled_name_to_comp): Change return type. --- gdb/cp-support.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'gdb/cp-support.h') diff --git a/gdb/cp-support.h b/gdb/cp-support.h index b93e2d6..9054bf6 100644 --- a/gdb/cp-support.h +++ b/gdb/cp-support.h @@ -50,6 +50,10 @@ struct using_direct; struct demangle_parse_info { + demangle_parse_info (); + + ~demangle_parse_info (); + /* The memory used during the parse. */ struct demangle_info *info; @@ -135,21 +139,16 @@ struct type *cp_find_type_baseclass_by_name (struct type *parent_type, /* Functions from cp-name-parser.y. */ -extern struct demangle_parse_info *cp_demangled_name_to_comp +extern std::unique_ptr cp_demangled_name_to_comp (const char *demangled_name, const char **errmsg); extern char *cp_comp_to_string (struct demangle_component *result, int estimated_len); -extern void cp_demangled_name_parse_free (struct demangle_parse_info *); -extern struct cleanup *make_cleanup_cp_demangled_name_parse_free - (struct demangle_parse_info *); extern void cp_merge_demangle_parse_infos (struct demangle_parse_info *, struct demangle_component *, struct demangle_parse_info *); -extern struct demangle_parse_info *cp_new_demangle_parse_info (void); - /* The list of "maint cplus" commands. */ extern struct cmd_list_element *maint_cplus_cmd_list; -- cgit v1.1