[pushed] analyzer: support diagnostics that don't have a stmt

2023-09-15 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-4042-gb09193fb0686b7. gcc/analyzer/ChangeLog: * analyzer.cc (get_stmt_location): Handle null stmt. * diagnostic-manager.cc (saved_diagnostic::saved_diagnostic): Copy m_loc from ploc.

[pushed] analyzer: introduce pending_location

2023-09-15 Thread David Malcolm via Gcc-patches
No functional change intended. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-4041-g759a1a52ea615d. gcc/analyzer/ChangeLog: * analyzer.h (struct pending_location): New forward decl. * diagnostic-manager.cc

[pushed] analyzer: handle volatile ops

2023-09-15 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-4040-g6319b5b2d46690. gcc/analyzer/ChangeLog: * region-model.cc (region_model::get_gassign_result): Handle volatile ops by using a conjured_svalue. gcc/testsuite/ChangeLog: *

[pushed] diagnostics: support multithreaded diagnostic paths

2023-09-14 Thread David Malcolm via Gcc-patches
This patch extends the existing diagnostic_path class so that as well as list of events, there is a list of named threads, with each event being associated with one of the threads. No GCC diagnostics take advantage of this, but GCC plugins may find a use for this; an example is provided in the

[pushed] analyzer: fix missing return in compatible_epath_p

2023-09-14 Thread David Malcolm via Gcc-patches
On Mon, 2023-09-11 at 10:23 +0200, Andreas Schwab via Gcc-patches wrote: > ../../gcc/analyzer/diagnostic-manager.cc: In function 'bool > ana::compatible_epath_p(const exploded_path*, const exploded_path*)': > ../../gcc/analyzer/diagnostic-manager.cc:969:1: warning: control reaches end > of

Re: [PATCH] ggc, jit: forcibly clear GTY roots in jit

2023-09-14 Thread David Malcolm via Gcc-patches
On Tue, 2023-09-12 at 15:20 -0400, Antoni Boucher wrote: FWIW I've pushed the "ggc, jit: forcibly clear GTY roots in jit" to trunk after retesting it, as r14-4003-geaa8e8541349df. > I added it to bugzilla here: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111396 I don't yet have a fix for

[pushed] analyzer: use unique_ptr for rejected_constraint

2023-09-14 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-4004-g8878f7ab1cb9ed. gcc/analyzer/ChangeLog: * diagnostic-manager.cc (process_worklist_item): Use std::unique_ptr rather than plain rejected_constraint *. * engine.cc

Re: [WIP RFC] analyzer: Move gcc.dg/analyzer tests to c-c++-common (3) [PR96395]

2023-09-13 Thread David Malcolm via Gcc-patches
On Mon, 2023-09-11 at 19:44 +0200, priour...@gmail.com wrote: > From: benjamin priour > > Hi, > > Patch below is mostly done, just have to check the formatting. > Althought, I'd like your feedback on how to manage named_constants > from enum in C++. > > I've checked and the analyzer works as

Re: [PATCH] testsuite work-around compound-assignment-1.c C++ failures on various targets [PR111377]

2023-09-13 Thread David Malcolm via Gcc-patches
On Tue, 2023-09-12 at 09:02 +0200, Jakub Jelinek wrote: > On Mon, Sep 11, 2023 at 11:11:30PM +0200, Jakub Jelinek via Gcc- > patches wrote: > > On Mon, Sep 11, 2023 at 07:27:57PM +0200, Benjamin Priour via Gcc- > > patches wrote: > > > Thanks for the report, > > > > > > After investigation it

Re: [PATCH] ggc, jit: forcibly clear GTY roots in jit

2023-09-12 Thread David Malcolm via Gcc-patches
On Tue, 2023-09-12 at 13:36 -0400, Antoni Boucher wrote: > In the mean time, here's a (Rust) reproducer for the issue: > > fn main() { >     for _ in 0..5 { >     let context = Context::default(); >     context.add_command_line_option("-flto"); >     >

Re: [PATCH] analyzer: implement symbolic value support for CPython plugin's refcnt checker [PR107646]

2023-09-11 Thread David Malcolm via Gcc-patches
On Sun, 2023-09-10 at 22:12 -0400, Eric Feng wrote: > On Thu, Sep 7, 2023 at 1:28 PM David Malcolm > wrote: > > > On Mon, 2023-09-04 at 22:13 -0400, Eric Feng wrote: > > [...snip...] > > > > > > I know you're emulating the old behavior I implemented way back in > > cpychecker, but I don't

Re: [PATH] [CLEANUP] Remove trailing whitespace characters

2023-09-11 Thread David Malcolm via Gcc-patches
On Sun, 2023-09-10 at 16:36 +0200, Guillaume Gomez wrote: > When going through the code, I saw a lot of trailing whitespace > characters so I decided to write a small script that would remove > them. I didn't expect there would be so many though... Not sure if > patch with so many changes are

Re: [Patch] OpenMP (C only): omp allocate - extend parsing support, improve diagnostic (was: [Patch] OpenMP (C only): omp allocate - handle stack vars, improve diagnostic)

