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 <tom@tromey.com> * 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.
This commit is contained in:
parent
1ac32117f7
commit
c8b23b3f89
5 changed files with 52 additions and 79 deletions
|
@ -832,7 +832,7 @@ typy_legacy_template_argument (struct type *type, const struct block *block,
|
|||
{
|
||||
int i;
|
||||
struct demangle_component *demangled;
|
||||
struct demangle_parse_info *info = NULL;
|
||||
std::unique_ptr<demangle_parse_info> info;
|
||||
const char *err;
|
||||
struct type *argtype;
|
||||
struct cleanup *cleanup;
|
||||
|
@ -860,7 +860,6 @@ typy_legacy_template_argument (struct type *type, const struct block *block,
|
|||
return NULL;
|
||||
}
|
||||
demangled = info->tree;
|
||||
cleanup = make_cleanup_cp_demangled_name_parse_free (info);
|
||||
|
||||
/* Strip off component names. */
|
||||
while (demangled->type == DEMANGLE_COMPONENT_QUAL_NAME
|
||||
|
@ -869,7 +868,6 @@ typy_legacy_template_argument (struct type *type, const struct block *block,
|
|||
|
||||
if (demangled->type != DEMANGLE_COMPONENT_TEMPLATE)
|
||||
{
|
||||
do_cleanups (cleanup);
|
||||
PyErr_SetString (PyExc_RuntimeError, _("Type is not a template."));
|
||||
return NULL;
|
||||
}
|
||||
|
@ -882,14 +880,12 @@ typy_legacy_template_argument (struct type *type, const struct block *block,
|
|||
|
||||
if (! demangled)
|
||||
{
|
||||
do_cleanups (cleanup);
|
||||
PyErr_Format (PyExc_RuntimeError, _("No argument %d in template."),
|
||||
argno);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
argtype = typy_lookup_type (demangled->u.s_binary.left, block);
|
||||
do_cleanups (cleanup);
|
||||
if (! argtype)
|
||||
return NULL;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue