handle <local-source-name> in demangler

Geoffrey Keating geoffk@apple.com
Thu Nov 9 00:05:00 GMT 2006

On 08/11/2006, at 12:39 AM, Ian Lance Taylor wrote:

> gkeating@apple.com (Geoffrey Keating) writes:
>> Following up on
>> <http://gcc.gnu.org/ml/gcc/2006-10/msg00441.html>,
>> this patch implements Mark's preferred option,
>>     <unqualified-name> ::= <operator-name>
>>                        ::= <ctor-dtor-name>
>>                        ::= <source-name>
>> 		       ::= <local-source-name>   // new
>>     <local-source-name> ::= Z <source-name> <discriminator>  // new
> The mangling scheme right now has the property that you can
> unambiguously tell what to do as you see each character.  This
> proposal breaks that property.  Now 'Z' can either be the start of a
> <local-source-name> or a <local-name>, which makes <name> ambiguous.
> So even though Mark suggested it, I don't think this is a good
> encoding.

Yes.  I made basically these points in the mail to which the URL above  
is a reply.

> This shows up in your patch, which does things the demangler code
> doesn't do anywhere else, like refer directly to di->n, and save and
> restore its position.  And the save and restore does not work
> correctly anyhow, since it does not reset di->next_comp.

Yes.  Fortunately that last is easy to fix.

> How about adding a case to local-name?
> <local-name> ::= Z <(function) encoding> E <(entity) name>  
> [<discriminator>]
>              ::= Z <(function) encoding> E s [<discriminator>]
>              ::= Z E <source-name> <discriminator>
> This is unambiguous, as 'E' can not appear at the start of <encoding>.
> It is very unlikely that we would ever want 'E' to appear at the start
> of <encoding>, since it is used in a number of places to mark the end
> of a list.

You mean, in addition to the <local-source-name> change?  So:

     <name> ::= <nested-name>
	   ::= <unscoped-name>
	   ::= <unscoped-template-name> <template-args>
	   ::= <local-name>

     <unscoped-name> ::= <unqualified-unscoped-name>
		    ::= St <unqualified-name>   # ::std::

     <unqualified-unscoped-name> ::= <operator-name>
	                        ::= <ctor-dtor-name>
	                        ::= <source-name>

     <unqualified-name> ::= <unqualified-unscoped-name>
		       ::= Z <local-source-name>

     <local-source-name> ::= <source-name> <discriminator>

     <local-template-source-name> ::= <local-source-name>
				 ::= <substitution>

     <local-name> ::= Z <(function) encoding> E <(entity) name>  
                  ::= Z <(function) encoding> E s [<discriminator>]
		 ::= Z E <local-source-name>
		 ::= Z E <local-template-source-name> <template-args>

This seems a little complex to me.  Maybe it would be easier to just do

     <unqualified-name> ::= <operator-name>
                        ::= <ctor-dtor-name>
                        ::= <source-name>
		       ::= <local-source-name>   // new

     <local-source-name> ::= Z E <source-name> <discriminator>  // new

Any objections?  Mark?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2462 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20061109/65bfdd1b/attachment.p7s>

More information about the Binutils mailing list