[cxx-abi-dev] Name mangling for explicit overriders

Mark Mitchell mark at codesourcery.com
Sun Jul 27 18:24:47 UTC 2003


On Sun, 2003-07-27 at 05:21, J. Stephen Adamczyk wrote:
> We recently implemented the Microsoft extension that allows explicit
> specification of overriding on derived class virtual functions.
> For example:
> 
> 	struct B1 {
> 	  virtual void f() = 0;
> 	};
> 	struct B2 {
> 	  virtual void f() = 0;
> 	};
> 	struct D: B1, B2 {
> 	  virtual void B1::f() {}  // Overrides B1::f (only)
> 	  virtual void B2::f() {}  // Overrides B2::f (only)
> 	};
> 
> (Hey, we didn't invent it; we're just implementing it for Microsoft
> compatibility. :-) )
> 
> This has a name mangling implication: as shown in the above example,
> you can end up with two member functions in a given class that have
> the same name and signature, and differ only in the function that
> they override.
> 
> Here's the extension we made to name mangling, so that others who
> have to do this feature might do it the same way, or so that anyone
> who sees a problem with what we did can warn us now before we ship
> it.
> 
> We added a rule for <encoding>:
> 
>   <encoding> ::= <function name> O <nested-name> <bare-function-type>

I've suggested before that we should have a portion of the mangling
namespace (i.e., the names that begin with "_Z") reserved for vendor
extensions.  

I'm not 100% sure that the following scheme will not conflict with
anything else, but it will serve as an illustration:

  _Z v <length number> <vendor identifier> ...

The idea is that all EDG-specific manglings would begin with:

  _Zv3EDG

The characters that follow that point would be entirely up to you.

That would keep the manglings that you add from getting in the way of
any future extensions of the base standard.  In other words, if some new
feature C++ 2017 caused us to add a mangling, we wouldn't have to
remember that EDG is already using this bit with the "O" in the middle
of it for this Microsoft thing.

What do you think of this idea?  What do other people think?

-- 
Mark Mitchell
CodeSourcery, LLC
mark at codesourcery.com




More information about the cxx-abi-dev mailing list