public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 00/22] RFC: Overhaul of diagnostics
@ 2015-09-10 20:12 David Malcolm
  2015-09-10 20:12 ` [PATCH 01/22] Change of location_get_source_line signature David Malcolm
                   ` (22 more replies)
  0 siblings, 23 replies; 133+ messages in thread
From: David Malcolm @ 2015-09-10 20:12 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

This is a followup to the ideas posted at:
  https://gcc.gnu.org/ml/gcc-patches/2015-03/msg00837.html

I've been experimenting with capturing and printing richer
information for our diagnostics, underlining pertinent source ranges
when printing them, and potentially providing "fix-it" hints.

Attached is a work-in-progress patch kit implementing these ideas.
I posting it now to get feedback: some parts of it may be ready to
commit, but other parts are definitely *not* ready yet.

Some screenshots:
 https://dmalcolm.fedorapeople.org/gcc/2015-09-04/ranges-in-format-string-diagnostics.html
 https://dmalcolm.fedorapeople.org/gcc/2015-09-10/spellcheck-with-fixits.html
(other screenshots can be seen in the individual patches).

Overview of the patches:

Patches 1-3:
    01: Change of location_get_source_line signature
    02: Testsuite: add dg-{begin|end}-multiline-output commands
    03: Move diagnostic_show_locus and friends out into a new source file
These patches are a preamble, setting things up for what's to come.

Patches 4-5:
    04: Reimplement diagnostic_show_locus, introducing rich_location classes
    05: Add overloads of inform, warning_at, etc that take a source_range
These patches introduce a "rich_location" class capable of storing
multiple ranges, and use it internally throughout the diagnostic
implementation, together with the code for printing such information.

These patches and the ones leading up to it survive bootstrap and
regression testing; after this point things start to get more
"experimental".

Patch 6:
    06: PR/62314: add ability to add fixit-hints
This adds some machinery to allow diagnostics to supply "fix-it" hints
to the user.

Patches 7-11:
    07: Implement token range tracking within libcpp and C/C++ FEs
    08: C frontend: use token ranges in various diagnostics
    09: C frontend: store and use token ranges in c_declspecs
    10: C++ FE: Use token ranges for various diagnostics
    11: Objective C: c/c-parser.c: use token ranges in two places
These patches capture source range information for *tokens* in
libcpp, C and C++, and start using them in place of
mere locations for various diagnostics, so that we get underlines.

Patches 12-16:
    12: Add source-ranges for trees
    13: gcc-rich-location.[ch]: add methods for working with tree ranges
    14: C: capture tree ranges for various expressions
    15: Add plugin to recursively dump the source-ranges in a tree
These patches capture source range information
for *tree expressions*.  The representation I'm using has both
enlargements to core tree structures *and* will require lots of extra
tree nodes, so it's clearly going to be unacceptable as-is; my aim
here is to use this as a starting point for trying to optimize the
implementation (e.g. to gather stats on real-world code).

Patches 16:
    16: C/C++ frontend: use tree ranges in various diagnostics
This patches uses the tree expression source range information
gathered above in various diagnostics, so that we get more
underlines.  This is probably just scratching the surface in terms
of the diagnostics we could improve.

Patches 17-20:
    17: libcpp: add location tracking within string literals
    18: Track locations within string literals in tree_string
    19: gcc-rich-location.[ch]: add debug methods for cpp_string_location
    20: Use rich locations in c-family/c-format.c
