On Wed, Sep 04, 2013 at 03:29:43PM +0100, Gary Benson wrote:
> I've added the result to the demangler test suite, but I know of
> no way to check the validity of the demangled symbol other than by
> inspection (and I am no expert here!)  If anybody knows a way to
> check this then please let me know!  Otherwise, I hope this
> not-really-checked demangled version is acceptable.

Unfortunately this patch broke GCC bootstrap.
cp-demangle.c isn't used just in libiberty, where using hashtab,
xcalloc, XNEW etc. is fine, but also in libsupc++/libstdc++, where
none of that is fine.  That is why cp-demangle.c only uses e.g. realloc,
checks for allocation failures and propagates those to the caller
if they happen (see allocation_failure field).  hashtab.o isn't linked
into libstdc++ nor libsupc++, and the question is if we really do want to
link all the hashtable code into libstdc++.
How many hash table entries are there typically?  Is a hashtable required?

> diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
> index e4ce0b9..a084282 100644
> --- a/libiberty/ChangeLog
> +++ b/libiberty/ChangeLog
> @@ -1,3 +1,22 @@
> +2013-09-04  Gary Benson  <gben...@redhat.com>
> +
> +     * cp-demangle.c: Include hashtab.h.
> +     (struct d_print_info): New field saved_scopes.
> +     (d_print_init): Initialize the above.
> +     (d_print_free): New function.
> +     (cplus_demangle_print_callback): Call the above.
> +     (struct d_saved_scope): New structure.
> +     (d_store_scope): New function.
> +     (d_free_scope) Likewise.
> +     (d_restore_scope) Likewise.
> +     (d_hash_saved_scope) Likewise.
> +     (d_equal_saved_scope) Likewise.
> +     (d_print_comp): New variable saved_scope.
> +     [DEMANGLE_COMPONENT_REFERENCE,
> +     DEMANGLE_COMPONENT_RVALUE_REFERENCE]: Capture scope the first
> +     time the component is traversed, and use the captured scope for
> +     subsequent traversals.

        Jakub

Reply via email to