[pushed] diagnostics: fix missing init of set_locations_cb

2023-10-02 Thread David Malcolm
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-4366-gc64693fb885f21. gcc/ChangeLog: * diagnostic.cc (diagnostic_initialize): Initialize set_locations_cb to nullptr. --- gcc/diagnostic.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc

[pushed] diagnostics: add diagnostic_output_format class

2023-10-02 Thread David Malcolm
Eliminate various global variables in the json/sarif output code by bundling together callbacks and state into a new diagnostic_output_format class, with per-output-format subclasses. No functional change intended. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as

[pushed] diagnostics: group together source printing fields of diagnostic_context

2023-10-02 Thread David Malcolm
struct diagnostic_context has > 60 fields. Try to tame some of the complexity by grouping together the 8 source-printing fields into a struct, the "m_source_printing" field. No functional change intended. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-4367-

[pushed] diagnostics: add ctors to text_info; add m_ prefixes to fields

2023-10-03 Thread David Malcolm
No functional change intended. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-4379-gc44ca7c01226e0. gcc/ada/ChangeLog: * gcc-interface/misc.cc: Use text_info ctor. gcc/analyzer/ChangeLog: * analyzer-logging.cc (logger::log_va_partial): Use t

[PATCH] c++: print source code in print_instantiation_partial_context_line

2023-10-03 Thread David Malcolm
* error.cc (print_instantiation_partial_context_line): Call diagnostic_show_locus. gcc/testsuite/ChangeLog: * g++.dg/diagnostic/static_assert3.C: Add directives for additional source printing. * g++.dg/template/error60.C: New test. Signed-off-by: David Malcolm --

Re: [COMMITTED] Remove pass counting in VRP.

2023-10-03 Thread David Malcolm
On Tue, 2023-10-03 at 10:32 -0400, Andrew MacLeod wrote: > Pass counting in VRP is used to decide when to call early VRP, pass > the > flag to enable warnings, and when the final pass is. > > If you try to add additional passes, this becomes quite fragile. This > patch simply chooses the pass bas

Re: [COMMITTED] Remove pass counting in VRP.

2023-10-03 Thread David Malcolm
On Tue, 2023-10-03 at 13:11 -0400, Andrew MacLeod wrote: > > On 10/3/23 13:02, David Malcolm wrote: > > On Tue, 2023-10-03 at 10:32 -0400, Andrew MacLeod wrote: > > > Pass counting in VRP is used to decide when to call early VRP, > > > pass > > > the >

[pushed] libcpp: "const" and other cleanups

