On Thu, 2024-11-21 at 17:36 -0500, David Malcolm wrote: > This is v2 of the patch; v1 was here: > https://gcc.gnu.org/pipermail/gcc-patches/2024-June/655541.html > > Changed in v2: > * added a new TARGET_DOCUMENTATION_NAME hook for figuring out which > documentation URL to use when there are multiple per-target docs, > such as for __attribute__((interrupt)); implemented this for all > targets that have target-specific attributes > * moved attribute_urlifier and its support code to a new > gcc-attribute-urlifier.cc since it needs to use targetm for the > above; gcc-urlifier.o is used by the driver. > * fixed extend.texi so that some attributes that failed to appear in > attr-urls.def now do so (affected nvptx "kernel" and "shared" > attrs) > * regenerated attr-urls.def for the above fix, and bringing in > attributes added since v1 of the patch > > In r14-5118-gc5db4d8ba5f3de I added a mechanism to automatically add > documentation URLs to quoted strings in diagnostics. > In r14-6920-g9e49746da303b8 I added a mechanism to generate URLs for > mentions of command-line options in quoted strings in diagnostics. > > This patch does a similar thing for attributes. It adds a new Python > 3 > script to scrape the generated HTML looking for documentation of > attributes, and uses this to (re)generate a new gcc/attr-urls.def > file. > > Running "make regenerate-attr-urls" after rebuilding the HTML docs > will > regenerate gcc/attr-urls.def in the source directory. > > The patch uses this to optionally add doc URLs for attributes in any > diagnostic emitted during the lifetime of a auto_urlify_attributes > instance, and adds such instances everywhere that a diagnostic refers > to a diagnostic within quotes (based on grepping the source tree > for references to attributes in strings and in code). > > For example, given: > > $ ./xgcc -B. -S ../../src/gcc/testsuite/gcc.dg/attr-access-2.c > ../../src/gcc/testsuite/gcc.dg/attr-access-2.c:14:16: warning: > attribute ‘access(read_write, 2, 3)’ positional argument 2 conflicts > with previous designation by argument 1 [-Wattributes] > > with this patch the quoted text `access(read_write, 2, 3)' > automatically gains the URL for our docs for "access": > https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-access-function-attribute > in a sufficiently modern terminal. > > Like r14-6920-g9e49746da303b8 this avoids the Makefile target > depending on the generated HTML, since a missing URL is a minor > problem, whereas requiring all users to build HTML docs seems more > involved. Doing so also avoids Python 3 as a build requirement for > everyone, but instead just for developers addding attributes. > Like the options, we could add a CI test for this. > > The patch gathers both general and target-specific attributes. > For example, the function attribute "interrupt" has 19 URLs within > our > docs: one common, and 18 target-specific ones. > The patch adds a new target hook used when selecting the most > appropriate one. > > Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. > > OK for trunk?
I did a successful "all-configs" build of this, so with my "diagnostic messages" maintainer hat on I self-approved it, and pushed this to trunk as r15-5988-g5a022062d22e0b. Dave