Re: [PATCH] libgccjit: Fix get_size of size_t

2023-12-07 Thread David Malcolm
On Thu, 2023-12-07 at 17:26 -0500, Antoni Boucher wrote: > Hi. > This patch fixes getting the size of size_t (bug 112910). > > There's one issue with this patch: like every other feature that > checks > for target-specific stuff, it requires a compilation before actually > fetching the size of the

[pushed] analyzer: fix ICE for 2 bits before the start of base region [PR112889]

2023-12-07 Thread David Malcolm
Cncrete bindings were using -1 and -2 in the offset field to signify deleted and empty hash slots, but these are valid values, leading to assertion failures inside hash_map::put on a debug build, and probable bugs in a release build. (gdb) call k.dump(true) start: -2, size: 1, next: -1 (gdb) p k.

[pushed] analyzer: fix taint false positives with UNKNOWN [PR112850]

2023-12-06 Thread David Malcolm
PR analyzer/112850 reports a false positive from -Wanalyzer-tainted-allocation-size on the Linux kernel [1] where -fanalyzer complains that an allocation size is attacker-controlled despite the value being correctly sanitized against upper and lower limits. The root cause is that the expression is

Re: [PATCH] analyzer: deal with -fshort-enums

2023-12-06 Thread David Malcolm
On Wed, 2023-12-06 at 02:31 -0300, Alexandre Oliva wrote: > On Nov 22, 2023, Alexandre Oliva wrote: > > > Ah, nice, that's a great idea, I wish I'd thought of that!  Will > > do. > > Sorry it took me so long, here it is.  I added two tests, so that, > regardless of the defaults, we get both circ

[pushed] v2: diagnostics: prettify JSON output formats

2023-12-06 Thread David Malcolm
I messed up the testing of the previous version of this patch, and it turned out to have regressions. Whilst fixing them, it turned out I needed a way to disable the formatting for some test cases, so this version of the patch restricts the formatting to just the diagnostics format, and adds a -fn

[pushed] diagnostics: use const and references for diagnostic_info

2023-12-06 Thread David Malcolm
mns): Likewise. libcc1/ChangeLog: * context.cc (plugin_print_error_function): Make diagnostic_info param const. Signed-off-by: David Malcolm --- gcc/c-family/c-opts.cc| 2 +- gcc/cp/cp-tree.h | 2 +- g

Re: [PATCH] gcc/doc: spelling mistakes and example

2023-12-03 Thread David Malcolm
On Sun, 2023-12-03 at 11:59 +, Jonny Grant wrote: > > > On 03/12/2023 04:03, Xi Ruoyao wrote: > > On Sun, 2023-12-03 at 00:17 +, Jonny Grant wrote: > > > @@ -733,7 +733,7 @@ To configure GCC: > > >  @smallexample > > >  % mkdir @var{objdir} > > >  % cd @var{objdir} > > > -% @var{srcdir}/c

Re: [PATCH] libgccjit: Fix GGC segfault when using -flto

2023-12-01 Thread David Malcolm
On Thu, 2023-11-30 at 17:13 -0500, Antoni Boucher wrote: > Here's the updated patch. > The failure was due to the test being in the test array while it > should > not have been there since it changes the context. Thanks for the updated patch. Did you do a full bootstrap and regression test with t

Re: [PATCH] libgccjit: Add support for the type bfloat16

2023-12-01 Thread David Malcolm
On Thu, 2023-11-16 at 17:20 -0500, Antoni Boucher wrote: > I forgot to attach the patch. > > On Thu, 2023-11-16 at 17:19 -0500, Antoni Boucher wrote: > > Hi. > > This patch adds the support for the type bfloat16 (bug 112574). > > > > This was asked to be splitted from a another patch sent here: >

[pushed] diagnostics, analyzer: add optional per-diagnostic property bags to SARIF

2023-12-01 Thread David Malcolm
I've found it useful in debugging the analyzer for the SARIF output to contain extra analyzer-specific data in each diagnostic. This patch: * adds a way for a diagnostic_metadata to populate a property bag within a SARIF "result" object based on a new vfunc * reworks how diagnostics are emitted wi

[pushed] docs: remove stray reference to -fanalyzer-checker=taint [PR103533]

