Skip to content

[SymbolGraphGen] silence symbolgraph-extract output without -v flag #36785

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 2 commits into from
Apr 9, 2021

Conversation

QuietMisdreavus
Copy link
Contributor

Resolves rdar://72630103

This PR changes how SymbolGraphGen emits its output. By default, the SymbolGraphGen code will not output anything other than errors without a -v flag given to swift-symbolgraph-extract. This also means that the symbol-graph code called from the driver or from SourceKit will now also be silenced.

@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please smoke test

@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please build toolchain macOS platform


/// Whether to silence the "Found N symbols" messages when rendering
/// a symbol graph.
bool QuietMessages;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is "quiet" common terminology? Maybe SilenceMessage would fit better here (see https://github.com/apple/swift/blob/a5a79f23c0257c36c297d3c1b9275a873434468a/lib/Sema/TypeCheckType.h#L57)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When i started writing this, i assumed i would use a --quiet flag, which i've seen on other tools to reduce/eliminate the messages they display. Since the meaning was ultimately inverted (no output without -v flag), this might work better as PrintMessages instead. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

PrintMessages sounds good as well!

llvm::errs() << ModuleDecls.size()
<< " top-level declarations in this module.\n";
if (!Options.QuietMessages)
llvm::errs() << ModuleDecls.size()
Copy link
Contributor

Choose a reason for hiding this comment

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

Another way to implement this would be to create a stream that forwards its input to llvm:errs() only if QuietMessages is true. That way we don't have to guard the messages around if checks. I don't really mind either way though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unless there's some "optional stream wrapper" type that exists somewhere, this implementation feels like the "smallest diff" way to implement this. Otherwise, i'd have to implement the wrapper myself.

@@ -35,6 +35,10 @@ struct SymbolGraphOptions {
/// Emit members gotten through class inheritance or protocol default
/// implementations with compound, "SYNTHESIZED" USRs.
bool EmitSynthesizedMembers;

/// Whether to silence the "Found N symbols" messages when rendering
Copy link
Contributor

Choose a reason for hiding this comment

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

It's more than the "Found N symbols" messages though right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are three lines that are affected by this change:

Emitting symbol graph file for module: <filename>.swiftmodule
X top-level declarations in this file.
Found Y symbols and Z relationships.

emitSymbolGraphForModule only emits the latter two (the first is printed directly by swift-symbolgraph-extract), so centering the docs around the "Found N symbols" seemed like the most direct way to describe it. I could mention the "X top-level symbols" line as well if that seems better.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's true today but might not be in the future. I'm nitpicking though, this isn't blocking :)

@QuietMisdreavus
Copy link
Contributor Author

Pushed up a commit to invert the meaning of the field. I tweaked the doc comment while i was at it, too. 😉

@swift-ci Please smoke test

@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please build toolchain macOS platform

@swift-ci
Copy link
Contributor

swift-ci commented Apr 7, 2021

macOS Toolchain
Download Toolchain
Git Sha - ba2b92b

Install command
tar -zxf swift-PR-36785-934-osx.tar.gz --directory ~/

@QuietMisdreavus QuietMisdreavus merged commit 07dc2a9 into main Apr 9, 2021
@QuietMisdreavus QuietMisdreavus deleted the QuietMisdreavus/quiet-symbolgraph branch April 9, 2021 14:43
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