Skip to content

[Diagnostics] Add -print-diagnostic-groups flag #76363

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
Sep 11, 2024

Conversation

DmT021
Copy link
Contributor

@DmT021 DmT021 commented Sep 10, 2024

This change adds the -print-diagnostic-groups flag as described by SE-0443.

@DmT021
Copy link
Contributor Author

DmT021 commented Sep 10, 2024

@DougGregor please take a look

I've also added the flag to many relevant tests. This way we test that the messages we're getting are expected and belong to the expected group. IMO it's nice to have some extra coverage so we can be sure we don't change the group of a warning accidentally. But let me know if you think otherwise.

Also, there's a use of DiagnosticOptions and DiagnosticEngine in LLDB so I've opened a PR there as well swiftlang/llvm-project#9240

@DmT021 DmT021 force-pushed the wp/print-diagnostic-groups branch from c36dfce to 23c57d3 Compare September 10, 2024 18:22
@@ -1518,7 +1512,7 @@ DiagnosticEngine::diagnosticInfoForDiagnostic(const Diagnostic &diagnostic) {

return DiagnosticInfo(
diagnostic.getID(), loc, toDiagnosticKind(behavior),
diagnosticStringFor(diagnostic.getID(), getPrintDiagnosticNames()),
diagnosticStringFor(diagnostic.getID(), getPrintDiagnosticNamesMode()),
diagnostic.getArgs(), Category, getDefaultDiagnosticLoc(),
Copy link
Member

Choose a reason for hiding this comment

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

It looks like Category here has a few hardcoded values. Should we provide the warning group name for Category when there is one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we probably could do it. But I'm sure we should. These categories are inferred from DiagnosticOptions.
The deprecation category seems to be interesting to look at. Maybe we should consider removing the DiagnosticOptions::Deprecation option and instead infer this category from checking if a diagnostic belongs to the deprecated group. So we don't have two ways to express the same thing.
And I don't know if we need the api-digester-breaking-change and no-usage categories expressed as groups.

Copy link
Member

Choose a reason for hiding this comment

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

I took a look at the diagnostics that get each of these flags: the "deprecation" category does seem to line up fairly well with the "deprecated" group, the "no-usage" category could be useful as a general diagnostic group for "you did something and didn't use the result" warnings, and "api-digester-breaking-change" is a very specific group of separate diagnostics (mostly errors).

@DougGregor
Copy link
Member

Only a small comment and a question, this looks good!

@DougGregor
Copy link
Member

@swift-ci please smoke test

@DmT021
Copy link
Contributor Author

DmT021 commented Sep 11, 2024

@DougGregor Since there are changes in the public members of DiagnosticOptions and DiagnosticEngine LLDB won't build without this patch swiftlang/llvm-project#9240

I don't know how to deal with it, both of these PRs depend on each other and should be tested and merged together.

Can you rerun the tests here with that PR?

@DmT021 DmT021 force-pushed the wp/print-diagnostic-groups branch from 23c57d3 to 36a7417 Compare September 11, 2024 01:38
@DougGregor
Copy link
Member

swiftlang/llvm-project#9240

@swift-ci please smoke test

@DougGregor
Copy link
Member

I don't know how to deal with it, both of these PRs depend on each other and should be tested and merged together.

Can you rerun the tests here with that PR?

Yes, of course. I've kicked off the multi-PR test, sorry I missed that earlier.

This change adds the `-print-diagnostic-groups` flag as described by SE-0443.
@DmT021 DmT021 force-pushed the wp/print-diagnostic-groups branch from 36a7417 to a8b71ea Compare September 11, 2024 11:34
@DmT021
Copy link
Contributor Author

DmT021 commented Sep 11, 2024

@DougGregor
Copy link
Member

swiftlang/llvm-project#9240

@swift-ci please smoke test

@DougGregor DougGregor merged commit b272a05 into swiftlang:main Sep 11, 2024
3 checks passed
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