These patches extend string-literal parsing to capture per-character
source range information within string literals, then use it within
c-format.c to robustly print string ranges for printf-style format
string errors (even in the face of e.g. concatenation).  This
hasn't been optimized yet; I don't yet know the impact on
compile-time and memory (but I have ideas for optimizing it if
it's an issue).

Patches 21-22:
    21: Use Levenshtein distance for various misspellings in C frontend
    22: Add fixit hints to spellchecker suggestions
These patches use Levenshtein distance to provide hints in
various places when the user misspells something,
and starts adding the ability to add "fix-it" hints to diagnostics.
Some of this could be split out and applied independently of the
rich_location work.

Thoughts?

(the patches are on top of r227562)

 boehm-gc/testsuite/lib/boehm-gc.exp                |    1 +
 gcc/Makefile.in                                    |    5 +-
 gcc/box-drawing.c                                  |   99 ++
 gcc/box-drawing.h                                  |   43 +
 gcc/c-family/c-common.c                            |   37 +-
 gcc/c-family/c-common.h                            |    8 +-
 gcc/c-family/c-format.c                            |  117 +-
 gcc/c-family/c-indentation.c                       |   10 +-
 gcc/c-family/c-lex.c                               |   32 +-
 gcc/c-family/c-pragma.h                            |    4 +-
 gcc/c-family/c-pretty-print.c                      |    4 +
 gcc/c/c-convert.c                                  |   17 +-
 gcc/c/c-decl.c                                     |   58 +-
 gcc/c/c-errors.c                                   |   95 +-
 gcc/c/c-objc-common.c                              |    2 +-
 gcc/c/c-parser.c                                   |  172 ++-
 gcc/c/c-tree.h                                     |   26 +-
 gcc/c/c-typeck.c                                   |  273 +++--
 gcc/cp/error.c                                     |    5 +-
 gcc/cp/parser.c                                    |   54 +-
 gcc/cp/parser.h                                    |    2 +
 gcc/cp/typeck.c                                    |    3 +-
 gcc/diagnostic-color.c                             |    5 +-
 gcc/diagnostic-core.h                              |   15 +
 gcc/diagnostic-show-locus.c                        | 1116 ++++++++++++++++++++
 gcc/diagnostic.c                                   |  412 +++++---
 gcc/diagnostic.h                                   |   48 +-
 gcc/fortran/cpp.c                                  |   13 +-
 gcc/fortran/error.c                                |   43 +-
 gcc/gcc-rich-location.c                            |  235 +++++
 gcc/gcc-rich-location.h                            |   84 ++
 gcc/genmatch.c                                     |   27 +-
 gcc/gimplify.c                                     |    4 +
 gcc/input.c                                        |   21 +-
 gcc/input.h                                        |    2 +-
 gcc/intl.c                                         |    9 +
 gcc/objc/objc-act.c                                |    3 +-
 gcc/pretty-print.c                                 |   21 +
 gcc/pretty-print.h                                 |   25 +-
 gcc/print-tree.c                                   |   21 +
 gcc/rtl-error.c                                    |    3 +-
 gcc/spellcheck.c                                   |  126 +++
 gcc/spellcheck.h                                   |   32 +
 gcc/testsuite/g++.dg/diagnostic/token-ranges.C     |  104 ++
 gcc/testsuite/gcc.dg/diagnostic-token-ranges.c     |  135 +++
 gcc/testsuite/gcc.dg/diagnostic-tree-expr-ranges.c |  159 +++
 gcc/testsuite/gcc.dg/format/diagnostic-ranges.c    |  101 ++
 .../gcc.dg/plugin/diagnostic-test-expressions-1.c  |  562 ++++++++++
 .../plugin/diagnostic-test-show-locus-ascii-bw.c   |  157 +++
 .../diagnostic-test-show-locus-ascii-color.c       |   78 ++
 .../plugin/diagnostic-test-show-locus-utf-8-bw.c   |  101 ++
 .../diagnostic-test-show-locus-utf-8-color.c       |  105 ++
 .../gcc.dg/plugin/diagnostic-test-show-trees-1.c   |  106 ++
 .../plugin/diagnostic-test-string-literals-1.c     |  139 +++
 .../gcc.dg/plugin/diagnostic_plugin_show_trees.c   |  179 ++++
 .../plugin/diagnostic_plugin_test_show_locus.c     |  396 +++++++
 .../diagnostic_plugin_test_string_literals.c       |  215 ++++
 .../diagnostic_plugin_test_tree_expression_range.c |  162 +++
 gcc/testsuite/gcc.dg/plugin/plugin.exp             |   11 +
 gcc/testsuite/gcc.dg/spellcheck.c                  |   40 +
 gcc/testsuite/lib/gcc-dg.exp                       |    1 +
 gcc/testsuite/lib/multiline.exp                    |  241 +++++
 gcc/testsuite/lib/prune.exp                        |    5 +
 gcc/tree-core.h                                    |    5 +
 gcc/tree-diagnostic.c                              |    2 +-
 gcc/tree-pretty-print.c                            |    2 +-
 gcc/tree.c                                         |   66 +-
 gcc/tree.def                                       |    2 +
 gcc/tree.h                                         |   33 +
 libatomic/testsuite/lib/libatomic.exp              |    1 +
 libcpp/charset.c                                   |  357 ++++++-
 libcpp/directives.c                                |    4 +-
 libcpp/errors.c                                    |    7 +-
 libcpp/expr.c                                      |    2 +
 libcpp/include/cpplib.h                            |  144 ++-
 libcpp/include/line-map.h                          |  329 ++++++
 libcpp/internal.h                                  |    7 +-
 libcpp/lex.c                                       |   20 +-
 libcpp/line-map.c                                  |  334 ++++++
 libcpp/macro.c                                     |    1 +
 libgo/testsuite/lib/libgo.exp                      |    1 +
 libgomp/testsuite/lib/libgomp.exp                  |    1 +
 libitm/testsuite/lib/libitm.exp                    |    1 +
 libvtv/testsuite/lib/libvtv.exp                    |    1 +
 84 files changed, 7124 insertions(+), 525 deletions(-)
 create mode 100644 gcc/box-drawing.c
 create mode 100644 gcc/box-drawing.h
 create mode 100644 gcc/diagnostic-show-locus.c
 create mode 100644 gcc/gcc-rich-location.c
 create mode 100644 gcc/gcc-rich-location.h
 create mode 100644 gcc/spellcheck.c
 create mode 100644 gcc/spellcheck.h
 create mode 100644 gcc/testsuite/g++.dg/diagnostic/token-ranges.C
 create mode 100644 gcc/testsuite/gcc.dg/diagnostic-token-ranges.c
 create mode 100644 gcc/testsuite/gcc.dg/diagnostic-tree-expr-ranges.c
 create mode 100644 gcc/testsuite/gcc.dg/format/diagnostic-ranges.c
 create mode 100644 gcc/testsuite/gcc.dg/plugin/diagnostic-test-expressions-1.c
 create mode 100644 gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-ascii-bw.c
 create mode 100644 gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-ascii-color.c
 create mode 100644 gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-utf-8-bw.c
 create mode 100644 gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-utf-8-color.c
 create mode 100644 gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-trees-1.c
 create mode 100644 gcc/testsuite/gcc.dg/plugin/diagnostic-test-string-literals-1.c
 create mode 100644 gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_show_trees.c
 create mode 100644 gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c
 create mode 100644 gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_string_literals.c
 create mode 100644 gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.c
 create mode 100644 gcc/testsuite/gcc.dg/spellcheck.c
 create mode 100644 gcc/testsuite/lib/multiline.exp

-- 
1.8.5.3

^ permalink raw reply	[flat|nested] 133+ messages in thread

end of thread, other threads:[~2021-11-05 11:39 UTC | newest]

Thread overview: 133+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-10 20:12 [PATCH 00/22] RFC: Overhaul of diagnostics David Malcolm
2015-09-10 20:12 ` [PATCH 01/22] Change of location_get_source_line signature David Malcolm
2015-09-14 19:28   ` Jeff Law
2015-09-15 17:02     ` David Malcolm
2015-09-10 20:13 ` [PATCH 06/22] PR/62314: add ability to add fixit-hints David Malcolm
2015-09-10 20:13 ` [PATCH 02/22] Testsuite: add dg-{begin|end}-multiline-output commands David Malcolm
2015-09-14 19:35   ` Jeff Law
2015-09-14 22:17     ` Bernhard Reutner-Fischer
2015-09-14 22:45       ` Jeff Law
2015-09-15 17:53         ` dejagnu version update? Mike Stump
2015-09-15 19:23           ` David Malcolm
2015-09-15 20:29             ` Jeff Law
2015-09-15 21:15               ` Bernhard Reutner-Fischer
2017-05-13 10:38                 ` Bernhard Reutner-Fischer
2017-05-13 11:06                   ` Jakub Jelinek
2017-05-13 21:12                     ` Jeff Law
2017-05-14 23:10                       ` NightStrike
2017-05-15  8:14                         ` Richard Biener
2017-05-15 19:24                           ` Mike Stump
2017-05-15 20:52                             ` Andreas Schwab
2017-05-16  9:56                     ` Jonathan Wakely
2017-05-16 12:16                       ` Bernhard Reutner-Fischer
2017-05-16 12:35                         ` Jonathan Wakely
2017-05-16 12:55                           ` Bernhard Reutner-Fischer
2017-05-16 18:41                             ` Matthias Klose
2017-05-16 19:09                           ` Mike Stump
2018-08-04 16:32                             ` Bernhard Reutner-Fischer
2018-08-06 14:33                               ` Jonathan Wakely
2018-08-06 15:26                               ` Mike Stump
2018-08-07 16:34                                 ` Segher Boessenkool
2018-08-08 11:18                                   ` Bernhard Reutner-Fischer
2018-08-08 13:35                                     ` Richard Earnshaw (lists)
2018-08-08 14:37                                     ` Michael Matz
2018-08-08 16:45                                     ` Segher Boessenkool
2021-10-27 23:00                               ` Bernhard Reutner-Fischer
2021-10-28 19:11                                 ` Jeff Law
2021-10-29  0:41                                   ` [PATCH] Bump required minimum DejaGnu version to 1.5.3 Bernhard Reutner-Fischer
2021-10-29  7:32                                     ` Richard Biener
2021-11-04 11:55                                       ` Segher Boessenkool
2021-11-04 12:22                                         ` Martin Liška
2021-11-04 19:09                                           ` Segher Boessenkool
2021-11-05  9:33                                             ` Richard Biener
2021-11-05 11:39                                               ` Jonathan Wakely
2021-11-04 12:41                                         ` Richard Biener
2021-11-04 13:50                                           ` Jonathan Wakely
2015-09-15 19:53           ` dejagnu version update? Bernhard Reutner-Fischer
2015-09-15 20:05             ` Jeff Law
2015-09-15 23:12               ` Mike Stump
2015-09-16  7:41                 ` Andreas Schwab
2015-09-16 16:19                   ` Mike Stump
2015-09-16 16:32                     ` Ramana Radhakrishnan
2015-09-16 16:39                       ` Jeff Law
2015-09-16 17:26                         ` Trevor Saunders
2015-09-16 17:46                         ` David Malcolm
2015-09-16 19:09                           ` Bernhard Reutner-Fischer
2015-09-16 19:51                             ` Mike Stump
2015-09-17  0:07                           ` Segher Boessenkool
2015-09-17 13:57                         ` Richard Earnshaw
2015-09-16 18:04                       ` Mike Stump
2015-09-16 18:58                         ` Bernhard Reutner-Fischer
2015-09-16 19:37                         ` Ramana Radhakrishnan
2015-09-16 13:17             ` Matthias Klose
2015-09-16 15:46               ` Bernhard Reutner-Fischer
2015-09-10 20:13 ` [PATCH 10/22] C++ FE: Use token ranges for various diagnostics David Malcolm
2015-09-10 20:13 ` [PATCH 08/22] C frontend: use token ranges in " David Malcolm
2015-09-10 20:13 ` [PATCH 03/22] Move diagnostic_show_locus and friends out into a new source file David Malcolm
2015-09-14 19:37   ` Jeff Law
2015-09-18 18:31     ` David Malcolm
2015-09-10 20:13 ` [PATCH 13/22] gcc-rich-location.[ch]: add methods for working with tree ranges David Malcolm
2015-09-10 20:13 ` [PATCH 11/22] Objective C: c/c-parser.c: use token ranges in two places David Malcolm
2015-09-10 20:13 ` [PATCH 20/22] Use rich locations in c-family/c-format.c David Malcolm
2015-09-10 20:13 ` [PATCH 09/22] C frontend: store and use token ranges in c_declspecs David Malcolm
2015-09-10 20:28 ` [PATCH 07/22] Implement token range tracking within libcpp and C/C++ FEs David Malcolm
2015-09-11 14:08   ` Michael Matz
2015-09-14 19:41     ` Jeff Law
2015-09-15 10:20   ` Richard Biener
2015-09-15 10:28     ` Jakub Jelinek
2015-09-15 10:48       ` Richard Biener
2015-09-15 11:01         ` Jakub Jelinek
2015-09-16 20:29           ` David Malcolm
2015-09-17 16:54             ` David Malcolm
2015-09-17 19:15               ` Jeff Law
2015-09-17 20:06                 ` David Malcolm
2015-09-17 19:25         ` Jeff Law
2015-09-15 12:09       ` Manuel López-Ibáñez
2015-09-15 12:18         ` Richard Biener
2015-09-15 12:57           ` Manuel López-Ibáñez
2015-09-17 19:11             ` Jeff Law
2015-09-17 19:13           ` Jeff Law
2015-09-15 13:53       ` David Malcolm
2015-09-10 20:29 ` [PATCH 05/22] Add overloads of inform, warning_at, etc that take a source_range David Malcolm
2015-09-10 20:29 ` [PATCH 04/22] Reimplement diagnostic_show_locus, introducing rich_location classes David Malcolm
2015-09-11 13:44   ` Michael Matz
2015-09-11 14:12   ` Michael Matz
2015-09-11 15:15     ` David Malcolm
2015-09-10 20:30 ` [PATCH 12/22] Add source-ranges for trees David Malcolm
2015-09-10 20:30 ` [PATCH 15/22] Add plugin to recursively dump the source-ranges in a tree David Malcolm
2015-09-11  3:19   ` Martin Sebor
2015-09-10 20:30 ` [PATCH 14/22] C: capture tree ranges for various expressions David Malcolm
2015-09-10 20:31 ` [PATCH 18/22] Track locations within string literals in tree_string David Malcolm
2015-09-10 20:31 ` [PATCH 19/22] gcc-rich-location.[ch]: add debug methods for cpp_string_location David Malcolm
2015-09-10 20:32 ` [PATCH 17/22] libcpp: add location tracking within string literals David Malcolm
2015-09-10 20:32 ` [PATCH 16/22] C/C++ frontend: use tree ranges in various diagnostics David Malcolm
2015-09-10 20:32 ` [PATCH 21/22] Use Levenshtein distance for various misspellings in C frontend David Malcolm
2015-09-10 21:11   ` Andi Kleen
2015-09-11 15:31   ` Manuel López-Ibáñez
2015-09-15 15:25     ` [PATCH WIP] Use Levenshtein distance for various misspellings in C frontend v2 David Malcolm
2015-09-15 16:25       ` Manuel López-Ibáñez
2015-09-16  8:45       ` Richard Biener
2015-09-16 13:33         ` Michael Matz
2015-09-16 14:00           ` Richard Biener
2015-09-16 15:49             ` Manuel López-Ibáñez
2015-09-17  8:46               ` Richard Biener
2015-09-17 19:32         ` Jeff Law
2015-09-17 20:05           ` David Malcolm
2015-09-17 20:52             ` Manuel López-Ibáñez
2015-10-30 12:30           ` [PATCH 0/2] Levenshtein-based suggestions (v3) David Malcolm
2015-10-30 12:30             ` [PATCH 2/2] C FE: suggest corrections for misspelled field names David Malcolm
2015-10-30 12:36             ` [PATCH 1/2] Implement Levenshtein distance David Malcolm
2015-11-02 10:56               ` Mikael Morin
2015-11-02  6:44             ` [PATCH 0/2] Levenshtein-based suggestions (v3) Jeff Law
2015-11-13  2:08               ` David Malcolm
2015-11-13  6:57                 ` Marek Polacek
2015-11-13 12:16                   ` David Malcolm
2015-11-13 15:11                     ` Marek Polacek
2015-11-13 15:44                       ` Bernd Schmidt
2015-11-13 15:53                         ` Marek Polacek
2015-11-13 15:56                           ` Jakub Jelinek
2015-11-13 16:02                             ` Marek Polacek
2015-09-10 20:50 ` [PATCH 22/22] Add fixit hints to spellchecker suggestions David Malcolm
2015-09-14 17:49 ` [PATCH 00/22] RFC: Overhaul of diagnostics Bernd Schmidt
2015-09-14 19:44   ` Jeff Law
2015-09-15  1:11     ` David Malcolm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).