2023-09-11 Thread David Malcolm via Gcc-patches
On Mon, 2023-09-11 at 13:54 +0200, Jakub Jelinek wrote: > Hi! > > One question to David below, CCed. > > On Mon, Sep 11, 2023 at 01:44:07PM +0200, Tobias Burnus wrote: [...] > > > + > > + if (DECL_SOURCE_LOCATION (allocator) > > > DECL_SOURCE_LOCATION (var)) > > +   { > > +

[pushed] analyzer: basic support for computed gotos (PR analyzer/110529)

2023-09-07 Thread David Malcolm via Gcc-patches
PR analyzer/110529 notes that -fanalyzer was giving up on execution paths that follow a computed goto, due to ignoring CFG edges with the flag EDGE_ABNORMAL set. This patch implements enough handling for them to allow analysis of such execution paths to continue. Successfully bootstrapped &

[pushed] analyzer: fix -Wunused-parameter warnings

2023-09-07 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-3793-g18f1f79ec5b1f1. gcc/analyzer/ChangeLog: * region-model.h: fix -Wunused-parameter warnings --- gcc/analyzer/region-model.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git

Re: [PATCH] analyzer: implement symbolic value support for CPython plugin's refcnt checker [PR107646]

2023-09-07 Thread David Malcolm via Gcc-patches
On Mon, 2023-09-04 at 22:13 -0400, Eric Feng wrote: > Hi Dave, Hi Eric, thanks for the patch. > > Recently I've been working on symbolic value support for the reference > count checker. I've attached a patch for it below; let me know it looks > OK for trunk. Thanks! > > Best, > Eric > > ---

Re: [PATCH v2] analyzer: Call off a superseding when diagnostics are unrelated [PR110830]

2023-09-06 Thread David Malcolm via Gcc-patches
On Wed, 2023-09-06 at 21:16 +0200, priour...@gmail.com wrote: [...snip...] > Signed-off-by: benjamin priour > Co-authored-by: david malcolm Please also add: Signed-off-by: David Malcolm [...snip...] > > +static bool > +compatible_epath_p (const exploded_path *lhs_path, > +  

Re: [PATCH] analyzer: Move gcc.dg/analyzer tests to c-c++-common (2) [PR96395]

2023-09-06 Thread David Malcolm via Gcc-patches
On Wed, 2023-09-06 at 15:50 +0200, Benjamin Priour wrote: > Hi David, > Thanks for the review. > > > > On Tue, Sep 5, 2023 at 1:53 PM David Malcolm > wrote: > > > On Mon, 2023-09-04 at 20:00 +0200, priour...@gmail.com wrote: > > > > > [...snip...] > > > > All of these "new" tests (apart

Re: [PATCH 2/2] Experiment with adding an error code to an error

2023-09-06 Thread David Malcolm via Gcc-patches
On Wed, 2023-09-06 at 15:53 +0200, Arthur Cohen wrote: > From: David Malcolm This is probably something for the gcc-rust maintainers to review (rather than me self-reviewing with my "diagnostics maintainer" hat on). Doesn't have a ChangeLog entry, FWIW. Doesn't have a signed-off-by, so here's

Re: [PATCH 1/2] diagnostics: add error_meta

2023-09-06 Thread David Malcolm via Gcc-patches
On Wed, 2023-09-06 at 15:53 +0200, Arthur Cohen wrote: > From: David Malcolm I guess I can review this patch :) Needs a ChangeLog entry, so here's one: gcc/ChangeLog * diagnostic-core.h (error_meta): New decl. * diagnostic.cc (error_meta): New. Also, needs a signed-off-by, so

[pushed] analyzer: implement kf_strstr [PR105899]

2023-09-06 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-3741-gf2d7a4001a3388. gcc/analyzer/ChangeLog: PR analyzer/105899 * kf.cc (class kf_strstr): New. (kf_strstr::impl_call_post): New. (register_known_functions): Register it.

[pushed] analyzer: implement kf_strncpy [PR105899]

2023-09-06 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-3740-gb51cde34d4e750. gcc/analyzer/ChangeLog: PR analyzer/105899 * kf.cc (class kf_strncpy): New. (kf_strncpy::impl_call_post): New. (register_known_functions): Register it.

[pushed] analyzer: add ctxt to fill_region/zero_fill_region

2023-09-06 Thread David Malcolm via Gcc-patches
I noticed that region_model's fill_region/zero_fill_region member functions weren't checking that the write to the region was valid. Fixed thusly. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-3739-gb923978a6ec447. gcc/analyzer/ChangeLog: * kf.cc

[PATCH] ggc, jit: forcibly clear GTY roots in jit

2023-09-06 Thread David Malcolm via Gcc-patches
As part of Antoyo's work on supporting LTO in rustc_codegen_gcc, he noticed an ICE inside libgccjit when compiling certain rust files. Debugging libgccjit showed that outdated information from a previous in-memory compile was referring to ad-hoc locations in the previous compile's line_table.

Re: [PATCH] analyzer: Move gcc.dg/analyzer tests to c-c++-common (2) [PR96395]

2023-09-05 Thread David Malcolm via Gcc-patches
On Mon, 2023-09-04 at 20:00 +0200, priour...@gmail.com wrote: > Hi, > > The second patch of this serie. > Regstrapped on x86_64-linux-gnu off trunk > a7d052b3200c7928d903a0242b8cfd75d131e374. Thanks for the patch. Overall, looks like great work, but there are a few nitpicks to be fixed, see

Re: [PATCH] diagnostics: Delete config pointer before overwriting it.

2023-09-01 Thread David Malcolm via Gcc-patches
On Fri, 2023-09-01 at 21:16 +0200, Mikael Morin via Gcc-patches wrote: > Hello, > > this is a fix for a small memory leak in the fortran frontend. > Tested on x86_64-pc-linux-gnu, nothing stands out besides the > apparently well-known guality instability. > OK for master ? LGTM, thanks! Dave

Re: [PATCH] analyzer: call off a superseding when diagnostics are unrelated [PR110830]

2023-09-01 Thread David Malcolm via Gcc-patches
On Fri, 2023-09-01 at 21:59 +0200, priour...@gmail.com wrote: > From: benjamin priour > > Hi, > > Patch succesfully regstrapped off trunk > 7f2ed06ddc825e8a4e0edfd1d66b5156e6dc1d34 > on x86_64-linux-gnu. > > Is it OK for trunk ? > > Thanks, > Benjamin. > [...snip...] >   > +/* Walk up the

Re: [PATCH] analyzer: Add support of placement new and improved operator new [PR105948,PR94355]

2023-09-01 Thread David Malcolm via Gcc-patches
On Fri, 2023-09-01 at 16:48 +0200, Benjamin Priour wrote: > Patch has been updated as per your suggestions and successfully > regstrapped > on x86_64-linux-gnu. > > call_details::maybe_get_arg_region is now > /* If argument IDX's svalue at the callsite is of pointer type, >     return the region

Re: [PATCH] analyzer: implement reference count checking for CPython plugin [PR107646]

2023-09-01 Thread David Malcolm via Gcc-patches
On Fri, 2023-09-01 at 04:49 +0200, Hans-Peter Nilsson wrote: > (Looks like this was committed as r14-3580-g597b9ec69bca8a) > > > Cc: g...@gcc.gnu.org, gcc-patches@gcc.gnu.org, Eric Feng > > > > From: Eric Feng via Gcc > > > gcc/testsuite/ChangeLog: > >   PR analyzer/107646 > > *

Re: [PATCH] analyzer: Add support of placement new and improved operator new [PR105948,PR94355]

2023-08-31 Thread David Malcolm via Gcc-patches
On Fri, 2023-09-01 at 00:04 +0200, priour...@gmail.com wrote: > Hi, > > Succesfully regstrapped off trunk 7f2ed06ddc825e8a4e0edfd1d66b5156e6dc1d34 > on x86_64-linux-gnu. > > Is it OK for trunk ? Hi Benjamin. Thanks for the patch. It's OK as-is, but it doesn't cover every case...

Re: [PATCH] analyzer: implement reference count checking for CPython plugin [PR107646]

2023-08-31 Thread David Malcolm via Gcc-patches
On Wed, 2023-08-30 at 18:15 -0400, Eric Feng wrote: > On Tue, Aug 29, 2023 at 5:14 PM David Malcolm > wrote: > > > > On Tue, 2023-08-29 at 13:28 -0400, Eric Feng wrote: > > > Additionally, by using the old model and the pointer per your > > > suggestion, > > > we are able to find the

Re: Analyzer failure due to missing header

2023-08-30 Thread David Malcolm via Gcc-patches
On Wed, 2023-08-30 at 23:24 +0200, FX Coudert wrote: > > std::max and std::min, introduced by d99d73c77d1e and 2bad0eeb5573, > > are not available because is not included. > > I originally thought this was only seen in cross-compilers, but it > actually broke bootstrap on darwin. > Attached

Re: [pushed] analyzer: fix ICE in text art strings support

2023-08-30 Thread David Malcolm via Gcc-patches
On Wed, 2023-08-30 at 11:52 +0530, Prathamesh Kulkarni wrote: > On Wed, 30 Aug 2023 at 04:21, David Malcolm > wrote: > > > > On Tue, 2023-08-29 at 11:01 +0530, Prathamesh Kulkarni wrote: > > > On Fri, 25 Aug 2023 at 18:15, David Malcolm via Gcc-patches > > >

Re: [pushed] analyzer: fix ICE in text art strings support

2023-08-29 Thread David Malcolm via Gcc-patches
On Tue, 2023-08-29 at 11:01 +0530, Prathamesh Kulkarni wrote: > On Fri, 25 Aug 2023 at 18:15, David Malcolm via Gcc-patches > wrote: > > > > Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. > > Pushed to trunk as r14-3481-g99a3fcb8ff0bf2. > Hi David

[pushed] analyzer: new warning: -Wanalyzer-overlapping-buffers [PR99860]

2023-08-29 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-3556-g034d99e81484fb. gcc/ChangeLog: PR analyzer/99860 * Makefile.in (ANALYZER_OBJS): Add analyzer/ranges.o. gcc/analyzer/ChangeLog: PR analyzer/99860 * analyzer-selftests.cc

Re: [PATCH] analyzer: implement reference count checking for CPython plugin [PR107646]

2023-08-29 Thread David Malcolm via Gcc-patches
On Tue, 2023-08-29 at 13:28 -0400, Eric Feng wrote: > Additionally, by using the old model and the pointer per your > suggestion, > we are able to find the representative tree and emit a more accurate > diagnostic! > > rc3.c:23:10: warning: expected ‘item’ to have reference count: ‘1’ > but

Re: [PATCH] analyzer: implement reference count checking for CPython plugin [PR107646]

2023-08-29 Thread David Malcolm via Gcc-patches
On Tue, 2023-08-29 at 00:31 -0400, Eric Feng wrote: > Hi Dave, Hi Eric. Thanks for the updated patch. A few nits below; this is OK for trunk with them fixed... [...snip...] > > gcc/analyzer/ChangeLog: > PR analyzer/107646 > * engine.cc (impl_region_model_context::warn): New optional

Re: [PATCH] libgccjit: Add support for `restrict` attribute on function parameters

2023-08-29 Thread David Malcolm via Gcc-patches
On Tue, 2023-08-29 at 17:15 +0200, Guillaume Gomez wrote: > We finished the investigation and found out the issue: when passing > arguments by value to functions, rustc still provides "NoAlias" as > attribute to the argument whereas it should never be passed in this > case. Luckily for us, in case

[pushed] analyzer: improve strdup handling [PR105899]

2023-08-29 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-3549-gf687fc1ff6d4a4. gcc/analyzer/ChangeLog: PR analyzer/105899 * kf.cc (kf_strdup::impl_call_pre): Set size of dynamically-allocated buffer. Simulate copying the string from

Re: [PATCH v2] analyzer: Move gcc.dg/analyzer tests to c-c++-common (1) [PR96395]

2023-08-26 Thread David Malcolm via Gcc-patches
On Sat, 2023-08-26 at 14:22 +0200, priour...@gmail.com wrote: > From: benjamin priour > > Hi, > > Updated version of the patch, regstrapping the changes described in > https://gcc.gnu.org/pipermail/gcc-patches/2023-August/628455.html. > > Regstrapped off trunk

Re: [PATCH] analyzer: Move gcc.dg/analyzer tests to c-c++-common (1).

2023-08-25 Thread David Malcolm via Gcc-patches
On Fri, 2023-08-25 at 14:48 +0200, Benjamin Priour wrote: > Hi David, > > Thanks for the review. > > On Fri, Aug 25, 2023 at 2:12 AM David Malcolm > wrote: > > > > From: benjamin priour > > > > > > Hi, > > > > > > Below the first batch of a serie of patches to transition > > > the analyzer

[pushed] analyzer: fix ICE in text art strings support

2023-08-25 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-3481-g99a3fcb8ff0bf2. gcc/analyzer/ChangeLog: * access-diagram.cc (class string_region_spatial_item): Remove assumption that the string is written to the start of the cluster.

Re: [PATCH] analyzer: Move gcc.dg/analyzer tests to c-c++-common (1).

2023-08-24 Thread David Malcolm via Gcc-patches
> From: benjamin priour > > Hi, > > Below the first batch of a serie of patches to transition > the analyzer testsuite from gcc.dg/analyzer to c-c++-common/analyzer. > I do not know how long this serie will be, thus the patch was not > numbered. > > For the grand majority of the tests, the

[PATCH 8/9] analyzer: handle strlen(BITS_WITHIN) [PR105899]

2023-08-24 Thread David Malcolm via Gcc-patches
gcc/analyzer/ChangeLog: PR analyzer/105899 * region-model.cc (fragment::has_null_terminator): Handle SK_BITS_WITHIN. --- gcc/analyzer/region-model.cc | 21 - 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/gcc/analyzer/region-model.cc

[PATCH 7/9] analyzer: handle INIT_VAL(ELEMENT_REG(STRING_REG), CONSTANT_SVAL) [PR105899]

2023-08-24 Thread David Malcolm via Gcc-patches
gcc/analyzer/ChangeLog: PR analyzer/105899 * region-model-manager.cc (region_model_manager::get_or_create_initial_value): Simplify INIT_VAL(ELEMENT_REG(STRING_REG), CONSTANT_SVAL) to CONSTANT_SVAL(STRING[N]). --- gcc/analyzer/region-model-manager.cc | 19

[pushed 0/9] analyzer: strlen, strcpy, and strcat [PR105899]

2023-08-24 Thread David Malcolm via Gcc-patches
This patch kit makes improvements to the analyzer's new strlen implementation, and wires it up to strcpy and strcat. For example, given: #include void test (void) { char buf[10]; strcpy (buf, "hello world!"); } we now emit: demo.c: In function ‘test’: demo.c:6:3: warning:

[PATCH 6/9] analyzer: handle strlen(INIT_VAL(STRING_REG)) [PR105899]

2023-08-24 Thread David Malcolm via Gcc-patches
gcc/analyzer/ChangeLog: PR analyzer/105899 * region-model.cc (fragment::has_null_terminator): Move STRING_CST handling to fragment::string_cst_has_null_terminator; also use it to handle INIT_VAL(STRING_REG). (fragment::string_cst_has_null_terminator): New,

[PATCH 2/9] analyzer: handle symbolic bindings in scan_for_null_terminator [PR105899]

2023-08-24 Thread David Malcolm via Gcc-patches
gcc/analyzer/ChangeLog: PR analyzer/105899 * region-model.cc (iterable_cluster::iterable_cluster): Add symbolic binding keys to m_symbolic_bindings. (iterable_cluster::has_symbolic_bindings_p): New. (iterable_cluster::m_symbolic_bindings): New field.

[PATCH 9/9] analyzer: implement kf_strcat [PR105899]

2023-08-24 Thread David Malcolm via Gcc-patches
gcc/analyzer/ChangeLog: PR analyzer/105899 * call-details.cc (call_details::check_for_null_terminated_string_arg): Split into overloads, one taking just an arg_idx, the other a new "include_terminator" param. * call-details.h: Likewise. *

[PATCH 3/9] analyzer: reimplement kf_strcpy [PR105899]

2023-08-24 Thread David Malcolm via Gcc-patches
This patch reimplements the analyzer's implementation of strcpy using the region_model::scan_for_null_terminator infrastructure, so that e.g. it can complain about out-of-bounds reads/writes, unterminated strings, etc. gcc/analyzer/ChangeLog: PR analyzer/105899 * kf.cc

[PATCH 5/9] analyzer: reimplement kf_memcpy_memmove

2023-08-24 Thread David Malcolm via Gcc-patches
gcc/analyzer/ChangeLog: * kf.cc (kf_memcpy_memmove::impl_call_pre): Reimplement using region_model::copy_bytes. * region-model.cc (region_model::read_bytes): New. (region_model::copy_bytes): New. * region-model.h (region_model::read_bytes): New decl.

[PATCH 4/9] analyzer: eliminate region_model::get_string_size [PR105899]

2023-08-24 Thread David Malcolm via Gcc-patches
gcc/analyzer/ChangeLog: PR analyzer/105899 * region-model.cc (region_model::get_string_size): Delete both. * region-model.h (region_model::get_string_size): Delete both decls. --- gcc/analyzer/region-model.cc | 29 -

[PATCH 1/9] analyzer: add logging to impl_path_context

2023-08-24 Thread David Malcolm via Gcc-patches
gcc/analyzer/ChangeLog: * engine.cc (impl_path_context::impl_path_context): Add logger param. (impl_path_context::bifurcate): Add log message. (impl_path_context::terminate_path): Likewise. (impl_path_context::m_logger): New field.

[pushed] analyzer: reimplement kf_strlen [PR105899]

2023-08-22 Thread David Malcolm via Gcc-patches
Reimplement kf_strlen in terms of the new string scanning implementation, sharing strlen's implementation with __analyzer_get_strlen. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-3391-g3242fb533d48ab. gcc/analyzer/ChangeLog: PR analyzer/105899

[pushed 6/6] analyzer: check format strings for null termination [PR105899]

2023-08-21 Thread David Malcolm via Gcc-patches
This patch extends -fanalyzer to check the format strings of calls to functions marked with '__attribute__ ((format...))'. The only checking done in this patch is to check that the format string is a valid null-terminated string; this patch doesn't attempt to check the content of the format

[pushed 4/6] analyzer: replace -Wanalyzer-unterminated-string with scan_for_null_terminator [PR105899]

2023-08-21 Thread David Malcolm via Gcc-patches
In r14-3169-g325f9e88802daa I added check_for_null_terminated_string_arg to -fanalyzer, calling it in various places, with a sole check for unterminated string constants, adding -Wanalyzer-unterminated-string for this case. This patch adds region_model::scan_for_null_terminator, which simulates

[pushed 2/6] analyzer: add ability for context to add events to a saved_diagnostic

2023-08-21 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-3372-g2503dd59b588d3. gcc/analyzer/ChangeLog: * diagnostic-manager.cc (saved_diagnostic::add_event): New. (saved_diagnostic::add_any_saved_events): New. (diagnostic_manager::add_event):

[pushed 5/6] analyzer: add kf_fopen

2023-08-21 Thread David Malcolm via Gcc-patches
Add checking to -fanalyzer that both params of calls to "fopen" are valid null-terminated strings. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-3375-g4325c82736d9e8. gcc/analyzer/ChangeLog: * kf.cc (class kf_fopen): New.

[pushed 3/6] analyzer: handle NULL inner context in region_model_context_decorator

2023-08-21 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-3373-g1e7b0a5d7a45dc. gcc/analyzer/ChangeLog: * region-model.cc (region_model_context_decorator::add_event): Handle m_inner being NULL. * region-model.h (class

[pushed 1/6] analyzer: convert note_adding_context to annotating_context

2023-08-21 Thread David Malcolm via Gcc-patches
This is enabling work towards the context being able to inject events into diagnostic paths, rather than just notes after the warning. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-3371-ge40a935db29cfd. gcc/analyzer/ChangeLog: * region-model.cc

Re: [PATCH] testsuite: Improve test in dg-require-python-h

2023-08-18 Thread David Malcolm via Gcc-patches
On Thu, 2023-08-17 at 23:30 -0300, Thiago Jung Bauermann wrote: > If GCC is tested with a sysroot which doesn't contain a Python > installation (e.g., with a command such as > "make check-gcc-c FLAGS_UNDER_TEST="--sysroot=/some/path"), but > there's > a python3-config in $PATH, then the testsuite

Re: [PATCH] libgccjit: Add support for `restrict` attribute on function parameters

2023-08-17 Thread David Malcolm via Gcc-patches
On Thu, 2023-08-17 at 17:41 +0200, Guillaume Gomez wrote: > And now I just discovered that a lot of commits from Antoni's fork > haven't been sent upstream which is why the ABI count is so high in > his repository. Fixed that as well. Thanks for the updated patch; I was about to comment on that.

Re: [PATCH] libgccjit: Add support for `restrict` attribute on function parameters

2023-08-16 Thread David Malcolm via Gcc-patches
On Wed, 2023-08-16 at 22:06 +0200, Guillaume Gomez via Jit wrote: > My apologies, forgot to run the commit checkers. Here's the commit > with the errors fixed. > > Le mer. 16 août 2023 à 18:32, Guillaume Gomez > a écrit : > > > > Hi, Hi Guillaume, thanks for the patch. > > > > This patch

Re: [WIP RFC v2] analyzer: Add support of placement new and improved operator new [PR105948]

2023-08-16 Thread David Malcolm via Gcc-patches
On Wed, 2023-08-16 at 14:19 +0200, priour...@gmail.com wrote: > From: benjamin priour > > Hi, > (s/we/the analyzer/) Hi Benjamin, thanks for the updated patch. > > I've been continuing my patch of supporting operator new variants > in the analyzer, and have added a few more test cases. > >

Re: [RFC] GCC Security policy

2023-08-15 Thread David Malcolm via Gcc-patches
On Mon, 2023-08-14 at 09:26 -0400, Siddhesh Poyarekar wrote: > Hi, > > Here's the updated draft of the top part of the security policy with all > of the recommendations incorporated. > > Thanks, > Sid > > > What is a GCC security bug? > === > > A security bug is

Re: [PATCH v4 4/8] diagnostics: Support obtaining source code lines from generated data buffers

2023-08-15 Thread David Malcolm via Gcc-patches
On Tue, 2023-08-15 at 14:15 -0400, Lewis Hyatt wrote: > On Tue, Aug 15, 2023 at 12:15:15PM -0400, David Malcolm wrote: > > On Wed, 2023-08-09 at 18:14 -0400, Lewis Hyatt wrote: > > > This patch enhances location_get_source_line(), which is the > > > primary > > > interface provided by the

Re: [PATCH v4 3/8] diagnostics: Refactor class file_cache_slot

2023-08-15 Thread David Malcolm via Gcc-patches
On Tue, 2023-08-15 at 13:58 -0400, Lewis Hyatt wrote: > On Tue, Aug 15, 2023 at 11:43:05AM -0400, David Malcolm wrote: > > On Wed, 2023-08-09 at 18:14 -0400, Lewis Hyatt wrote: > > > Class file_cache_slot in input.cc is used to query specific lines > > > of source > > > code from a file when

Re: [PATCH v4 8/8] diagnostics: Support generated data locations in SARIF output

2023-08-15 Thread David Malcolm via Gcc-patches
On Wed, 2023-08-09 at 18:14 -0400, Lewis Hyatt wrote: > The diagnostics routines for SARIF output need to read the source code back > in, so that they can generate "snippet" and "content" records, so they need to > be able to cope with generated data locations.  Add support for that in >

Re: [PATCH v4 6/8] diagnostics: Full support for generated data locations

2023-08-15 Thread David Malcolm via Gcc-patches
On Wed, 2023-08-09 at 18:14 -0400, Lewis Hyatt wrote: > Previous patches in this series have laid the groundwork for supporting > source code locations in memory ("generated data") rather than ordinary > files. This patch completes the support by adding awareness of such > locations to all places

Re: [PATCH v4 5/8] diagnostics: Support testing generated data in input.cc selftests

2023-08-15 Thread David Malcolm via Gcc-patches
On Wed, 2023-08-09 at 18:14 -0400, Lewis Hyatt wrote: > Add selftests for the new capabilities in input.cc related to source code > locations that are stored in memory rather than ordinary files. > > gcc/ChangeLog: > > * input.cc (temp_source_file::do_linemap_add): New function. >    

Re: [PATCH v4 4/8] diagnostics: Support obtaining source code lines from generated data buffers

2023-08-15 Thread David Malcolm via Gcc-patches
On Wed, 2023-08-09 at 18:14 -0400, Lewis Hyatt wrote: > This patch enhances location_get_source_line(), which is the primary > interface provided by the diagnostics infrastructure to obtain the line of > source code corresponding to a given location, so that it understands > generated data

Re: [PATCH v4 3/8] diagnostics: Refactor class file_cache_slot

2023-08-15 Thread David Malcolm via Gcc-patches
On Wed, 2023-08-09 at 18:14 -0400, Lewis Hyatt wrote: > Class file_cache_slot in input.cc is used to query specific lines of source > code from a file when needed by diagnostics infrastructure. This will be > extended in a subsequent patch to support obtaining the source code from > in-memory

Re: [PATCH v2] analyzer: New option fanalyzer-show-events-in-system-headers [PR110543]

2023-08-14 Thread David Malcolm via Gcc-patches
On Mon, 2023-08-14 at 17:48 +0200, priour...@gmail.com wrote: > From: benjamin priour > > Plenty useful, thanks David. I've adjusted some few things, especially > the artifacts of earlier versions I missed when building the commit. > > I didn't how to test for warnings within , I couldn't

Re: [PATCH v4 2/8] libcpp: diagnostics: Support generated data in expanded locations

2023-08-11 Thread David Malcolm via Gcc-patches
On Wed, 2023-08-09 at 18:14 -0400, Lewis Hyatt wrote: > The previous patch in this series introduced the concept of LC_GEN line > maps. This patch continues on the path to using them to improve _Pragma > diagnostics, by adding a new source_id SRC member to struct > expanded_location, which is

Re: [PATCH v4 1/8] libcpp: Add LC_GEN linemaps to support in-memory buffers

2023-08-11 Thread David Malcolm via Gcc-patches
On Wed, 2023-08-09 at 18:14 -0400, Lewis Hyatt wrote: Hi Lewis, thanks for the patch... > Add a new linemap reason LC_GEN which enables encoding the location of data > that was generated during compilation and does not appear in any source file. > There could be many use cases, such as, for

[pushed] analyzer: new warning: -Wanalyzer-unterminated-string [PR105899]

2023-08-11 Thread David Malcolm via Gcc-patches
This patch adds new functions to the analyzer for checking that an argument at a callsite is a pointer to a valid null-terminated string, and uses this for the following known functions: - error (param 3, the format string) - error_at_line (param 5, the format string) - putenv - strchr (1st

Re: [PATCH] analyzer: New option fanalyzer-show-events-in-system-headers [PR110543]

2023-08-11 Thread David Malcolm via Gcc-patches
On Fri, 2023-08-11 at 13:51 +0200, priour...@gmail.com wrote: > From: benjamin priour Hi Benjamin, thanks for the patch. Overall, the patch is close to being ready, but see the various comments inline below... > > This patch introduces -fanalyzer-show-events-in-system-headers, > disabled by

Re: [PATCH v2] analyzer: More features for CPython analyzer plugin [PR107646]

2023-08-09 Thread David Malcolm via Gcc-patches
On Wed, 2023-08-09 at 15:22 -0400, Eric Feng wrote: > Thank you for your help in getting dg-require-python-h working! I can > confirm that the FAILs are related to differences between the -- > cflags > affecting the gimple seen by the analyzer. For this reason, I have > changed it to --includes

Re: [PATCH] testsuite: Fix gcc.dg/analyzer/allocation-size-multiline-[123].c [PR 110426]

2023-08-09 Thread David Malcolm via Gcc-patches
On Tue, 2023-08-08 at 15:01 +, Christophe Lyon wrote: > For 32-bit newlib targets (e.g. arm-eabi)  int32_t is "long int". > > Like previous patches in these tests, update the matching regexps to > match "aka (long )?int". > > Tested on arm-eabi and aarch64-linux-gnu. Sorry about this

[pushed] analyzer: remove default return value from region_model::on_call_pre

2023-08-09 Thread David Malcolm via Gcc-patches
Previously, the code for simulating calls to external functions in region_model::on_call_pre wrote a default svalue to the LHS of the call statement, which could be further overwritten by known_function subclasses. Unfortunately, this led to messy hacks, such as when the default svalue was an

Re: [PATCH] Add -Wdisabled-optimization warning for not optimizing sibling calls

2023-08-08 Thread David Malcolm via Gcc-patches
On Tue, 2023-08-08 at 08:05 +0200, Richard Biener wrote: > On Mon, Aug 7, 2023 at 9:04 PM Bradley Lucier > wrote: > > > > Thank you for your comments.  I have a few questions. > > > > > I don't think this specific case qualifies for -Wdisabled- > > > optimization. > > > The diagnostic is for

Re: [RFC] GCC Security policy

2023-08-08 Thread David Malcolm via Gcc-patches
On Tue, 2023-08-08 at 09:33 -0400, Paul Koning via Gcc-patches wrote: > > > > On Aug 8, 2023, at 9:01 AM, Jakub Jelinek via Gcc-patches > > wrote: > > > > On Tue, Aug 08, 2023 at 02:52:57PM +0200, Richard Biener via Gcc- > > patches wrote: > > > There's probably external tools to do this, not

Re: [PATCH] Add -Wdisabled-optimization warning for not optimizing sibling calls

2023-08-05 Thread David Malcolm via Gcc-patches
On Sun, 2023-08-06 at 02:28 +0530, Prathamesh Kulkarni via Gcc-patches wrote: > On Fri, 4 Aug 2023 at 23:28, Bradley Lucier via Gcc-patches > wrote: Hi Bradley and Prathamesh... > > > > The patch at the end adds a warning when a tail/sibling call cannot > > be > > optimized for various

[pushed] analyzer: handle function attribute "alloc_size" [PR110426]

2023-08-04 Thread David Malcolm via Gcc-patches
This patch makes -fanalyzer make use of the function attribute "alloc_size", allowing -fanalyzer to emit -Wanalyzer-allocation-size, -Wanalyzer-out-of-bounds, and -Wanalyzer-tainted-allocation-size on execution paths involving allocations using such functions. Successfully bootstrapped &

[pushed] analyzer: fix some svalue::dump_to_pp implementations

2023-08-04 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-3000-g187b213ddbe7ea. gcc/analyzer/ChangeLog: * svalue.cc (region_svalue::dump_to_pp): Support NULL type. (constant_svalue::dump_to_pp): Likewise. (initial_svalue::dump_to_pp): Likewise.

Re: [PATCH v2] analyzer: stash values for CPython plugin [PR107646]

2023-08-03 Thread David Malcolm via Gcc-patches
On Thu, 2023-08-03 at 11:28 -0400, Eric Feng wrote: > On Wed, Aug 2, 2023 at 5:09 PM David Malcolm > wrote: > > > > On Wed, 2023-08-02 at 14:46 -0400, Eric Feng wrote: > > [...snip...] > > > > >  Otherwise, please let me know if I should request write > > > access first (the GettingStarted

Re: [PATCH] mid-end: Use integral time intervals in timevar.cc

2023-08-03 Thread David Malcolm via Gcc-patches
On Thu, 2023-08-03 at 15:54 +0100, Matthew Malcomson wrote: > On 8/3/23 15:09, David Malcolm wrote: > > > > Hi Matthew.  I recently touched the timevar code (in r14-2881- > > g75d623946d4b6e) to add support for serializing the timevar data in > > JSON form as part of the SARIF output (PR

[committed] testsuite, analyzer: add test case [PR108171]

2023-08-03 Thread David Malcolm via Gcc-patches
The ICE in PR analyzer/108171 appears to be a dup of the recently fixed PR analyzer/110882 and is likewise fixed by it; adding this test case. Successfully regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-2957-gf80efa49b7a163. gcc/testsuite/ChangeLog: PR analyzer/108171

Re: [PATCH] mid-end: Use integral time intervals in timevar.cc

2023-08-03 Thread David Malcolm via Gcc-patches
On Thu, 2023-08-03 at 14:38 +0100, Matthew Malcomson via Gcc-patches wrote: > > > > I think this is undesriable.  With fused you mean we use FMA? > > I think you could use -ffp-contract=off for the TU instead. > > > > Note you can't use __attribute__((noinline)) literally since the > > host

[committed] analyzer: fix ICE on zero-sized arrays [PR110882]

2023-08-03 Thread David Malcolm via Gcc-patches
Successfully bootstrapped and regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-2955-gc62f93d1e0383d. gcc/analyzer/ChangeLog: PR analyzer/110882 * region.cc (int_size_in_bits): Fail on zero-sized types. gcc/testsuite/ChangeLog: PR analyzer/110882 *

Re: [PATCH v2] analyzer: stash values for CPython plugin [PR107646]

2023-08-02 Thread David Malcolm via Gcc-patches
On Wed, 2023-08-02 at 14:46 -0400, Eric Feng wrote: > On Wed, Aug 2, 2023 at 1:20 PM Marek Polacek > wrote: > > > > On Wed, Aug 02, 2023 at 12:59:28PM -0400, David Malcolm wrote: > > > On Wed, 2023-08-02 at 12:20 -0400, Eric Feng wrote: > > > [Dropping Joseph and Marek from the CC]

Re: [PATCH v2] analyzer: stash values for CPython plugin [PR107646]

2023-08-02 Thread David Malcolm via Gcc-patches
On Wed, 2023-08-02 at 12:20 -0400, Eric Feng wrote: Hi Eric, thanks for the updated patch. Overall, looks good to me, although I'd drop the "Exited." from the "sorry" message (and thus from the dg-message directive), since the compiler is not exiting, it's just the particular plugin that's

Re: [PATCH] analyzer: stash values for CPython plugin [PR107646]

2023-08-01 Thread David Malcolm via Gcc-patches
On Tue, 2023-08-01 at 09:52 -0400, Eric Feng wrote: > Hi all, > > This patch adds a hook to the end of ana::on_finish_translation_unit > which calls relevant stashing-related callbacks registered during > plugin > initialization. This feature is used to stash named types and global > variables

Re: [PATCH] analyzer: Add support of placement new and improved operator new [PR105948]

2023-07-31 Thread David Malcolm via Gcc-patches
On Mon, 2023-07-31 at 13:46 +0200, Benjamin Priour wrote: > Hi Dave, > > On Fri, Jul 21, 2023 at 10:10 PM David Malcolm > wrote: [...snip...] > > > > I see that we have test coverage for: > >   noexcept-new.C: -fno-exceptions with new vs nothrow-new > > whereas: > >   new-2.C has (implicitly)

Re: [PATCH v3 0/4] diagnostics: libcpp: Overhaul locations for _Pragma tokens

2023-07-29 Thread David Malcolm via Gcc-patches
On Sat, 2023-07-29 at 10:27 -0400, Lewis Hyatt wrote: > On Fri, Jul 28, 2023 at 6:22 PM David Malcolm > wrote: > > > > On Fri, 2023-07-21 at 19:08 -0400, Lewis Hyatt wrote: > > > Hello- > > > > > > This is an update to the v2 patch series last sent in January: > > >

Re: [PATCH v3 1/4] diagnostics: libcpp: Add LC_GEN linemaps to support in-memory buffers

2023-07-28 Thread David Malcolm via Gcc-patches
On Fri, 2023-07-21 at 19:08 -0400, Lewis Hyatt wrote: > Add a new linemap reason LC_GEN which enables encoding the location > of data > that was generated during compilation and does not appear in any > source file. > There could be many use cases, such as, for instance, referring to > the content

Re: [PATCH v3 0/4] diagnostics: libcpp: Overhaul locations for _Pragma tokens

2023-07-28 Thread David Malcolm via Gcc-patches
On Fri, 2023-07-21 at 19:08 -0400, Lewis Hyatt wrote: > Hello- > > This is an update to the v2 patch series last sent in January: > https://gcc.gnu.org/pipermail/gcc-patches/2023-January/609473.html > > While I did not receive any feedback on the v2 patches yet, they did > need some > rebasing

[PATCH v2] SARIF and -ftime-report's output [PR109361]

2023-07-28 Thread David Malcolm via Gcc-patches
On Fri, 2023-07-28 at 08:00 +0200, Richard Biener wrote: > On Fri, Jul 28, 2023 at 12:23 AM David Malcolm via Gcc-patches > wrote: > > > > On Tue, 2023-04-11 at 08:43 +, Richard Biener wrote: > > > On Tue, 4 Apr 2023, David Malcolm wrote: > > > >

Re: [PATCH] Add -fsarif-time-report [PR109361]

2023-07-27 Thread David Malcolm via Gcc-patches
On Tue, 2023-04-11 at 08:43 +, Richard Biener wrote: > On Tue, 4 Apr 2023, David Malcolm wrote: > > > Richi, Jakub: I can probably self-approve this, but it's > > technically a > > new feature.  OK if I push this to trunk in stage 4?  I believe > > it's > > low risk, and is very useful for

[pushed] analyzer: add symbol base class, moving region id to there [PR104940]

2023-07-26 Thread David Malcolm via Gcc-patches
This patch introduces a "symbol" base class that region and svalue both inherit from, generalizing the ID from the region class so it's also used by svalues. This gives a way of sorting regions and svalues into creation order, which I've found useful in my experiments with adding SMT support (PR

  1   2   3   4   5   6   7   8   9   10   >