mangling of local names

John Wilkinson jfw at sgi.com
Fri Mar 31 22:09:36 UTC 2000


Here's some proposed new language for local name mangling:


-- 
John Wilkinson
-------------- next part --------------
Here is a proposed revision for the scope encoding section:

Occasionally an entity in a local scope must be mangled too (e.g. because
inlining or template instantiation causes multiple translation
units to require access to that entity).  The encoding for such entities
is as follows:

  <local-name> := Z <'function' encoding> E [<discriminator>] <'entity' name>
	       := Z <'function' encoding> E S <hashed-literal>

  <discriminator> := <number>_

The second production is used for string literals, which are hashed using
some yet-to-be-determined function.  Note that this assumes that the
same string literal occurring twice in a given function in fact represents
a single entity, i.e. has a unique address.

In the first production, the discriminator will be present only for the
second and later occurrences of the same name within a single function.
In this case <number> is n - 2, if this is the nth occurrence, in lexical
order, of the given name.  It is expected that this will be the 'natural'
order in most compilers.

In any case, trouble would arise only if different compilation units
including the same code were compiled by different compilers, and 
multiple entities requiring mangling had the same name.


More information about the cxx-abi-dev mailing list