X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=gdb%2Fcp-support.c;h=367fb6a20bbf5c14046a3a06738c26e3108790ae;hb=8677059126a84cb9f71371beb8688138a41014fc;hp=fb4e4289777aac9ddcc97faf6155bf8701b9ed52;hpb=fece451c2aca57b095e7e4063e342781cf74aa75;p=binutils-gdb.git diff --git a/gdb/cp-support.c b/gdb/cp-support.c index fb4e4289777..367fb6a20bb 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -661,10 +661,9 @@ cp_canonicalize_string (const char *string) static std::unique_ptr mangled_name_to_comp (const char *mangled_name, int options, - void **memory, char **demangled_p) + void **memory, + gdb::unique_xmalloc_ptr *demangled_p) { - char *demangled_name; - /* If it looks like a v3 mangled name, then try to go directly to trees. */ if (mangled_name[0] == '_' && mangled_name[1] == 'Z') @@ -684,22 +683,20 @@ mangled_name_to_comp (const char *mangled_name, int options, /* If it doesn't, or if that failed, then try to demangle the name. */ - demangled_name = gdb_demangle (mangled_name, options); + gdb::unique_xmalloc_ptr demangled_name = gdb_demangle (mangled_name, + options); if (demangled_name == NULL) return NULL; /* If we could demangle the name, parse it to build the component tree. */ std::unique_ptr info - = cp_demangled_name_to_comp (demangled_name, NULL); + = cp_demangled_name_to_comp (demangled_name.get (), NULL); if (info == NULL) - { - xfree (demangled_name); - return NULL; - } + return NULL; - *demangled_p = demangled_name; + *demangled_p = std::move (demangled_name); return info; } @@ -709,7 +706,7 @@ char * cp_class_name_from_physname (const char *physname) { void *storage = NULL; - char *demangled_name = NULL; + gdb::unique_xmalloc_ptr demangled_name; gdb::unique_xmalloc_ptr ret; struct demangle_component *ret_comp, *prev_comp, *cur_comp; std::unique_ptr info; @@ -789,7 +786,6 @@ cp_class_name_from_physname (const char *physname) } xfree (storage); - xfree (demangled_name); return ret.release (); } @@ -857,7 +853,7 @@ char * method_name_from_physname (const char *physname) { void *storage = NULL; - char *demangled_name = NULL; + gdb::unique_xmalloc_ptr demangled_name; gdb::unique_xmalloc_ptr ret; struct demangle_component *ret_comp; std::unique_ptr info; @@ -875,7 +871,6 @@ method_name_from_physname (const char *physname) ret = cp_comp_to_string (ret_comp, 10); xfree (storage); - xfree (demangled_name); return ret.release (); } @@ -1335,8 +1330,7 @@ add_symbol_overload_list_adl_namespace (struct type *type, const char *type_name; int i, prefix_len; - while (type->code () == TYPE_CODE_PTR - || TYPE_IS_REFERENCE (type) + while (type->is_pointer_or_reference () || type->code () == TYPE_CODE_ARRAY || type->code () == TYPE_CODE_TYPEDEF) { @@ -1452,10 +1446,7 @@ add_symbol_overload_list_qualified (const char *func_name, matching FUNC_NAME. Make sure we read that symbol table in. */ for (objfile *objf : current_program_space->objfiles ()) - { - if (objf->sf) - objf->sf->qf->expand_symtabs_for_function (objf, func_name); - } + objf->expand_symtabs_for_function (func_name); /* Search upwards from currently selected frame (so that we can complete on local vars. */ @@ -1608,10 +1599,10 @@ report_failed_demangle (const char *name, bool core_dump_allowed, /* A wrapper for bfd_demangle. */ -char * +gdb::unique_xmalloc_ptr gdb_demangle (const char *name, int options) { - char *result = NULL; + gdb::unique_xmalloc_ptr result; int crash_signal = 0; #ifdef HAVE_WORKING_FORK @@ -1640,7 +1631,7 @@ gdb_demangle (const char *name, int options) #endif if (crash_signal == 0) - result = bfd_demangle (NULL, name, options); + result.reset (bfd_demangle (NULL, name, options)); #ifdef HAVE_WORKING_FORK if (catch_demangler_crashes) @@ -2212,13 +2203,12 @@ void _initialize_cp_support (); void _initialize_cp_support () { - add_basic_prefix_cmd ("cplus", class_maintenance, - _("C++ maintenance commands."), - &maint_cplus_cmd_list, - "maintenance cplus ", - 0, &maintenancelist); - add_alias_cmd ("cp", "cplus", - class_maintenance, 1, + cmd_list_element *maintenance_cplus + = add_basic_prefix_cmd ("cplus", class_maintenance, + _("C++ maintenance commands."), + &maint_cplus_cmd_list, + 0, &maintenancelist); + add_alias_cmd ("cp", maintenance_cplus, class_maintenance, 1, &maintenancelist); add_cmd ("first_component",