2023-12-01 Thread David Malcolm
I missed this one in r14-5464-gcfaaa8b11b8429. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-6056-g83b210d55b2846. gcc/ChangeLog: PR analyzer/103533 * doc/extend.texi: Remove stray reference to -fanalyzer-checker=taint. --- gcc/doc/

[pushed] analyzer: install header files for use by plugins [PR109077]

2023-11-28 Thread David Malcolm
PLUGIN_ANALYZER_INIT was added in r11-5583-g66dde7bc64b75d, but we haven't been installing the analyzer's headers files. Fixed thusly. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. I compared the before/after results of "make install" and confirmed that it now installs the analyz

Re: [PATCH 5/5] diagnostics: don't print annotation lines when there's no column info

2023-11-27 Thread David Malcolm
On Tue, 2023-11-21 at 17:20 -0500, David Malcolm wrote: > gcc/ChangeLog: > * diagnostic-show-locus.cc > (layout::maybe_add_location_range): > Don't print annotation lines for ranges when there's no > column > info. > (selftest:

Re: [PATCH 4/5] diagnostics: add diagnostic_context::get_location_text

2023-11-27 Thread David Malcolm
On Tue, 2023-11-21 at 17:20 -0500, David Malcolm wrote: > No functional change intended. > > gcc/ChangeLog: > * diagnostic.cc (diagnostic_get_location_text): Convert to... > (diagnostic_context::get_location_text): ...this, and convert > return t

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

2023-11-21 Thread David Malcolm
nostic_add_fix_it_hint_delete (diagnostic *diag, + const diagnostic_physical_location *loc) +{ + gcc_assert (diag); + diag->get_manager ().assert_valid_diagnostic_physical_location (loc); + + diag->get_manager ().set_line_table_global (); + diag-&

[PATCH] binutils: v2: experimental use of libdiagnostics in gas

2023-11-21 Thread David Malcolm
Changed in v2: * updated for change from diagnostic_location_t to const diagnostic_physical_location * * fix #if USE_DIAGNOSTICS to retain context and listing code Output from the example below with v2 is now: testsuite/gas/all/warn-1.s:3: warning: a warning message 3 | .warning "a warning

[PATCH 4/5] diagnostics: add diagnostic_context::get_location_text

2023-11-21 Thread David Malcolm
No functional change intended. gcc/ChangeLog: * diagnostic.cc (diagnostic_get_location_text): Convert to... (diagnostic_context::get_location_text): ...this, and convert return type from char * to label_text. (diagnostic_build_prefix): Update for above change.

[PATCH 1/5] libdiagnostics v2: header and examples

2023-11-21 Thread David Malcolm
Changed in v2: * Changed from diagnostic_location_t -> const diagnostic_physical_location * * Add entrypoint: diagnostic_finish_va * add new type diagnostic_text_sink, and new entrypoints for enabling/disabling options on it * add new debugging entrypoints for dumping objects to a FILE * * new te

[PATCH 3/5] libdiagnostics v2: add C++ wrapper API

2023-11-21 Thread David Malcolm
This is new in v2: a C++ wrapper API that provides some syntactic sugar for calling into libdiagnostics.{h,so}. I've been "eating my own dogfood" with this by using it to write a simple client that reads a SARIF file and dumps it using the text sink: https://github.com/davidmalcolm/libdiagnostic

[PATCH 5/5] diagnostics: don't print annotation lines when there's no column info

2023-11-21 Thread David Malcolm
gcc/ChangeLog: * diagnostic-show-locus.cc (layout::maybe_add_location_range): Don't print annotation lines for ranges when there's no column info. (selftest::test_one_liner_no_column): New. (selftest::test_diagnostic_show_locus_one_liner): Call it. --- gcc/d

[PATCH 0/6] v2 of libdiagnostics

2023-11-21 Thread David Malcolm
scussed in: https://gcc.gnu.org/pipermail/gcc-patches/2023-November/635575.html Patch 6 (for binutils) is an updated version of the experiment at using the API from gas. Thoughts? David Malcolm (5): libdiagnostics v2: header and examples libdiagnostics v2: work-in-progress implementa

Re: [PATCH 0/4] v2 of Option handling: add documentation URLs

2023-11-21 Thread David Malcolm
On Tue, 2023-11-21 at 15:12 +0100, Tobias Burnus wrote: > On 21.11.23 14:57, David Malcolm wrote: > > On Tue, 2023-11-21 at 02:09 +0100, Hans-Peter Nilsson wrote: > > > Sorry for barging in though I did try finding the relevant > > > discussion, but is committing thi

Re: [PATCH 0/4] v2 of Option handling: add documentation URLs

2023-11-21 Thread David Malcolm
On Tue, 2023-11-21 at 02:09 +0100, Hans-Peter Nilsson wrote: > > From: David Malcolm > > Date: Thu, 16 Nov 2023 09:28:54 -0500 > > > How is this looking for trunk? > > > > Thanks > > Dave > > > > > > David Malcolm (4): > >

Re: [PATCH] libgccjit Fix a RTL bug for libgccjit

2023-11-20 Thread David Malcolm
On Mon, 2023-11-20 at 16:38 -0700, Jeff Law wrote: > > > On 11/20/23 15:46, David Malcolm wrote: > > On Fri, 2023-11-17 at 14:09 -0700, Jeff Law wrote: > > > > > > > > > On 11/17/23 14:08, Antoni Boucher wrote: > > > > In contra

Re: [PATCH] libgccjit: Add ways to set the personality function

2023-11-20 Thread David Malcolm
On Fri, 2023-11-17 at 17:48 -0500, Antoni Boucher wrote: > Hi. > This adds functions to set the personality function (bug 112603). > > I'm not sure I can make a test for this: it seems the personality > function will not be set if there are no try/catch inside the > functions. > Do you know a way

Re: [PATCH] libgccjit: Add vector permutation and vector access operations

2023-11-20 Thread David Malcolm
On Fri, 2023-11-17 at 17:36 -0500, Antoni Boucher wrote: > Hi. > This patch adds a vector permutation and vector access operations > (bug > 112602). > > This was split from this patch: > https://gcc.gnu.org/pipermail/jit/2023q1/001606.html > Thanks for the patch. Overall, looks good, but 3 mino

Re: [PATCH] libgccjit Fix a RTL bug for libgccjit

2023-11-20 Thread David Malcolm
On Fri, 2023-11-17 at 14:09 -0700, Jeff Law wrote: > > > On 11/17/23 14:08, Antoni Boucher wrote: > > In contrast with the other frontends, libgccjit can be executed > > multiple times in a row in the same process. > Yup.  I'm aware of that.  Even so calling init_emit_once more than > one > time

Re: [PATCH] analyzer: deal with -fshort-enums

2023-11-20 Thread David Malcolm
On Sun, 2023-11-19 at 04:39 -0300, Alexandre Oliva wrote: > > On platforms that enable -fshort-enums by default, various switch- > enum > analyzer tests fail, because apply_constraints_for_gswitch doesn't > expect the integral promotion type cast.  I've arranged for the code > to cope with those c

Re: [PATCH] testsuite: analyzer: expect alignment warning with -fshort-enums

2023-11-20 Thread David Malcolm
On Sun, 2023-11-19 at 08:13 -0700, Jeff Law wrote: > > > On 11/19/23 00:36, Alexandre Oliva wrote: > > > > On targets that have -fshort-enums enabled by default, the type > > casts > > in the pr108251 analyzer tests warn that the byte-aligned enums may > > not be sufficiently aligned to be a str

[pushed] libcpp: split decls out to rich-location.h

2023-11-19 Thread David Malcolm
The various decls relating to rich_location are in libcpp/include/line-map.h, but they don't relate to line maps. Split them out to their own header: libcpp/include/rich-location.h No functional change intended. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r1

[pushed] analyzer: new warning: -Wanalyzer-undefined-behavior-strtok [PR107573]

2023-11-18 Thread David Malcolm
Log: PR analyzer/107573 * c-c++-common/analyzer/strtok-1.c: New test. * c-c++-common/analyzer/strtok-2.c: New test. * c-c++-common/analyzer/strtok-3.c: New test. * c-c++-common/analyzer/strtok-4.c: New test. * c-c++-common/analyzer/strtok-cppreferenc

[pushed] analyzer: new warning: -Wanalyzer-infinite-loop [PR106147]

2023-11-17 Thread David Malcolm
s feasibility_state public: feasibility_state (region_model_manager *manager, const supergraph &sg); + feasibility_state (const region_model &model, +const supergraph &sg); feasibility_state (const feasibility_state &other); + feasi

[PATCH 3/4] opts: add logic to generate options-urls.cc

2023-11-16 Thread David Malcolm
Changed in v2: - split out from the code that uses this - now handles lang-specific URLs, as well as generic URLs - the generated options-urls.cc now contains a function with a switch statement, rather than an array, to support lang-specific URLs: const char * get_opt_url_suffix (int option_in

[PATCH 4/4] options: wire up options-urls.cc into gcc_urlifier

2023-11-16 Thread David Malcolm
Changed in v2: - split out from the code that generates options-urls.cc - call the generated function, rather than use a generated array - pass around lang_mask gcc/ChangeLog: * diagnostic.h (diagnostic_make_option_url_cb): Add lang_mask param. (diagnostic_context::make_opt

[PATCH 0/4] v2 of Option handling: add documentation URLs

2023-11-16 Thread David Malcolm
On Wed, 2023-11-15 at 23:40 +, Joseph Myers wrote: > On Wed, 15 Nov 2023, David Malcolm wrote: > > > As mentioned, I'm currently investigating capturing per-language > > option > > URLs (to address Iain's and Marc's comments about D and Ada); if I > &

[PATCH 1/4] options: add gcc/regenerate-opt-urls.py

2023-11-16 Thread David Malcolm
Changed in v2: - added convenience targets to Makefile for regenerating the .opt.urls files, and for running unit tests for the generation code - parse gdc and gfortran documentation, and create LangUrlSuffix_{lang} directives for language-specific URLs. - add documentation to sourcebuild.texi g

[pushed] diagnostics: make m_lang_mask private

2023-11-16 Thread David Malcolm
No functional change intended. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-5530-g4547c271c455dc. gcc/ChangeLog: * diagnostic.cc (diagnostic_context::set_option_hooks): Add "lang_mask" param. * diagnostic.h (diagnostic_context::opti

Re: [PATCH 0/3] Option handling: add documentation URLs

2023-11-15 Thread David Malcolm
On Tue, 2023-11-14 at 00:12 +, Joseph Myers wrote: > On Fri, 10 Nov 2023, David Malcolm wrote: > > > The .opt.urls files it generates become part of the source tree, > > and > > would be regenerated by maintainers whenever new options are added. > > Forgetti

[PATCH/RFC] json.cc: format JSON output

2023-11-14 Thread David Malcolm
Previously our JSON output emitted the JSON all on one line, with no indentation or newlines to show the structure of the values. Although it's easy to reformat such output (e.g. with "python -m json.tool"), I've found it's a pain to need to do so e.g. my text editor sometimes hangs when opening a

[pushed] json.cc: use SELFTEST_LOCATION in selftests

2023-11-14 Thread David Malcolm
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-5473-g2220263f0e032a. gcc/ChangeLog: * json.cc (selftest::assert_print_eq): Add "loc" param and use ASSERT_STREQ_AT. (ASSERT_PRINT_EQ): New macro. (selftest::test_writing_objects):

[pushed] analyzer: enable taint state machine by default [PR103533]

2023-11-14 Thread David Malcolm
-2011-0521-6.c: Likewise. * gcc.dg/plugin/taint-antipatterns-1.c: : Remove use of -fanalyzer-checker=taint. Signed-off-by: David Malcolm --- gcc/analyzer/sm-taint.cc | 2 +- gcc/analyzer/sm.cc| 5 +- gcc/d

[pushed] diagnostics: make option-handling callbacks private

2023-11-14 Thread David Malcolm
No functional change intended. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-5459-g353f146cebbf22. gcc/c-family/ChangeLog: * c-warn.cc (conversion_warning): Update call to global_dc->m_option_enabled to use option_enabled_p. gcc/cp/ChangeLo

[pushed] diagnostics: make m_text_callbacks private

2023-11-14 Thread David Malcolm
No functional change intended. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-5458-g07e568d77f364e. gcc/ChangeLog: * diagnostic-show-locus.cc (diagnostic_context::show_locus): Update for renaming of text callbacks fields. * diagnostic

[pushed] diagnostics: convert diagnostic_ready_p to an inline function

2023-11-14 Thread David Malcolm
No functional change intended. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-5457-gd0bfd6ba3ba77f. gcc/ChangeLog: * diagnostic.h (diagnostic_ready_p): Convert from macro to inline function. --- gcc/diagnostic.h | 6 +- 1 file changed, 5

[pushed] input.h: eliminate implicit users of global_dc's file_cache

2023-11-14 Thread David Malcolm
This patch eliminates the following functions that implicitly used global_dc's file cache: extern char_span location_get_source_line (const char *file_path, int line); extern char_span get_source_file_content (const char *file_path); extern bool location_missing_trailing_newline (const char

[pushed] json: reduce use of naked new in json-building code

2023-11-14 Thread David Malcolm
No functional change intended. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-5451-g070944fdd6394c gcc/ChangeLog: * diagnostic-format-json.cc: Use type-specific "set_*" functions of json::object to avoid naked new of json value subclasses.

Re: [PATCH 2/3] Add generated .opt.urls files

2023-11-13 Thread David Malcolm
On Sun, 2023-11-12 at 11:56 +0100, Iain Buclaw wrote: > Excerpts from David Malcolm's message of November 10, 2023 10:42 pm: > > gcc/d/ChangeLog: > > * lang.opt.urls: New file, autogenerated by > > regenerate-opt-urls.py. > > --- > >  gcc/d/lang.opt.urls  |  

Re: [PATCH 2/3] Add generated .opt.urls files

2023-11-13 Thread David Malcolm
On Mon, 2023-11-13 at 14:11 +0100, Marc Poulhiès wrote: > > David Malcolm writes: > > > gcc/ada/ChangeLog: > > * gcc-interface/lang.opt.urls: New file, autogenerated by > > regenerate-opt-urls.py. > > > > diff --git a/gcc/ada/gc

Re: [PATCH] libgccjit: Fix GGC segfault when using -flto

2023-11-12 Thread David Malcolm
On Fri, 2023-11-10 at 18:14 -0500, David Malcolm wrote: > On Fri, 2023-11-10 at 11:02 -0500, Antoni Boucher wrote: > > Hi. > > This patch fixes the segfault when using -flto with libgccjit (bug > > 111396). > > > > You mentioned in bugzilla that this didn

Re: [PATCH] libgccjit: Fix GGC segfault when using -flto

2023-11-10 Thread David Malcolm
On Fri, 2023-11-10 at 11:02 -0500, Antoni Boucher wrote: > Hi. > This patch fixes the segfault when using -flto with libgccjit (bug > 111396). > > You mentioned in bugzilla that this didn't fix the reproducer for > you, Rereading https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111396 it looks like a

[PATCH 1/3] options: add gcc/regenerate-opt-urls.py

2023-11-10 Thread David Malcolm
gcc/ChangeLog: * doc/options.texi (Option properties): Add UrlSuffix and description of regenerate-opt-urls.py. * regenerate-opt-urls.py: New file. --- gcc/doc/options.texi | 17 ++ gcc/regenerate-opt-urls.py | 366 + 2 files chang

[PATCH 3/3] diagnostics: use the .opt.urls files to urlify quoted text

2023-11-10 Thread David Malcolm
This patch adds machinery for using the .opt.urls files linking to the documentation of our options in gcc_urlifier. For every enabled .opt file, the corresponding .opt.urls file will also be used when constructing the "optionslist" file. The patch adds a new awk script to process the optionslist

[PATCH 0/3] Option handling: add documentation URLs

2023-11-10 Thread David Malcolm
red", [...snip...] }; and this is then used by the gcc_urlifier class when emitting diagnostics. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. OK for trunk? David Malcolm (3): options: add gcc/regenerate-opt-urls.py Add generated .opt.urls files diagnostics: use

Re: [PATCH] libgccjit: Add ability to get CPU features

2023-11-09 Thread David Malcolm
On Thu, 2023-11-09 at 17:27 -0500, Antoni Boucher wrote: > Hi. > This patch adds support for getting the CPU features in libgccjit > (bug > 112466) > > There's a TODO in the test: > I'm not sure how to test that gcc_jit_target_info_arch returns the > correct value since it is dependant on the CPU.

[pushed] diagnostics: cleanups to diagnostic-show-locus.cc

2023-11-09 Thread David Malcolm
Reduce implicit usage of line_table global, and move source printing to within diagnostic_context. No functional change intended. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-5300-g8625aa24669669. gcc/ChangeLog: * diagnostic-show-locus.cc (layout:

Re: [PATCH] Add missing declaration of get_restrict in C++ interface

2023-11-09 Thread David Malcolm
On Thu, 2023-11-09 at 21:51 +0100, Guillaume Gomez wrote: > I confirm it does. I realized it when finalizing our patch for > attributes support. Excellent; thanks for the fix. Dave

Re: [PATCH] Add missing declaration of get_restrict in C++ interface

2023-11-09 Thread David Malcolm
On Thu, 2023-11-09 at 21:03 +0100, Guillaume Gomez wrote: > Hi, > > This patch adds the `get_restrict` method declaration for > the C++ interface as it was forgotten. > > Thanks in advance for the review. Looking at my jit.sum results, it looks like the .cc files are indeed FAILing on initial co

Re: [PATCH 1/2] libdiagnostics: header and examples

2023-11-07 Thread David Malcolm
On Tue, 2023-11-07 at 19:02 -0500, Lewis Hyatt wrote: > On Mon, Nov 6, 2023 at 8:29 PM David Malcolm > wrote: > > > > Here's a work-in-progress patch for GCC that adds a > > libdiagnostics.h > > header describing the public interface, along with various > &g

Re: [PATCH] binutils: experimental use of libdiagnostics in gas

2023-11-07 Thread David Malcolm
On Tue, 2023-11-07 at 16:57 +0100, Clément Chigot wrote: > > > However, I'm not sure how you're planning to make the transition. > > > But > > > currently, it looks like libdiagnostics is either enabled and > > > thus > > > the > > > new format being produced, either it's not and we do have the > >

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

2023-11-07 Thread David Malcolm
On Tue, 2023-11-07 at 08:54 +0100, Simon Sobisch wrote: > Thank you for our work and providing this patch. > > GCC related questions: > > Is it planned to change GCC diagnostics to use libdiagnostic itself? No. GCC uses C++ internally, and the internal diagnostic API is written in C++. libdiagn

Re: [PATCH] binutils: experimental use of libdiagnostics in gas

2023-11-07 Thread David Malcolm
On Tue, 2023-11-07 at 08:04 +0100, Simon Sobisch wrote: > Thank you very much for this proof-of-concept use! > > Inspecting it raises the following questions to me, both for a > possible > binutils implementation and for the library use in general: > > * How should the application set the releva

Re: [PATCH] binutils: experimental use of libdiagnostics in gas

2023-11-07 Thread David Malcolm
On Tue, 2023-11-07 at 11:03 +0100, Jan Beulich wrote: > On 06.11.2023 23:29, David Malcolm wrote: > > Here's a patch for gas in binutils that makes it use libdiagnostics > > (with some nasty hardcoded paths to specific places on my hard > > drive > > to m

Re: [PATCH] binutils: experimental use of libdiagnostics in gas

2023-11-07 Thread David Malcolm
On Tue, 2023-11-07 at 10:21 +0100, Clément Chigot wrote: > Hi David, > > Thanks for that interesting RFC ! I'm fully in favor of such > improvements, having uniformed error messages across gcc, gas and > later ld, would greatly help integration of these tools, let alone > the > SARIF format output

[PATCH] binutils: experimental use of libdiagnostics in gas

2023-11-06 Thread David Malcolm
Here's a patch for gas in binutils that makes it use libdiagnostics (with some nasty hardcoded paths to specific places on my hard drive to make it easier to develop the API). For now this hardcodes adding two sinks: a text sink on stderr, and also a SARIF output to stderr (which happens after all

[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

[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/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

[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

[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 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 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. (

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] 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

[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: 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)

[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

[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 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/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

[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"

[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] 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] 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] 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

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

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: [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 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] 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: [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

[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

[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

[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

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"

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

[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

[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_}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] 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 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

<    1   2   3   4   5   6   7   8   9   10   >