[RFA] c++/12266 (again) [cp_demangled_name_parse_free-4.patch]

Keith Seitz keiths@redhat.com
Tue Aug 9 20:23:00 GMT 2011


On 08/02/2011 01:28 PM, Jan Kratochvil wrote:
> $ make test-cp-name-parser
> cp-name-parser.y:2018: undefined reference to `make_cleanup'

Fixed.

>> +  result = ((struct demangle_parse_info *)
>> +	    malloc (sizeof (struct demangle_parse_info)));
>
> This cast seems redundant to me.

Removed. GDB is a mish-mash of usage discrepancies like this. [Mind you, 
a C++ compiler will complain about this.]

>> +	  info = ((struct demangle_parse_info *)
>> +		  xmalloc (sizeof (struct demangle_parse_info)));
>
> Redundant cast.

Removed.

> I guess you have been considering it but anyway:
>
> Its ->tree items can reference for s_name the original string being demangled,
> as you even state in some comments.  Due to it it also requires later explicit
> handling of `free_list'.  Could this struct already have the original string
> duplicated and this struct would track its freeing?
> cp_merge_demangle_parse_infos would then track all the source strings in the
> merged destination demangle_parse_info.

That is actually something that didn't occur to me for some reason, but 
I've made the necessary changes to use an obstack. [This change can be 
seen in the next patch, since it is not strictly necessary for this 
cleanup/refactoring.]

New patch attached.

Keith

ChangeLog
2011-08-09  Keith Seitz  <keiths@redhat.com>

	* cp-name-parser.y (struct demangle_info): Remove unused
	member PREV.
	(d_grab): Likewise.
	(allocate_info): Change return type to struct demangle_info *.
	Always allocate a new demangle_info.
	Remove unused PREV pointer.
	(cp_new_demangle_parse_info): New function.
	(cp_demangled_name_parse_free): New function.
  	(do_demangled_name_parse_free_cleanup): New function.
	(make_cleanup_cp_demangled_name_parse_free): New function.
	(cp_demangled_name_to_comp): Change return type to
	struct demangle_parse_info *.
	Allocate a new storage for each call.
	(main): Update usage for cp_demangled_name_to_comp
	API change.
	* cp-support.h (struct demangle_parse_info): New structure.
	(cp_demangled_name_to_comp): Update API change for
	return type.
	(cp_new_demangle_parse_info): Declare.
	(make_cleanup_cp_demangled_name_parse_free): New declaration.
	(cp_demangled_name_parse_free): Declare.
	* cp-support.c (cp_canonicalize_string): Update API
	change for cp_demangled_name_to_comp.
	(mangled_name_to_comp): Likewise.
	Return struct demangle_parse_info, too.
	(cp_class_name_from_physname): Update mangled_name_to_comp
	API change.
	(method_name_from_physname): Likewise.
	(cp_func_name): Update API change for cp_demangled_name_to_comp.
	(cp_remove_params): Likewise.
	* python/py-type.c (typy_legacy_template_argument): Likewise.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cp_demangled_name_parse_free-5.patch
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20110809/36da37e6/attachment.ksh>


More information about the Gdb-patches mailing list