problem with local name mangling

Alex Samuel samuel at codesourcery.com
Mon Aug 28 05:01:23 UTC 2000


Folks,

I've come across problems while debugging mangling of local names.
Currently,

  <name> ::= <local-name>

and also 

  <component> ::= <local-name>

where

  <local-name> ::= Z <function encoding> E <entity name> [<discriminator>]

This means that the <local-name> and therefore the function's
<encoding> appears twice for each local name, once at the top level,
in <name>, and once when expanding the list of components that makes
up the name.  There should be no need for the <component> production
above; function scope should be handled at the <name> level.

Two other things that should probably be spelled out explicitly:

  - In the case of nested function scopes, the first <local-name>
    evaluated should be the innermost function scope.

  - When invoking <entity name> from <local-name>, the expansion of
    <name> needs to stop at the innermost function scope, to prevent
    an infinite recusion.

Also, if the <component> production above is removed, <component>
is synonymous with <unqualified-name> and therefore can be removed.

Finally, the production

  <class-enum-type> ::= <local-name>

is redundant because of

  <class-enum-type> ::= <name>


Here's an example of a local name expansion, as I understand it:

  void foo () {
    struct C {
      void bar () {
        struct D {
          void baz () {
          }
        };
      }
    };
  }

This requires two levels of <local-name>.  The mangling for baz() is

  _ZZZ3foovEN1C3barEvEN1D3bazEv
     <--local-name--->
    <-------local-name------->


To summarize, the changes I think we need are:

  - Remove: <component>

  - Replace: all uses of <component> with <unqualified-name>

  - Remove: <class-enum-type> ::= <local-name>

     ( one might even imagine removing <class-enum-type> altogether and
       simply using  <type> ::= <class-enum name> )

  - Specify that, in the production <name> ::= <local-name>, the
    innermost local name is handled first.

  - Specify that, in the production for <local-name>, when <name> is
    used the assumption is that local function scopes are subsequently
    ignored.  (One could do this with an alternate production for
    <name>, instead.)


Does this make sense to people?

Regards
Alex




More information about the cxx-abi-dev mailing list