Skip to content

Completely refactor class constructor initialization for ownership #7714

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

Conversation

gottesmm
Copy link
Contributor

This PR is a product of my blood sweet and tears... but it has been completed. It is the beginning of a chain commits I am hoping to drop late rtoday.

It does the following:

  1. It ensures that when we emit an lvalue access for ref_element_addr in an lvalue we use a formal access scope.
  2. The previous way that we emitted class constructor initializers was broken in several ways:
    a. It did not use cleanups and if you used cleanups that were expecting to occur in the top level context, the code just asserted.
    b. It did not use ownership at all.
    c. The designated initializer sequence code was a huge hack that did not use ownership and ad-hoced borrowed things. I replaced this with an open coded solution that is at least principled with usage of cleanups, etc.

rdar://29791263

… a formal access borrow instead of a full borrow to make sure that the borrow ends at the end of the lvalue formal evaluation.

rdar://29791263
…make calling designated/chaining initializes use proper ownership.

rdar://29791263
…itSelfUses into its own function.

The new function is called collectDelegatingClassInitSelfLoadUses. This is just
a classical loop function extraction refactor.
As a bonus, now DI properly errors on:

super.init(self)
@gottesmm
Copy link
Contributor Author

Oh and I updated DI as well and fixed some DI bugs. DI before this wasn't triggering on:

super.init(self)

I found this by noticing that I started to cause this case to trigger in an unrelated SILOptimizer file. I moved the test case to definite init diagnostics and now we check for this error. So it shouldn't break again.

@gottesmm
Copy link
Contributor Author

@swift-ci Please smoke test and merge

@jrose-apple jrose-apple requested a review from jckarter February 23, 2017 17:07
@swift-ci swift-ci merged commit dfd3b74 into swiftlang:master Feb 23, 2017
@gottesmm gottesmm deleted the completely_refactor_class_constructor_initialization branch February 23, 2017 17:34
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 this pull request may close these issues.

2 participants