Description
Description
With the introduction of SE-0443 "Precise Control Flags over Compiler Warnings", compiler warnings can be placed into groups. The groups provide more control over whether those warnings are escalated to errors (via flags -Werror <groupe>
and -Wwarning <group>
), as well as providing documentation about the warnings that are within that group.
Today, only a handful of Swift's warnings are associated with a diagnostic group. We'd like to expand coverage to more warnings to make this feature more useful to Swift developers, giving them more control over which warnings are important to them as well as providing valuable documentation on what these warnings mean. We can use subtasks within this issue to keep track of the warnings that we want to move over to diagnostic groups.
If you want to help, there are three steps to take to move a set of warnings into a group. Each step is valuable in its own right, and once the third step has been completed, the new diagnostic group will be available in the compiler for future releases.
- Identify a set of related warnings in the compiler that should go into a group. To find them, look for
WARNING
uses throughout theDiagnostics*.def
files in the compiler, e.g.,DiagnosticsSema.def
, and identify the warnings that should go into a group. For example, this set of three warnings:could go into a diagnostic group about dynamic casting warnings. When you've identified the warnings, create a subtask of this issue that captures the intent for the new diagnostic group and mention the diagnostic identifiers involved (e.g.,WARNING(isa_is_always_true,none, "'%0' test is always true", (StringRef)) WARNING(isa_is_foreign_check,none, "'is' test is always true because %0 is a Core Foundation type", (Type)) WARNING(checked_cast_not_supported,none, "runtime conversion from %0 to %1 is not supported; " "%select{'is' test|cast}2 always fails", (Type, Type, unsigned))
isa_is_always_true
). - Write a Markdown file describing what the warnings in this new diagnostic group mean. The existing diagnostic group documentation files are a good resource for how to implement these. When you've written this documentation, open a pull request against the Swift compiler repository that adds the new Markdown file and leave a comment here.
- Teach the compiler to associate the warnings gathered in step 1 with the documentation in step 2. This means adding the new diagnostic group to the
DiagnosticGroups.def
file and then replacing the correspondingWARNING
uses in theDiagnostics*.def
files withGROUPED_WARNING
uses that name the new diagnostic group. Open a pull request against the Swift compiler repository and we're done!
Note that steps 1 and 2 do not require you to build the Swift compiler. Swift compiler developers will be happy to help along the way, including doing the integration work in step 3.
Additional information
No response