Skip to content

ASTPrinter: remove ASTPrinter's dependency on sema. NFC #10985

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 1 commit into from
Jul 15, 2017
Merged

ASTPrinter: remove ASTPrinter's dependency on sema. NFC #10985

merged 1 commit into from
Jul 15, 2017

Conversation

nkcsgexi
Copy link
Contributor

No description provided.

@nkcsgexi
Copy link
Contributor Author

@swift-ci please smoke test

1 similar comment
@nkcsgexi
Copy link
Contributor Author

@swift-ci please smoke test

@nkcsgexi
Copy link
Contributor Author

Merging. @jrose-apple Please let me know if this unblocks your patch.

@nkcsgexi nkcsgexi merged commit 0bba7d9 into swiftlang:master Jul 15, 2017
@nkcsgexi nkcsgexi deleted the sema-dep-ast-printer branch July 15, 2017 03:02
Copy link
Contributor

@jrose-apple jrose-apple left a comment

Choose a reason for hiding this comment

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

Thanks, Xi!

@@ -294,6 +275,9 @@ struct PrintOptions {
/// Whether to print the extensions from conforming protocols.
bool PrintExtensionFromConformingProtocols = false;

std::shared_ptr<ShouldPrintChecker> CurrentPrintabilityChecker =
Copy link
Contributor

Choose a reason for hiding this comment

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

Small note: it seems a little funny to make this a shared_ptr rather than just an optional non-owning pointer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Like Optional<ShouldPrintChecker*>? does it mean we don't release the original one when when resetting the pointer?

Copy link
Contributor

Choose a reason for hiding this comment

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

Just ShouldPrintChecker * is fine—if it's nullptr, you get the default behavior. Whenever someone wants to customize it, they can stack-allocate their checker and pass in the address.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Stack allocation is usually insufficient for setting the checker because we set in the factory method of PrintOptions.

Copy link
Contributor

Choose a reason for hiding this comment

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

:-/ All right. std::shared_ptr just seems very heavyweight to me, but I guess PrintOptions don't get copied around a lot and customizing this behavior doesn't happen very often anyway.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for talking through it with me!

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