Skip to content

[ASTMangler] Fix USR generation/mangling crash in invalid code #27108

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

nathawes
Copy link
Contributor

@nathawes nathawes commented Sep 10, 2019

In invalid code it seems decls can end up with an opened archetype type that the mangler doesn't like (hitting this unreachable). We still want to be able to generate a USR for these decls so that we can index and rename their occurrences successfully. To allow this, this patch calls mapTypeOutOfContext on types that have primary or opened archetype types prior to mangling.

This is like the issue @rintaro fixed for sourcekitd's ConformingMethodList request in #25130, but for indexing.

Resolves rdar://problem/54310026

@nathawes
Copy link
Contributor Author

@swift-ci please test

@nathawes nathawes force-pushed the r54310026-usr-generation-crash-in-invalid-code branch from f41aca8 to d201fd1 Compare September 11, 2019 00:28
@nathawes
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - f41aca8623695a13a4458fc1c68c0bd9b4c4b6fb

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - f41aca8623695a13a4458fc1c68c0bd9b4c4b6fb

if (auto gft = dyn_cast<GenericFunctionType>(type)) {
Type type = decl->getInterfaceType()
->getReferenceStorageReferent();
if (type->hasArchetype())
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you file a radar and assign it to me to fix the underlying problem here? I believe the only decls that are affected by this are ParamDecls (in fact, can you add an assert that if hasArchetype() is true, the decl is a ParamDecl?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks Slava! I filed rdar://problem/55268049 and updated this PR with the assertion.

In invalid code a decl may end up with an opened archetype type that the
mangler doesn't expect. We still want to be able to generate a USR for these
decls so that we can index and rename their occurences successfully. To allow
this, this patch calls mapTypeOutOfContext on primary or opened archetype types
prior to mangling.

Resolves rdar://problem/54310026
@nathawes nathawes force-pushed the r54310026-usr-generation-crash-in-invalid-code branch from d201fd1 to d48b620 Compare September 11, 2019 17:59
@nathawes
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - d201fd1cc5386cfef6fc0e6c81bba6db209cdc0a

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - d201fd1cc5386cfef6fc0e6c81bba6db209cdc0a

@nathawes nathawes merged commit 2163698 into swiftlang:master Sep 11, 2019
@nathawes nathawes deleted the r54310026-usr-generation-crash-in-invalid-code branch September 11, 2019 20:59
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