Skip to content

[Diags] Add support for remarks in diagnostic groups#88516

Draft
hnrklssn wants to merge 9 commits into
swiftlang:mainfrom
hnrklssn:remark-groups
Draft

[Diags] Add support for remarks in diagnostic groups#88516
hnrklssn wants to merge 9 commits into
swiftlang:mainfrom
hnrklssn:remark-groups

Conversation

@hnrklssn
Copy link
Copy Markdown
Member

This adds:

  • infrastructure needed for automatically enabling remarks based on their diagnostic group (-R FooBar)
  • diagnostic groups for all existing remarks
  • basic documentation for each group
    • feel free to suggest additions to this documentation - I don't have experience with all of them
    • these markdown files are toolchain-local for now, partially because they are not very polished, and partially because I'm just not certain how automatic the process publishing these to docs.swift.org is (we should probably comment this somewhere)
  • regression test to make sure any new diagnostic has at least some basic toolchain-local docs
  • -Rhelp to list groups containing remarks, along with links to their docs

Existing remark options are turned into aliases of the new -R <group> for compatibility. The exception is -Raccess-note=<level> which is not supported by the new option for two reasons:

  • it requires an argument
  • it is enabled by default

This resolves #87756

Leaving this as draft for now since I'm not sure whether this will go into 6.4.

@hnrklssn
Copy link
Copy Markdown
Member Author

@swift-ci please test

This adds a flag to swift-ide-test emitting a list of all diagnostic
groups, and a test checking that there is a corresponding markdown file
for each group. The flag is in swift-ide-test rather than swift-frontend
since it's only intended to be used for testing.

Also adds some initial documentation for RegionIsolation and
WeakMutability which was previously missing.
This creates groups for all current remarks and adds them to their
corresponding groups. These groups currently don't do anything other
than displaying documentation alongside the remark.
Add a FrontendOnly option to DiagnosticGroupOptions for groups that
should not be accessible from the Swift driver. This will be used to
match their current behavior.

Remove the unused remark_scanner_uncached_lookups diagnostic.

Also adds some basic documentation for each new diagnostic group.
This creates `resolveDiagnosticDocumentationPath`,
`resolveLocalDiagnosticDocumentationPath` as static functions in
`DiagnosticEngine`. `declaredDiagnosticKindFor` is converted to a static
function. `getDocumentationURL` is added to `DiagGroupInfo`.
These functions will be used before `configureDiagnosticEngine` is
called as part of the `-Rhelp` implementation in the next commit.

`::DiagnosticOptions` is also renamed to `::DiagnosticProperties` to
avoid clashing with `swift::DiagnosticOptions`.
-Rhelp checks all diagnostic groups for the presence of remarks, and
lists them together with URLs to their documentation.
Instead of manually adding new `-Rfoo` options each time we add a new kind
of remark, this adds a generic `-R Foo` option to enable any remark
diagnostics group. Existing `-Rfoo` options are made into aliases of
this new option. For compatibility, parsing of the new option sets the
same boolean flags as the corresponding old options did. Over time it is
expected that this will be handled by querying the DiagnosticsEngine
whether a certain remark is enabled or not, or even just emitting the
remark and letting the engine silence it.

Like with `-Rhelp`, to prevent matching frontend-only remark groups when
`-R` is passed to the driver, `-R` is actually split up into `-R` and
`-Rswiftc`. `-R` is available in both the driver and the compiler,
whereas `-Rswiftc` is only available in the compiler. When `-R` is
passed to the driver, it forwards `-Rswiftc` to the compiler to prevent
matching frontend-only groups.
@hnrklssn
Copy link
Copy Markdown
Member Author

@swift-ci please test

hnrklssn added a commit to hnrklssn/swift-driver that referenced this pull request Apr 18, 2026
When passed to the driver, these options are remapped to -Rhelp-swiftc
and -Rswiftc, respectively, before invoking the compiler. This lets the
compiler gate remark availability on whether the options were passed to
the driver or to the compiler directly. the -R*-swiftc versions are not
to be used directly.

Paired with swiftlang/swift#88516
@hnrklssn
Copy link
Copy Markdown
Member Author

swiftlang/swift-driver#2124
@swift-ci please test

@hnrklssn
Copy link
Copy Markdown
Member Author

swiftlang/swift-driver#2124
@swift-ci please smoke test

This file was accidentally leftover as duplicated content after
renaming to modularization-issue.md.
@hnrklssn
Copy link
Copy Markdown
Member Author

swiftlang/swift-driver#2124
@swift-ci please smoke test

1 similar comment
@hnrklssn
Copy link
Copy Markdown
Member Author

swiftlang/swift-driver#2124
@swift-ci please smoke test

@hnrklssn
Copy link
Copy Markdown
Member Author

CI Failure: Swift Test Windows Platform

Reason: Infrastructure error detected
Type: Timeout

Error: Exception calling "DownloadFile" with "2" argument(s): "The operation has timed out"

Automatically retriggering CI to verify if this is a transient infrastructure issue.

@hnrklssn
Copy link
Copy Markdown
Member Author

@swift-ci please test windows platform

"failed inside dependency scanner: '%0'", (StringRef))

REMARK(warn_scanner_deserialize_failed, none,
GROUPED_REMARK(warn_scanner_deserialize_failed, DependencyScanCache, none,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should it be possible to have an un-grouped remark with this change? i.e. should all remarks just be REMARK and require a group?

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.

Extend diagnostic groups to remarks

2 participants