2023-10-08 Thread David Malcolm
No functional change intended. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-4475-g25af7c1a806c0c. gcc/ChangeLog: * input.cc (make_location): Move implementation to line_maps::make_location. libcpp/ChangeLog: * include/line-map.h (l

[pushed] diagnostics: fix ICE on sarif output when source file is unreadable [PR111700]

2023-10-08 Thread David Malcolm
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-4474-g94caa6a6b4bd73. gcc/ChangeLog: PR driver/111700 * input.cc (file_cache::add_file): Update leading comment to clarify that it can fail. (file_cache::lookup_or_add_file): Likew

[pushed] libcpp: eliminate COMBINE_LOCATION_DATA

2023-10-08 Thread David Malcolm
This patch eliminates the function "COMBINE_LOCATION_DATA" (which hasn't been a macro since r6-739-g0501dbd932a7e9) and the function "get_combined_adhoc_loc" in favor of a new line_maps::get_or_create_combined_loc member function. No functional change intended. Successfully bootstrapped & regrtes

[pushed] libcpp: eliminate LINEMAPS_LAST_ALLOCATED{, _ORDINARY, _MACRO}_MAP

2023-10-08 Thread David Malcolm
Nothing uses these; delete them. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-4478-ga73c80d99736f0. libcpp/ChangeLog: * include/line-map.h (LINEMAPS_LAST_ALLOCATED_MAP): Delete. (LINEMAPS_LAST_ALLOCATED_ORDINARY_MAP): Delete. (LINEM

[pushed] libcpp: eliminate LINEMAPS_{,ORDINARY_,MACRO_}CACHE

2023-10-08 Thread David Malcolm
It's simpler to use field access than to go through these inline functions that look as if they are macros. No functional change intended. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-4479-g45bae1809c3919. libcpp/ChangeLog: * include/line-map.h (m

[pushed] analyzer: improvements to out-of-bounds diagrams [PR111155]

2023-10-08 Thread David Malcolm
Update out-of-bounds diagrams to show existing string values, and the initial write index within a string buffer. For example, given the out-of-bounds write in strcat in: void test (void) { char buf[10]; strcpy (buf, "hello"); strcat (buf, " world!"); } the diagram improves from:

[pushed] libcpp: eliminate LINEMAPS_{ORDINARY,MACRO}_MAPS

2023-10-08 Thread David Malcolm
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-4480-g0a0ceb7a72fe0b. libcpp/ChangeLog: * include/line-map.h (LINEMAPS_ORDINARY_MAPS): Delete. (LINEMAPS_MACRO_MAPS): Delete. * line-map.cc (linemap_tracks_macro_expansion_locs_p): Update

Re: [pushed] analyzer: improvements to out-of-bounds diagrams [PR111155]

2023-10-09 Thread David Malcolm
es::kind)': > gcc/analyzer/access-diagram.cc:655:20: error: 'kind' is not a class, > namespace, or enumeration >     (kind == kind::HARD) ? "HARD" : "soft"); >      ^ > The problem is ... > > On 09.10.23 00:58, David Mal

Re: [pushed] analyzer: improvements to out-of-bounds diagrams [PR111155]

2023-10-09 Thread David Malcolm
On Mon, 2023-10-09 at 17:01 +0200, Tobias Burnus wrote: > Hi David, > > On 09.10.23 16:08, David Malcolm wrote: > > On Mon, 2023-10-09 at 12:09 +0200, Tobias Burnus wrote: > > > The following works: > > > (A) Using "kind == boundaries::kind::HARD"

[pushed] diagnostics: fix missing initialization of context->extra_output_kind

2023-10-16 Thread David Malcolm
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-4668-gf8644b678285cf. gcc/ChangeLog: * diagnostic.cc (diagnostic_initialize): Ensure context->extra_output_kind is initialized. --- gcc/diagnostic.cc | 2 +- 1 file changed, 1 insertion(+), 1 del

[pushed] diagnostics: special-case -fdiagnostics-text-art-charset=ascii for LANG=C

2023-10-16 Thread David Malcolm
In the LWN discussion of the "ASCII" art in GCC 14 https://lwn.net/Articles/946733/#Comments there was some concern about the use of non-ASCII characters in the output. Currently -fdiagnostics-text-art-charset defaults to "emoji". To better handle older terminals by default, this patch special-c

[RFC] Add function attribute: null_terminated_string_arg(PARAM_IDX)

2023-10-19 Thread David Malcolm
c: New test. * c-c++-common/analyzer/attr-null_terminated_string_arg-nonnull.c: New test. * c-c++-common/analyzer/attr-null_terminated_string_arg-nullable-sized.c: New test. * c-c++-common/analyzer/attr-null_terminated_string_arg-nullable.c: New t

[committed] Reinstate dump_generic_expr_loc

2018-07-01 Thread David Malcolm
In r262149 ("Introduce dump_location_t", aka c309657f69df19eaa590b6650acf4d3bea9ac9e6), I removed dump_generic_expr_loc from dumpfile.h/c as it was unused in the source tree. It looks like this was overzealous of me, as Richard wants to use it in "Re: [14/n] PR85694: Rework overwidening detectio

Re: [PATCH] -fopt-info: add indentation via DUMP_VECT_SCOPE

2018-07-02 Thread David Malcolm
On Mon, 2018-07-02 at 14:23 +0200, Christophe Lyon wrote: > On Fri, 29 Jun 2018 at 10:09, Richard Biener com> wrote: > > > > On Tue, Jun 26, 2018 at 5:43 PM David Malcolm > > wrote: > > > > > > This patch adds a concept of nested "scopes" to

Re: [C++ Patch] Adjust one more error message to use rich_location::add_range

2018-07-02 Thread David Malcolm
On Mon, 2018-07-02 at 12:58 +0200, Paolo Carlini wrote: > Hi, > > I was double checking my pending patch and going through the errors > we > emit in decl.c and elsewhere about thread_local and __thread and > noticed > another place, in parser.c, where using rich_location::add_range > seems > na

[committed] selftest: introduce class auto_fix_quotes

2018-07-02 Thread David Malcolm
This patch moves a workaround for locale differences from a selftest in pretty-print.c to selftest.h/c to make it reusable; I need this for a selftest in a followup patch. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Committed to trunk as r262317 (with my "diagnostic messages" m

[PATCH 1/2] Add "optinfo" framework

2018-07-02 Thread David Malcolm
; typedef union section section; struct gcc_options; diff --git a/gcc/dump-context.h b/gcc/dump-context.h new file mode 100644 index 000..753f714 --- /dev/null +++ b/gcc/dump-context.h @@ -0,0 +1,128 @@ +/* Support code for handling the various dump_* calls in dumpfile.h + Copyright (C) 2018 F

[PATCH 0/2] v4: optinfo framework and remarks

2018-07-02 Thread David Malcolm
On Fri, 2018-06-29 at 09:09 +0200, Richard Biener wrote: > On Thu, Jun 28, 2018 at 4:29 PM David Malcolm > wrote: > > > > On Thu, 2018-06-28 at 13:29 +0200, Richard Biener wrote: > > > On Tue, Jun 26, 2018 at 3:54 PM David Malcolm > > m> > > > wrote:

[PATCH 2/2] optinfo: add diagnostic remarks

2018-07-02 Thread David Malcolm
test_flag("NoDWARFRecord", flags, " | CL_NO_DWARF_RECORD") \ test_flag("Warning", flags, " | CL_WARNING") \ + test_flag("Remark", flags, " | CL_REMARK") \ test_flag("(Optimization|PerFunction)", f

Re: [PATCH] -fopt-info: add indentation via DUMP_VECT_SCOPE

2018-07-03 Thread David Malcolm
On Tue, 2018-07-03 at 09:37 +0200, Richard Biener wrote: > On Mon, Jul 2, 2018 at 7:00 PM David Malcolm > wrote: > > > > On Mon, 2018-07-02 at 14:23 +0200, Christophe Lyon wrote: > > > On Fri, 29 Jun 2018 at 10:09, Richard Biener > > ail. > > > com>

[PATCH] Remove "note: " prefix from some scan-tree-dump directives

2018-07-03 Thread David Malcolm
On Tue, 2018-07-03 at 15:53 +0200, Richard Biener wrote: > On Tue, Jul 3, 2018 at 3:52 PM David Malcolm > wrote: > > > > On Tue, 2018-07-03 at 09:37 +0200, Richard Biener wrote: > > > On Mon, Jul 2, 2018 at 7:00 PM David Malcolm > > > > > > wrote

Re: Add support for dumping multiple dump files under one name

2018-07-03 Thread David Malcolm
On Tue, 2018-07-03 at 11:00 +0100, Andre Vieira (lists) wrote: > On 29/06/18 11:13, David Malcolm wrote: > > On Fri, 2018-06-29 at 10:15 +0200, Richard Biener wrote: > > > On Fri, 22 Jun 2018, Jan Hubicka wrote: > > > > > > > Hi, > > > > this

[PATCH 0/5] [RFC v2] Higher-level reporting of vectorization problems

2018-07-09 Thread David Malcolm
On Mon, 2018-06-25 at 11:10 +0200, Richard Biener wrote: > On Fri, 22 Jun 2018, David Malcolm wrote: > > > NightStrike and I were chatting on IRC last week about > > issues with trying to vectorize the following code: > > > > #include > > std::size_t f(s

[PATCH 2/5] Use opt-problem.h in try_vectorize_loop_1

2018-07-09 Thread David Malcolm
gcc/ChangeLog: * tree-vectorizer.c: Include "opt-problem.h". (try_vectorize_loop_1): Convert "loop_vinfo" from loop_vec_info to opt_loop_vec_info loop_vinfo, and use opt_report to report any opt_problem thus captured. Use opt_report ro report on successful l

[PATCH 3/5] Add some test coverage

2018-07-09 Thread David Malcolm
In particular, note how this allows us to highlight specific loops in testcases (via dg-remark), and to highlight the specific lines that cause problems to the vectorizer (via dg-message). gcc/testsuite/ChangeLog: * gcc.dg/vect/vect-alias-check-4.c: Add -fremarks to options. Add d

[PATCH 1/5] Add opt-problem.h

2018-07-09 Thread David Malcolm
-problem.h diff --git a/gcc/opt-problem.h b/gcc/opt-problem.h new file mode 100644 index 000..100eed0 --- /dev/null +++ b/gcc/opt-problem.h @@ -0,0 +1,326 @@ +/* Rich information on why an optimization wasn't possible. + Copyright (C) 2018 Free Software Foundation, Inc. + Contributed by

[PATCH 5/5] Add opt-problem.cc

2018-07-09 Thread David Malcolm
-query.o \ diff --git a/gcc/opt-problem.cc b/gcc/opt-problem.cc new file mode 100644 index 000..f518b16 --- /dev/null +++ b/gcc/opt-problem.cc @@ -0,0 +1,96 @@ +/* Rich information on why an optimization wasn't possible. + Copyright (C) 2018 Free Software Foundation, Inc. + Contributed by

[PATCH 4/5] Use opt_result throughout vectorizer

2018-07-09 Thread David Malcolm
This patch uses the opt_result framework throughout the vectorizer (and a few other places) so that specific details on problems are propagated back up to the top-level of the vectorizer. The changes are mostly fairly mechanical. There are various FIXMEs in the code: for example, in various place

Re: [PATCH 1/2] Add "optinfo" framework

2018-07-10 Thread David Malcolm
On Mon, 2018-07-09 at 15:00 +0200, Richard Biener wrote: > On Mon, Jul 2, 2018 at 10:51 PM David Malcolm > wrote: > > > > This patch implements a way to consolidate dump_* calls into > > optinfo objects, as enabling work towards being able to write out > > optimizat

[PATCH 2/2] Add "-fsave-optimization-record"

2018-07-11 Thread David Malcolm
ll subsequent dump_* calls are consolidated into diff --git a/gcc/json.cc b/gcc/json.cc new file mode 100644 index 000..3c2aa77 --- /dev/null +++ b/gcc/json.cc @@ -0,0 +1,293 @@ +/* JSON trees + Copyright (C) 2017-2018 Free Software Foundation, Inc. + Contributed by David Malcolm . + +This f

[PATCH 1/2] v5: Add "optinfo" framework

2018-07-11 Thread David Malcolm
dump-context.h new file mode 100644 index 000..a191e3a --- /dev/null +++ b/gcc/dump-context.h @@ -0,0 +1,138 @@ +/* Support code for handling the various dump_* calls in dumpfile.h + Copyright (C) 2018 Free Software Foundation, Inc. + Contributed by David Malcolm . + +This file is part of GCC.

Re: [PATCH 0/5] [RFC v2] Higher-level reporting of vectorization problems

2018-07-11 Thread David Malcolm
On Wed, 2018-07-11 at 16:56 +0100, Richard Sandiford wrote: > David Malcolm writes: > > On Mon, 2018-06-25 at 11:10 +0200, Richard Biener wrote: > > > On Fri, 22 Jun 2018, David Malcolm wrote: > > > > > > > NightStrike and I were chatting on IRC last w

[PATCH] C++: suggestions for misspelled private members (PR c++/84993)

2018-07-11 Thread David Malcolm
PR c++/84993 identifies a problem with our suggestions for misspelled member names in the C++ FE for the case where the member is private. For example, given: class foo { public: double get_ratio() const { return m_ratio; } private: double m_ratio; }; void test(foo *ptr) { if (ptr->ratio

Re: [PATCH] Fix _Pragma GCC diagnostic in macro expansions

2018-07-18 Thread David Malcolm
On Wed, 2018-07-04 at 10:53 +, Bernd Edlinger wrote: Sorry for the delay in reviewing this. > Hi, > > currently _Pragma("GCC diagnostic ...") does not properly > work in macro expansions. > > Consider the following code: > > #define B _Pragma("GCC diagnostic push") \ > _Pragma("GCC

[PING] Re: [PATCH 1/2] v5: Add "optinfo" framework

2018-07-18 Thread David Malcolm
Ping, re these patches: "[PATCH 1/2] v5: Add "optinfo" framework" https://gcc.gnu.org/ml/gcc-patches/2018-07/msg00535.html "[PATCH 2/2] Add "-fsave-optimization-record"" https://gcc.gnu.org/ml/gcc-patches/2018-07/msg00536.html Thanks Dave On Wed,

Re: [PATCH 2/2] Add "-fsave-optimization-record"

2018-07-20 Thread David Malcolm
On Thu, 2018-07-19 at 14:39 +0200, Richard Biener wrote: > On Wed, Jul 11, 2018 at 12:53 PM David Malcolm > wrote: > > > > This patch implements a -fsave-optimization-record option, which > > leads to a JSON file being written out, recording the dump_* calls &

[PATCH] -fsave-optimization-record: add contrib/optrecord.py

2018-07-20 Thread David Malcolm
e --- /dev/null +++ b/contrib/optrecord.py @@ -0,0 +1,295 @@ +#!/usr/bin/env python3 +# +# Python module for working with the result of -fsave-optimization-record +# Contributed by David Malcolm . +# +# Copyright (C) 2018 Free Software Foundation, Inc. +# This file is part of GCC. +# +# GCC is fre

[committed] libcpp: remove redundant parameter from rich_location::set_range

2018-07-20 Thread David Malcolm
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Committed to trunk as r262913. gcc/c-family/ChangeLog: * c-common.c (c_cpp_error): Remove redundant "line_table" parameter from call to rich_location::set_range. (maybe_suggest_missing_token_insertion): Likewis

Re: [PATCH] -fsave-optimization-record: add contrib/optrecord.py

2018-07-23 Thread David Malcolm
On Mon, 2018-07-23 at 11:46 +0200, Richard Biener wrote: > On Fri, Jul 20, 2018 at 6:27 PM David Malcolm > wrote: > > > > This patch adds a Python 3 module to "contrib" for reading the > > output of > > -fsave-optimization-record. > > > &g

[PATCH] Fix segfault in -fsave-optimization-record (PR tree-optimization/86636)

2018-07-23 Thread David Malcolm
There are various ways that it's possible for a gimple statement to have an UNKNOWN_LOCATION, and for that UNKNOWN_LOCATION to be wrapped in an ad-hoc location to capture inlining information. For such a location, LOCATION_FILE (loc) is NULL. Various places in -fsave-optimization-record were chec

Re: [PATCH] include more detail in -Warray-bounds (PR 86650)

2018-07-23 Thread David Malcolm
On Mon, 2018-07-23 at 17:49 -0600, Martin Sebor wrote: > (David, I'm hoping your your help here. Please see the end.) > > While looking into a recent -Warray-bounds instance in Glibc > involving inlining of large functions it became apparent that > GCC could do a better job of pinpointing the sou

Re: [PATCH] include more detail in -Warray-bounds (PR 86650)

2018-07-24 Thread David Malcolm
On Mon, 2018-07-23 at 20:56 -0600, Martin Sebor wrote: > On 07/23/2018 07:20 PM, David Malcolm wrote: > > On Mon, 2018-07-23 at 17:49 -0600, Martin Sebor wrote: > > > (David, I'm hoping your your help here. Please see the end.) > > > > > > While looking

Re: [PATCH] combine: Allow combining two insns to two insns

2018-07-25 Thread David Malcolm
On Tue, 2018-07-24 at 17:18 +, Segher Boessenkool wrote: > This patch allows combine to combine two insns into two. This helps > in many cases, by reducing instruction path length, and also allowing > further combinations to happen. PR85160 is a typical example of code > that it can improve.

[committed] optinfo-emit-json.cc: fix trivial memory leak

2018-07-25 Thread David Malcolm
There's a small leak in class optrecord_json_writer, which shows up as a new leak in "make selftest-valgrind" as: ==50133== 40 bytes in 1 blocks are definitely lost in loss record 27 of 672 ==50133==at 0x4A0645D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==50133==b

Re: [PATCH] -fsave-optimization-record: add contrib/optrecord.py

2018-07-25 Thread David Malcolm
On Tue, 2018-07-24 at 16:11 +0200, Richard Biener wrote: > On Mon, Jul 23, 2018 at 9:20 PM David Malcolm > wrote: > > > > On Mon, 2018-07-23 at 11:46 +0200, Richard Biener wrote: > > > On Fri, Jul 20, 2018 at 6:27 PM David Malcolm > > m> > > > wrote

[PATCH] RFC: Prototype of "rich vectorization hints" idea

2018-07-25 Thread David Malcolm
---+\n" + "|scalar| |prologue |\n" + "| | +---+\n" + "| | |\n" + "| | +---+\n" +

[PATCH] Fixes to testcase for PR tree-optimization/86636

2018-07-27 Thread David Malcolm
On Thu, 2018-07-26 at 13:22 +0100, Andre Vieira (lists) wrote: [...snip...] > > > diff --git a/gcc/testsuite/gcc.c-torture/compile/pr86636.c > > > b/gcc/testsuite/gcc.c-torture/compile/pr86636.c > > > new file mode 100644 > > > index 000..2fe2f70 > > > --- /dev/null > > > +++ b/gcc/testsuite/

[PING] Re: [PATCH] C++: suggestions for misspelled private members (PR c++/84993)

2018-07-27 Thread David Malcolm
Ping: https://gcc.gnu.org/ml/gcc-patches/2018-07/msg00594.html On Wed, 2018-07-11 at 22:42 -0400, David Malcolm wrote: > PR c++/84993 identifies a problem with our suggestions for > misspelled member names in the C++ FE for the case where the > member is private. > > For

Re: [PATCH] Fixes to testcase for PR tree-optimization/86636

2018-07-27 Thread David Malcolm
On Fri, 2018-07-27 at 17:43 +0100, Andre Vieira (lists) wrote: > On 27/07/18 16:39, David Malcolm wrote: > > On Thu, 2018-07-26 at 13:22 +0100, Andre Vieira (lists) wrote: > > > > [...snip...] > > > > > > > diff --git a/gcc/testsuite/gcc.c-torture/c

[PATCH 1/5] Simplify dump_context by adding a dump_loc member function

2018-07-27 Thread David Malcolm
This patch removes some duplicated code in dumpfile.c by reimplementing the various dump_foo_loc calls in terms of dump_foo. gcc/ChangeLog: * dump-context.h (dump_context::dump_loc): New decl. * dumpfile.c (dump_context::dump_loc): New member function. (dump_context::dump_g

[PATCH 0/5] dump_printf support for middle-end types

2018-07-27 Thread David Malcolm
(stmt, "not vectorized: different sized vector " "types in statement, %T and %T\n", vectype, nunits_vectype); where opt_result::failure_at would encapsulate the "false", and capture an opt_problem * (when du

[PATCH 3/5] C++: clean up cp_printer

2018-07-27 Thread David Malcolm
This makes it easier to compare cp_printer with gcc_cxxdiag_char_table in c-format.c. No functional change intended. gcc/cp/ChangeLog: * error.c (cp_printer): In the leading comment, move "%H" and "I" into alphabetical order, and add missing "%G" and "K". Within the switc

[PATCH 4/5] c-family: clean up the data tables in c-format.c

2018-07-27 Thread David Malcolm
The format_char_info tables in c-format.c for our own formats contain a lot of repetition. This patch adds a macro to express the conversion specifiers implemented within pp_format, making it clearer which are custom ones added by the various diagnostic_format_decoder callbacks. Doing so uncovere

[PATCH 5/5] Formatted printing for dump_* in the middle-end

2018-07-27 Thread David Malcolm
This patch converts dump_print and dump_printf_loc from using printf (and thus ATTRIBUTE_PRINTF) to using a new pretty-printer based on pp_format, which supports formatting middle-end types. In particular, the following codes are implemented (in addition to the standard pretty_printer ones): %

[PATCH 2/5] dumpfile.c: eliminate special-casing of dump_file/alt_dump_file

2018-07-27 Thread David Malcolm
With the addition of optinfo, the various dump_* calls had three parts: - optionally print to dump_file - optionally print to alt_dump_file - optionally make an optinfo_item and add it to the pending optinfo, creating it for dump_*_loc calls. However, this split makes it difficult to implement t

Re: [PATCH 0/5] dump_printf support for middle-end types

2018-07-31 Thread David Malcolm
On Tue, 2018-07-31 at 14:50 +0200, Richard Biener wrote: > On Fri, Jul 27, 2018 at 11:47 PM David Malcolm > wrote: > > > > This patch kit converts dump_print and dump_printf_loc from using > > fprintf etc internally to using a new pretty-printer > > based on pp_for

Re: [PATCH 5/5] Formatted printing for dump_* in the middle-end

2018-07-31 Thread David Malcolm
On Tue, 2018-07-31 at 15:03 +0200, Richard Biener wrote: > On Fri, Jul 27, 2018 at 11:49 PM David Malcolm > wrote: > > > > This patch converts dump_print and dump_printf_loc from using > > printf (and thus ATTRIBUTE_PRINTF) to using a new pretty-printer > > base

Re: [PATCH 2/5] dumpfile.c: eliminate special-casing of dump_file/alt_dump_file

2018-07-31 Thread David Malcolm
On Tue, 2018-07-31 at 14:53 +0200, Richard Biener wrote: > On Fri, Jul 27, 2018 at 11:48 PM David Malcolm > wrote: > > > > With the addition of optinfo, the various dump_* calls had three > > parts: > > - optionally print to dump_file > > - optionally print to

Re: [RFC] Add function attribute: null_terminated_string_arg(PARAM_IDX)

2023-10-19 Thread David Malcolm
On Thu, 2023-10-19 at 16:13 +0200, Andreas Schwab wrote: > On Okt 19 2023, David Malcolm wrote: [...] > > +   /* First, check for a null-terminated string *without* > > +  emitting emitting warnings (via a null context), to > > -emitting > Thanks; I

Re: [PATCH] libcpp: Improve the diagnostic for poisoned identifiers [PR36887]

2023-10-23 Thread David Malcolm
On Wed, 2023-09-20 at 00:12 -0400, Lewis Hyatt wrote: > Hello- > > This patch implements the PR's request to add more information to the > diagnostic issued for using a poisoned identifier. Bootstrapped + > regtested > all languages on x86-64 Linux. Does it look OK please? Thanks! Thanks! Patch

Re: [PATCH v5 2/5] libcpp: add a function to determine UTF-8 validity of a C string

2023-10-23 Thread David Malcolm
On Wed, Jan 25, 2023 at 4:09 PM Ben Boeckel via Gcc wrote: > > This simplifies the interface for other UTF-8 validity detections when a > simple "yes" or "no" answer is sufficient. > > libcpp/ > > * charset.cc: Add `_cpp_valid_utf8_str` which determines whether > a C string is vali

Re: [PATCH v5 2/5] libcpp: add a function to determine UTF-8 validity of a C string

2023-10-23 Thread David Malcolm
On Mon, 2023-10-23 at 11:24 -0400, Jason Merrill wrote: > On 10/23/23 11:16, David Malcolm wrote: > > On Wed, Jan 25, 2023 at 4:09 PM Ben Boeckel via Gcc > > wrote: > > > > > > This simplifies the interface for other UTF-8 validity detections > > > w

Re: [PATCH] gcc/jit/jit-recording.cc: recording::global::write_to_dump: Avoid crashes when writing psuedo-C for globals with string initializers.

2023-10-25 Thread David Malcolm
On Fri, 2022-11-25 at 02:13 +0530, Vibhav Pant via Jit wrote: > If a char * global was initialized with a rvalue from > `gcc_jit_context_new_string_literal` containing a format string, > dumping the context causes libgccjit to SIGSEGV due to an improperly > constructed call to vasprintf. The follow

Re: [RFC] Add function attribute: null_terminated_string_arg(PARAM_IDX)

2023-10-26 Thread David Malcolm
On Thu, 2023-10-19 at 10:02 -0400, David Malcolm wrote: > This patch adds a new function attribute to GCC for marking that an > argument is expected to be a null-terminated string. > > For example, consider: > >   void test_a (const char *p) >     __attribute__((null_ter

[pushed] pretty-print: gracefully handle null URLs

2023-10-31 Thread David Malcolm
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-5047-gb9e2088d297744. gcc/ChangeLog: * pretty-print.cc (pretty_printer::pretty_printer): Initialize m_skipping_null_url. (pp_begin_url): Handle URL being null. (pp_end_url): Likewi

[pushed] opts.cc: fix comment about DOCUMENTATION_ROOT_URL

2023-10-31 Thread David Malcolm
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-5048-g8b4ac021cd1f63. gcc/ChangeLog: * opts.cc (get_option_url): Update comment; the requirement to pass DOCUMENTATION_ROOT_URL's value via -D was removed in r10-8065-ge33a1eae25b8a8. ---

[pushed] libcpp: eliminate MACRO_MAP_EXPANSION_POINT_LOCATION

2023-10-31 Thread David Malcolm
This patch eliminates the function "MACRO_MAP_EXPANSION_POINT_LOCATION" (which hasn't been a macro since r6-739-g0501dbd932a7e9) in favor of a new line_map_macro::get_expansion_point_location accessor. No functional change intended. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. P

[pushed] analyzer: move class record_layout to its own .h/.cc

2023-10-31 Thread David Malcolm
@@ -0,0 +1,125 @@ +/* Implementation of class record_layout. + Copyright (C) 2022-2023 Free Software Foundation, Inc. + Contributed by David Malcolm . + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as publishe

[pushed] analyzer: fix clang warnings [PR112317]

2023-11-02 Thread David Malcolm
No functional change intended. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-5080-gc71028c979d55f. gcc/analyzer/ChangeLog: PR analyzer/112317 * access-diagram.cc (class x_aligned_x_ruler_widget): Eliminate unused field "m_col_widths"

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

2023-11-02 Thread David Malcolm
d 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

[PATCH 3/4] diagnostics: add automatic URL-ification within messages

2023-11-02 Thread David Malcolm
in_diagnostic (diagnostic); pp_output_formatted_text (context->printer); if (context->show_cwe) diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h index a2c8740cbd0..d79369289bc 100644 --- a/gcc/diagnostic.h +++ b/gcc/diagnostic.h @@ -354,6 +354,10 @@ struct diagnostic_context par

[PATCH 2/4] c: add #pragma GCC show_layout

2023-11-02 Thread David Malcolm
This patch adds a new pragma to the C frontend that will make it emit a human-readable diagram of a struct's layout. For example, given this contrived usage: struct example { char foo : 7; char bar; char visible : 1; char active : 1; }; the compiler will emit output similar to the follo

[PATCH 1/4] c/c++: rework pragma parsing

2023-11-02 Thread David Malcolm
This patch reworks pragma parsing in c-pragma.cc, with the following improvements: - it replaces the GCC_BAD* macros (that contained "return") in favor of helper classes and functions for emitting diagnostics, making control flow more explicit - the -Wpragmas diagnostics are reworded from the for

[pushed] diagnostics: consolidate group-handling fields in diagnostic_context

2023-11-03 Thread David Malcolm
No functional change intended. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-5112-gae8abcb81ed814. gcc/ChangeLog: * diagnostic.cc (diagnostic_initialize): Update for consolidation of group-based fields. (diagnostic_report_diagnostic)

[pushed] diagnostics: convert diagnostic_context to a class

2023-11-03 Thread David Malcolm
This patch: - converts "struct diagnostic_context" to "class diagnostic_context". - ensures all data members have an "m_" prefix, except for "printer", which has so many uses that renaming would be painful. - makes most of the data members private - converts much of the diagnostic_* functions to

[pushed] diagnostics: add automatic URL-ification within messages

2023-11-03 Thread David Malcolm
On Thu, 2023-11-02 at 09:19 -0400, David Malcolm wrote: [...snip...] I eliminated the dependency on the c-pragma.cc changes from this patch, updated it for diagnostic_context becoming a class, and pushed it to trunk as r14-5118-gc5db4d8ba5f3de (after re-testing it). For reference, here's w

Re: [PATCH] diagnostics: fix gcc-urlifier.cc bootstrap failure [PR112379]

2023-11-04 Thread David Malcolm
On Sat, 2023-11-04 at 16:23 +, Sergei Trofimovich wrote: > From: Sergei Trofimovich > > Without the change `./configure --enable-checking=release` bootstrap > fails as: > >     gcc/gcc-urlifier.cc:100:1: error: > 'get_url_suffix_for_quoted_text()' >     defined but not used [-Werror=unus

[pushed 2/4] diagnostics: make diagnostic_context::m_urlifier private

2023-11-06 Thread David Malcolm
No functional change intended. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-5167-ga526cc6ff32e22. gcc/ChangeLog: * diagnostic.cc (diagnostic_context::set_urlifier): New. * diagnostic.h (diagnostic_context::set_urlifier): New decl. (

[pushed 1/4] diagnostics: eliminate diagnostic_kind_count

2023-11-06 Thread David Malcolm
No functional change intended. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-5166-g579bb65cdd35a4. gcc/ChangeLog: * diagnostic.cc (diagnostic_context::check_max_errors): Replace uses of diagnostic_kind_count with simple field acesss.

[pushed 3/4] diagnostics: introduce class diagnostic_option_classifier

2023-11-06 Thread David Malcolm
This patch gathers the 6 fields in diagnostic_context relating to keeping track of overriding the severity of warnings, and pushing/popping those severities, moving them all into a new class diagnostic_option_classifier. No functional change intended. Successfully bootstrapped & regrtested on x86

[pushed 4/4] diagnostics: split out struct diagnostic_source_printing_options

2023-11-06 Thread David Malcolm
This patch removes almost all use of diagnostic_context from the source-printing code. No functional change intended. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-5169-g54da47f9459890. gcc/ChangeLog: * diagnostic-show-locus.cc (class colorizer): T

[PATCH/RFC] libdiagnostics: a shared library for emitting diagnostics

2023-11-06 Thread David Malcolm
ot; list at the end listing various known unfinished aspects, and "known unknowns". Thoughts? David Malcolm (2): libdiagnostics: header and examples libdiagnostics: work-in-progress implementation gcc/Makefile.in | 134 +- gcc/configure

[PATCH 1/2] libdiagnostics: header and examples

2023-11-06 Thread David Malcolm
Here's a work-in-progress patch for GCC that adds a libdiagnostics.h header describing the public interface, along with various testcases that show usage examples for the API. Various aspects of this need work; posting now for early feedback on overall direction. How does the interface look? gcc

[PATCH 2/2] libdiagnostics: work-in-progress implementation

2023-11-06 Thread David Malcolm
set_line_table_global (); + diag->get_rich_location ()->add_fixit_remove (loc); +} + +/* Public entrypoint. */ + +void +diagnostic_finish (diagnostic *diag, const char *gmsgid, ...) +{ + gcc_assert (diag); + + if (const char *tool_name + = diag->get_manager ().get_client_version

Re: [wwwdocs] readings.html - "Porting GCC for Dunces" is gone

2019-11-10 Thread David Malcolm
On Sun, 2019-11-10 at 14:53 +0100, Gerald Pfeifer wrote: > Hi H-P, > > it appears this download is gone. Do you have an alternate location? > > For now I applied the patch below which disables that link in > readings.html. > > Gerald FWIW archive.org seems to have a copy here: https://web.arc

[PATCH] analyzer: fix ICE on METHOD_TYPE (PR 93212)

2020-01-09 Thread David Malcolm
PR analyzer/93212 reports an ICE when attempting to use -fanalyzer on a C++ source file. That isn't supported yet, but the fix is trivial (handling METHOD_TYPE as well as FUNCTION_TYPE). Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to the dmalcolm/analyzer branch on the G

Re: [PATCH 33/49] analyzer: new files: sm.{cc|h}

2020-01-09 Thread David Malcolm
On Wed, 2019-12-11 at 12:23 -0700, Jeff Law wrote: > On Fri, 2019-11-15 at 20:23 -0500, David Malcolm wrote: > > This patch adds a "state_machine" base class for describing > > API checkers in terms of state machine transitions. Followup > > patches use th

Re: [PATCH 43/49] analyzer: new file: exploded-graph.h

2020-01-09 Thread David Malcolm
On Wed, 2019-12-11 at 13:04 -0700, Jeff Law wrote: > On Fri, 2019-11-15 at 20:23 -0500, David Malcolm wrote: > > This patch adds exploded_graph and related classes, for managing > > exploring paths through the user's code as a directed graph > > of pai

[PATCH] testsuite: add dg-enable-nn-line-numbers (v6)

2020-01-09 Thread David Malcolm
On Wed, 2020-01-08 at 17:07 -0500, David Malcolm wrote: [...] > Here's an alterative patch to the above that replaces the > "-fdiagnostics-nn-line-numbers" option in earlier versions of the > analyzer patch kit, by doing it at the DejaGnu level instead. [...] > I'

[PATCH] Add ordered_hash_map (v6)

2020-01-09 Thread David Malcolm
On Thu, 2020-01-09 at 11:56 +, Jonathan Wakely wrote: > On 08/01/20 18:47 -0500, David Malcolm wrote: > > On Wed, 2019-12-04 at 10:59 -0700, Martin Sebor wrote: > > > On 11/15/19 6:23 PM, David Malcolm wrote: > > > > This patch adds an ordered_hash_map templat

v6 of analyzer patch kit

2020-01-09 Thread David Malcolm
On Wed, 2020-01-08 at 04:02 -0500, David Malcolm wrote: > Here's an updated version of the analyzer patch kit. I've rebased (to r280067) and applied various fixes to the kit; I've pushed a v6 of the kit to the dmalcolm/analyzer branch of the git mirror (along with various

Re: [PATCH 07/41] Add ordered_hash_map

2020-01-10 Thread David Malcolm
On Fri, 2020-01-10 at 09:22 -0700, Jeff Law wrote: > On Wed, 2020-01-08 at 04:02 -0500, David Malcolm wrote: > > Needs review. This is used in many places in the analyzer. > > msebor made some comments about the v1 version of this patch here: > > https://gcc.gnu.org/m

Re: [PATCH 29/41] analyzer: new file: sm-signal.cc

2020-01-10 Thread David Malcolm
On Fri, 2020-01-10 at 09:01 -0700, Jeff Law wrote: > On Wed, 2020-01-08 at 04:02 -0500, David Malcolm wrote: > > Needs review. > > > > Although the comments say "experimental", there are followups > > (using > > function_set) which make this much more

  1   2   3   4   5   6   7   8   9   10   >