[PATCH/RFC,0/4] C/C++/diagnostics: various UX improvements

Message ID 20231102131933.2161191-1-dmalcolm@redhat.com
Headers
Series C/C++/diagnostics: various UX improvements |

Message

David Malcolm Nov. 2, 2023, 1:19 p.m. UTC
  The following patch kit implements the:
  #pragma GCC show_layout (struct foo)
idea I mentioned in my Cauldron talk (in patch 2),  and the other
patches implement various related user experience changes I came
across when implementing it.

Patch 1 reworks how c-pragma.cc parses pragmas, and experiments with
adding links to documentation to the diagnostics messages (on a
suitably capable terminal).

Patch 2 implements the new "show_layout" pragma

Patch 3 adds a new mechanism to the diagnostics subsytem for
automatically adding documentation links to messages, with enough
data to handle the pragmas from patch 1.

Patch 4 attempts to automatically populate the URL data for our docs by
parsing the results of "make html".

Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.

I'd like to go ahead with patch 1 and patch 3; patch 2 and patch 4 may
need more work, but posting here for feedback.

Thoughts?

David Malcolm (4):
  c/c++: rework pragma parsing
  c: add #pragma GCC show_layout
  diagnostics: add automatic URL-ification within messages
  RFC: add contrib/regenerate-index-urls.py

 contrib/regenerate-index-urls.py              |  245 ++
 gcc/Makefile.in                               |    3 +-
 gcc/analyzer/record-layout.cc                 |  235 ++
 gcc/analyzer/record-layout.h                  |    4 +
 gcc/c-family/c-pragma.cc                      |  641 ++++-
 gcc/c-family/c-pragma.h                       |    5 +-
 gcc/diagnostic.cc                             |    8 +-
 gcc/diagnostic.h                              |    4 +
 gcc/doc/extend.texi                           |   49 +
 gcc/gcc-urlifier.cc                           |  159 ++
 gcc/gcc-urlifier.def                          | 2532 +++++++++++++++++
 gcc/gcc-urlifier.h                            |   26 +
 gcc/gcc.cc                                    |    2 +
 gcc/pretty-print-urlifier.h                   |   33 +
 gcc/pretty-print.cc                           |  242 +-
 gcc/pretty-print.h                            |    5 +-
 gcc/selftest-run-tests.cc                     |    1 +
 gcc/selftest.h                                |    1 +
 gcc/stor-layout.h                             |    3 +
 .../c-c++-common/pragma-message-parsing.c     |   21 +
 .../c-c++-common/pragma-optimize-parsing.c    |   16 +
 .../c-c++-common/pragma-pack-parsing-1.c      |   19 +
 .../c-c++-common/pragma-pack-parsing-2.c      |    4 +
 .../pragma-redefine_extname-parsing.c         |    9 +
 .../c-c++-common/pragma-target-parsing.c      |   14 +
 .../c-c++-common/pragma-visibility-parsing.c  |   13 +
 .../c-c++-common/pragma-weak-parsing.c        |   24 +
 gcc/testsuite/gcc.dg/bad-pragma-locations.c   |   22 +-
 .../gcc.dg/parsing-pragma-show_layout.c       |   15 +
 .../pragma-scalar_storate_order-parsing.c     |    8 +
 gcc/testsuite/gcc.dg/pragma-show_layout-1.c   |   12 +
 gcc/testsuite/gcc.dg/pragma-show_layout-2.c   |  184 ++
 ...agma-show_layout-infoleak-CVE-2017-18550.c |  175 ++
 gcc/testsuite/gcc.dg/sso-6.c                  |    2 +-
 gcc/toplev.cc                                 |    2 +
 35 files changed, 4589 insertions(+), 149 deletions(-)
 create mode 100755 contrib/regenerate-index-urls.py
 create mode 100644 gcc/gcc-urlifier.cc
 create mode 100644 gcc/gcc-urlifier.def
 create mode 100644 gcc/gcc-urlifier.h
 create mode 100644 gcc/pretty-print-urlifier.h
 create mode 100644 gcc/testsuite/c-c++-common/pragma-message-parsing.c
 create mode 100644 gcc/testsuite/c-c++-common/pragma-optimize-parsing.c
 create mode 100644 gcc/testsuite/c-c++-common/pragma-pack-parsing-1.c
 create mode 100644 gcc/testsuite/c-c++-common/pragma-pack-parsing-2.c
 create mode 100644 gcc/testsuite/c-c++-common/pragma-redefine_extname-parsing.c
 create mode 100644 gcc/testsuite/c-c++-common/pragma-target-parsing.c
 create mode 100644 gcc/testsuite/c-c++-common/pragma-visibility-parsing.c
 create mode 100644 gcc/testsuite/c-c++-common/pragma-weak-parsing.c
 create mode 100644 gcc/testsuite/gcc.dg/parsing-pragma-show_layout.c
 create mode 100644 gcc/testsuite/gcc.dg/pragma-scalar_storate_order-parsing.c
 create mode 100644 gcc/testsuite/gcc.dg/pragma-show_layout-1.c
 create mode 100644 gcc/testsuite/gcc.dg/pragma-show_layout-2.c
 create mode 100644 gcc/testsuite/gcc.dg/pragma-show_layout-infoleak-CVE-2017-18550.c