Skip to content

Fix miscompile when emitting protocol conformance of a runtime-only class #15860

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

Merged
merged 3 commits into from
Apr 11, 2018

Conversation

slavapestov
Copy link
Contributor

Fixes rdar://problem/39117602.

@slavapestov slavapestov requested a review from jckarter April 10, 2018 23:45
@slavapestov slavapestov force-pushed the fix-foreign-class-bug branch from ec60a3e to a0a4248 Compare April 10, 2018 23:52
Copy link
Contributor

@jckarter jckarter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

ClassDecl::isForeign() is true for both CF types and runtime-only classes.
In some places, we do not expect to see the latter.
We were emitting foreign type metadata for this case, because of an
invalid usage of ClassDecl::isForeign(), which also returns true
for runtime-only classes.

Fixes <rdar://problem/39117602>.
@slavapestov slavapestov force-pushed the fix-foreign-class-bug branch from a0a4248 to 94409b8 Compare April 11, 2018 01:05
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

ClangImporter/explicit-system-framework-path failure is not me.

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test macOS

@slavapestov
Copy link
Contributor Author

... or maybe it is me! Let’s find out.

@slavapestov slavapestov merged commit fe965a7 into swiftlang:master Apr 11, 2018
@@ -111,7 +111,7 @@ MetadataLayout &IRGenModule::getMetadataLayout(NominalTypeDecl *decl) {
auto &entry = MetadataLayouts[decl];
if (!entry) {
if (auto theClass = dyn_cast<ClassDecl>(decl)) {
if (theClass->isForeign())
if (theClass->getForeignClassKind() == ClassDecl::ForeignKind::CFType)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes, thank you. Perhaps we should do a renaming pass here, because it seems like IRGen is using "foreign class" in places that really mean "CF type". That's how foreign classes started, but with the introduction the Clang's objc_runtime_visible, the meaning of "foreign" in the AST was generalized.

Copy link
Contributor

@jckarter jckarter Apr 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know that the concept of ForeignKind really holds its weight at all; the capabilities of CF and runtime-only classes overlap somewhat but both diverge in different ways; the Venn diagram doesn't perfectly nest or overlap. IMO We should probably just split the "is CF" and "is objc_runtime_visible" predicates.

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.

3 participants