Skip to content

[PrintAsObjC] Pull the actual decl/type printer out to a separate file #27163

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 6 commits into from
Sep 13, 2019

Conversation

jrose-apple
Copy link
Contributor

I've tried several times to separate the type printing from the decl-printing and found it tricky, but at least both can be separated from the logic of walking the top-level decls in a module and scheduling them appropriately. No functionality change.

I've tried several times to separate the type printing from the
decl-printing and found it tricky, but at least both can be separated
from the logic of walking the top-level decls in a module and
scheduling them appropriately. No functionality change.
The state for @optional vs. @required was only ever referenced from
one function, so we can just put it there.
@jrose-apple
Copy link
Contributor Author

@swift-ci Please smoke test

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test source compatibility

All persistent info should live in the parent DeclAndTypePrinter, not
in the Implementation helper class. We can move the rarely-used
members out too even if they're not lazily-populated.
@jrose-apple
Copy link
Contributor Author

@swift-ci Please smoke test

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test source compatibility

It can get it from the owning DeclAndTypePrinter, and most of the time
it's only using it to get the ASTContext anyway. No functionality
change.
@jrose-apple
Copy link
Contributor Author

@swift-ci Please 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.

Github didn't make it easy to understand what happened to DeclAndTypePrinter.cpp, so I built a gist to show the differences: https://gist.github.com/brentdax/ec2d1070c867de20274f02f32402778a/revisions?diff=unified

I still didn't give that diff a really detailed read, but skimming it LGTM; I just have one small request.


using NameAndOptional = std::pair<StringRef, bool>;
llvm::DenseMap<std::pair<Identifier, Identifier>, NameAndOptional>
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a doc comment explaining how to interpret this member variable? The type and name are far from self-explanatory.

@jrose-apple
Copy link
Contributor Author

I was expecting reviewers to skip the first PR since it's "just" moving things, or maybe only looking at what changed on the PrintAsObjC and DeclAndTypePrinter header sides. But yeah, comment is fair.

And comment the other cached members a little better.
@jrose-apple
Copy link
Contributor Author

@swift-ci Please 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 is about a thousand times better!

@jrose-apple jrose-apple merged commit 258f372 into swiftlang:master Sep 13, 2019
@jrose-apple jrose-apple deleted the laserwriter branch September 13, 2019 23:17
beccadax added a commit to beccadax/swift that referenced this pull request Sep 14, 2019
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