Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

describe inherited constructor mangling #48

Closed
zygoloid opened this issue Feb 14, 2018 · 1 comment · Fixed by #93
Closed

describe inherited constructor mangling #48

zygoloid opened this issue Feb 14, 2018 · 1 comment · Fixed by #93

Comments

@zygoloid
Copy link
Contributor

[Imported from cxx-abi-dev]

Per http://wg21.link/p0136r1 an inheriting constructor declaration no longer results in the implicit synthesis of derived class constructors, and instead the behavior of a call to an inherited constructor is that:

  1. the portion of a hypothetical defaulted default constructor prior to the base constructor invocation is executed, then
  2. the inherited constructor is invoked, then
  3. the portion of a hypothetical defaulted default constructor after the base constructor invocation is executed

Proposal:

To avoid emitting the code for (1) and (3) in every inherited constructor call site, add a new form of mangled name for a fake constructor that forwards to a base class constructor, whose <encoding> is that of the base class constructor, except that the <nested-name> is that of the derived class and the <unqualified-name> is

<ctor-dtor-name> ::= CI1 <base class type> # complete object inheriting constructor
<ctor-dtor-name> ::= CI2 <base class type> # base object inheriting constructor

This would give code largely similar to what we generate with the C++11 inheriting constructor rules, except that the additional copy constructions and destructions for parameters would be removed.

The usage of this mangling would be entirely optional; the purpose of including this mangling in the ABI is only to coalesce multiple weak definitions of the same symbol. If an implementation can't forward all the arguments (eg for varargs constructors) or just doesn't want to emit these symbols, the full initialization can be inlined instead (or another technique can be used).

As usual, CI2 constructors do not construct virtual base class subobjects. As a consequence, when a constructor is inherited from a virtual base, the corresponding CI2 symbol does not need the formal parameters, so they are not passed.

@rjmccall
Copy link
Collaborator

This makes sense to me. Can you open a PR for it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants