[cfe-dev] Mangling & linkage of unnamed but instantiated nested classes

John McCall rjmccall at apple.com
Wed Oct 31 13:53:48 PDT 2012


On Oct 31, 2012, at 12:37 PM, David Blaikie wrote:
> GCC 4.7 mangles them as:
> 
> _Z1fIN1SUt_EEiT_
> _Z1fIN1SUt0_EEiT_
> _Z1fIN1TUt_EEiT_
> _Z1fIN1TUt0_EEiT_
> 
> I don't think we have any class-specific unnamed nested type counter
> that would implement that Ut_, Ut0_, ... mangling scheme, though I can
> imagine where one might be added (I'm not very familiar with IRGen
> though, so I'll certainly be happy to have any pointers about how that
> could/should be implemented).

Probably we would want to record and remember this in the AST.

This schema is indeed the one blessed by the ABI.
   <unnamed-type-name> ::= Ut [ <nonnegative number> ] _
But as the ABI also notes:
  The mangling of such unnamed types defined in namespace scope is generally unspecified because they do not have to match across translation units. An implementation must only ensure that naming collisions are avoided.

The interesting question is what linkage GCC actually gives these symbols.

John.



More information about the cfe-dev mailing list