mangling of function names

Alex Samuel samuel at codesourcery.com
Fri May 12 21:16:14 UTC 2000


Martin von Loewis <loewis at informatik.hu-berlin.de> writes:

  Martin> There are actually cases where it then would get
  Martin> substituted:

    struct klasse{
      struct methode{};
      void methode(struct methode);
    };

    void klasse::methode(struct methode){}

  Martin> Now, if it is considered too difficult for implementations
  Martin> to detect that substitution is needed here, or if it is
  Martin> unclear from the spec whether substitution should happen -
  Martin> then that would make a point for complicating the
  Martin> spec. 

I hadn't even considered this possibility.  I think it argues for
changing the name grammar again.

Here's an attempt to accomplish this.  This grammar replaces
<mangled-name> through <unqualified-name>  I've tried to accomplish
these things:

  - Separate the logic for encoding names in the global scope from
    <unqualfied-name>, which is a name without scope qualification.

  - Add substitution candidates for template names before template-ids
    by forking <unscoped-name> into <unscoped-template-name> and
    <prefix> into <template-prefix>.

  - Add the special compression rule that avoids a <nested-name> for
    names in ::std.

  - Split <special-name> into <special-data-name> and
    <special-function-name>.  

    <special-data-name> for vtables, VTTs, typeinfo, typeinfo names, 
                        guard variables, and thunks [these are mangled as 
			data, right?]

    <special-function-name> for ctors and dtors

I think this is a simplification to the existing grammar that
addresses the function name issue discussed yesterday, and also
corrects some omissions (for instance, in the existing grammar, 
untemplated operator names inside a namespace other than ::std were
not produced).

Regards
Alex


------------------------------------------------------------------------

    <mangled-name>      ::= _Z <name>

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

#
# A non-template or template-id name in :: or ::std scope.
#

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

#
# A template name in :: or ::std scope.  
#

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

#
# A name not in :: or ::std scope.
#

    <nested-name>       ::= N [<CV-qualifiers>] <prefix> E

#
# A prefix of a scoped name. 
#

    <prefix>            ::= <prefix> <component>
                        ::= <template-prefix> <template-args>
			::= # empty
			::= <substitution>

#
# A scoped template name that occurs in a prefix.  
#

    <template-prefix>   ::= <prefix>
                        ::= <substitution>

#
# A component of a scoped name.  
#

    <component>         ::= <unqualified-name>
                        ::= <builtin-type>
                        ::= <function-type>
			::= <array-type>
			::= <pointer-to-member-type>

#
# A name without scope or template qualifications.
#

    <unqualified-name>  ::= <function-name> <bare-function-type>
			::= <special-data-name>  # vtable, VTT, typeinfo, ...
			::= <source-name>        # namespace, class, data, ...

#
# A name of a function without scope or template qualifications or
# function signature.
#

    <function-name>     ::= <special-function-name>  # ctor, dtor
                        ::= <operator-name>
                        ::= <source-name>




More information about the cxx-abi-dev mailing list