Skip to content

[Module aliasing] Serialize SIL and binaries with module real names #39705

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 8 commits into from
Oct 19, 2021

Conversation

elsh
Copy link
Contributor

@elsh elsh commented Oct 12, 2021

Use module real names for containing modules and imported modules when serializing.
Resolves rdar://83632529

Rename test
@elsh
Copy link
Contributor Author

elsh commented Oct 12, 2021

@swift-ci smoke test

Copy link
Contributor

@beccadax beccadax left a comment

Choose a reason for hiding this comment

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

This looks good functionally, but I'd like to see more testing.

(Many of the comments I put in one particular test file are also applicable to some of the others—in particular, the request for negative tests and module interface tests. Please use your best judgment here. 🙂)

/// substituting another name instead.
virtual StringRef getExportedModuleName() const {
return getParentModule()->getName().str();
return getParentModule()->getRealName().str();
Copy link
Contributor

Choose a reason for hiding this comment

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

tl;dr: Looks good.

I checked the use sites of getExportedModuleName() and there's one—TypePrinter::printModuleContext()—that looked iffy. It's part of ASTPrinter, which means it serves multiple masters. However, it looks like the exported module name is only used there when we're generating a swiftinterface file, where we really would want the real name, so I think this is okay.

@elsh elsh force-pushed the es-module-alias-serialize branch from ac0eb8e to e1dfdba Compare October 14, 2021 23:18
@elsh elsh requested a review from jckarter October 14, 2021 23:21
@elsh elsh force-pushed the es-module-alias-serialize branch from ef54b76 to 7a3a032 Compare October 15, 2021 10:57
@elsh
Copy link
Contributor Author

elsh commented Oct 15, 2021

@swift-ci smoke test

@elsh
Copy link
Contributor Author

elsh commented Oct 19, 2021

@swift-ci smoke test

Identifier Name = Mod->getName();
// Should use the module real (binary) name here and everywhere else the
// module is printed in case module aliasing is used (see -module-alias)
Identifier Name = Mod->getRealName();
Copy link
Contributor

Choose a reason for hiding this comment

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

Huh. These ASTPrinter cases are interesting, because I think some clients (like .swiftinterface printing) will want the real name and some (diagnostics, possibly some SourceKit clients) will want the alias name.

It might make sense to base this decision on the PrintOptions—either by putting a bool flag there, or by actually putting a map of aliases there.

(It’s probably okay to merge this as-is for now and come back to it later.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good; will create a separate PR to address that.

@elsh elsh merged commit 6f34844 into main Oct 19, 2021
@elsh elsh deleted the es-module-alias-serialize branch October 19, 2021 04:55
@elsh elsh changed the title [Module aliasing] Serialize binary with module real name [Module aliasing] Serialize SIL and binaries with module real names Oct 19, 2021
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