aboutsummaryrefslogtreecommitdiff
path: root/gcc/diagnostic-path.h
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2024-05-15 21:22:51 -0400
committerDavid Malcolm <dmalcolm@redhat.com>2024-05-15 21:22:51 -0400
commit3cd267446755ab6b2c59936a718d34c8bc474ca5 (patch)
tree017b586dc28cb09be709b49dad35070fda091d04 /gcc/diagnostic-path.h
parenta7be993806a90a58397e9d5bc9b54160ac9f35db (diff)
downloadgcc-3cd267446755ab6b2c59936a718d34c8bc474ca5.zip
gcc-3cd267446755ab6b2c59936a718d34c8bc474ca5.tar.gz
gcc-3cd267446755ab6b2c59936a718d34c8bc474ca5.tar.bz2
diagnostics: simplify output of purely intraprocedural execution paths
Diagnostic path printing was added in r10-5901-g4bc1899b2e883f. As of that commit, with -fdiagnostics-path-format=inline-events (the default), we print a vertical line to the left of the source line numbering, visualizing the stack depth and interprocedural calls and returns as indentation changes. For cases where the events on a thread are purely interprocedural, this line does nothing except take up space and complicate the output. This patch adds logic to omit it for such cases, simpifying the output, and, I believe, improving readability. gcc/ChangeLog: * diagnostic-path.h: Update leading comment to reflect intraprocedural cases. Fix typo in comment. * doc/invoke.texi: Update intraprocedural example. gcc/testsuite/ChangeLog: * c-c++-common/analyzer/allocation-size-multiline-1.c: Update expected results for purely intraprocedural path. * c-c++-common/analyzer/allocation-size-multiline-2.c: Likewise. * c-c++-common/analyzer/allocation-size-multiline-3.c: Likewise. * c-c++-common/analyzer/analyzer-verbosity-0.c: Likewise. * c-c++-common/analyzer/analyzer-verbosity-1.c: Likewise. * c-c++-common/analyzer/analyzer-verbosity-2.c: Likewise. * c-c++-common/analyzer/analyzer-verbosity-3.c: Likewise. * c-c++-common/analyzer/malloc-macro-inline-events.c: Likewise. Doing so for this file requires a rewrite since the paths prefixing the "in expansion of macro" lines become the only thing on their line and so are no longer pruned by multiline.exp logic for pruning extra content on non-blank lines. * c-c++-common/analyzer/malloc-paths-9-noexcept.c: Likewise. * c-c++-common/analyzer/setjmp-2.c: Likewise. * gcc.dg/analyzer/malloc-paths-9.c: Likewise. * gcc.dg/analyzer/out-of-bounds-multiline-2.c: Likewise. * gcc.dg/plugin/diagnostic-test-paths-2.c: Likewise. gcc/ChangeLog: * tree-diagnostic-path.cc (per_thread_summary::interprocedural_p): New. (thread_event_printer::print_swimlane_for_event_range): Don't indent and print the stack depth line if this thread's events are purely intraprocedural. (selftest::test_intraprocedural_path): Update expected output. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc/diagnostic-path.h')
-rw-r--r--gcc/diagnostic-path.h32
1 files changed, 15 insertions, 17 deletions
diff --git a/gcc/diagnostic-path.h b/gcc/diagnostic-path.h
index fb7abe8..696991c 100644
--- a/gcc/diagnostic-path.h
+++ b/gcc/diagnostic-path.h
@@ -41,22 +41,20 @@ class sarif_object;
29 | PyList_Append(list, item);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
'demo': events 1-3
- |
- | 25 | list = PyList_New(0);
- | | ^~~~~~~~~~~~~
- | | |
- | | (1) when 'PyList_New' fails, returning NULL
- | 26 |
- | 27 | for (i = 0; i < count; i++) {
- | | ~~~
- | | |
- | | (2) when 'i < count'
- | 28 | item = PyLong_FromLong(random());
- | 29 | PyList_Append(list, item);
- | | ~~~~~~~~~~~~~~~~~~~~~~~~~
- | | |
- | | (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
- |
+ 25 | list = PyList_New(0);
+ | ^~~~~~~~~~~~~
+ | |
+ | (1) when 'PyList_New' fails, returning NULL
+ 26 |
+ 27 | for (i = 0; i < count; i++) {
+ | ~~~
+ | |
+ | (2) when 'i < count'
+ 28 | item = PyLong_FromLong(random());
+ 29 | PyList_Append(list, item);
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~
+ | |
+ | (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
The diagnostic-printing code has consolidated the path into a single
run of events, since all the events are near each other and within the same
@@ -146,7 +144,7 @@ class diagnostic_event
virtual tree get_fndecl () const = 0;
- /* Stack depth, so that consumers can visualizes the interprocedural
+ /* Stack depth, so that consumers can visualize the interprocedural
calls, returns, and frame nesting. */
virtual int get_stack_depth () const = 0;