You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Serialized diagnostics] Encode category documentation URL in existing record
Serialized diagnostics support an optional category name, which can be
used to group diagnostics together. This grouping is most helpful when
a number of diagnostics are placed in a category that is documented
together. For example, Clang's warnings are placed into groups that are
each documented. However, any relationship between the category name and
such documentation is left to the client to establish.
This change introduces a convention and APIs to allow diagnostic
categories to be associated with a URL at which one can find
documentation for the diagnostics in that category. Rather than
outright extend the serialized diagnostics format with a new record
kind, we utilize some redundancy to extend the existing RECORD_CATEGORY
in a backward-compatible way. Specifically, for diagnostic categories
that have documentation URLs associated with them, the blob associated
with a RECORD_CATEGORY entry will be
<category name>@<category URL>
The RECORD_CATEGORY already includes a "category name length" field,
which specifies the length of the category name. A correct reader
would already be ignoring anything beyond that that position in the
blob, so we get this extensibility for free: all of the extra
information goes into the blob, but the category name length field
still describes the length of the category name (i.e., the position of
the @). A correct reader (that hasn't been updated for this change)
will treat diagnostics files that provide these documentation URLs in
the same way as ones that don't, ignoring the URL.
Amusingly, the two readers I looked at (the one in Clang and a Swift
one we use for other tools) ignore the category name length field.
They still fail fairly gracefully: the category name ends up being the
whole blob, which is still human-readable and fairly reasonable.
This change teaches Clang's serialized diagnostic reader to properly
respect the category name length field and, when the blob matches the
description above, separately track the category documentation URL. It
adds a new libclang diagnostics API `clang_getDiagnosticCategoryURL()`
that provides this URL separately from the category.
c-index-test prints the category name -> URL mapping separate from the
diagnostic so we can test this functionality.
This commit does not teach Clang to encode documentation URLs in the
diagnostics it generates. That will come separately.
0 commit comments