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

2022-10-28 Thread David Malcolm via Gcc-patches
On Thu, 2022-10-27 at 19:16 -0400, Ben Boeckel wrote: > This simplifies the interface for other UTF-8 validity detections > when a > simple "yes" or "no" answer is sufficient. > > Signed-off-by: Ben Boeckel > --- >  libcpp/ChangeLog  |  6 ++ >  libcpp/charset.cc | 18 ++ >  

Re: [PATCH v2 1/3] libcpp: reject codepoints above 0x10FFFF

2022-10-28 Thread David Malcolm via Gcc-patches
On Thu, 2022-10-27 at 19:16 -0400, Ben Boeckel wrote: > Unicode does not support such values because they are unrepresentable > in > UTF-16. Wikipedia pointed me to RFC 3629, which was when UTF-8 introduced this restriction, whereas libcpp was implementing the higher upper limit from the earlier,

[committed] analyzer: fixes to file-descriptor handling

2022-10-26 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-3515-g57bbf3a403bb1e. gcc/analyzer/ChangeLog: * sm-fd.cc (fd_state_machine::on_open): Transition to "unchecked" when the mode is symbolic, rather than just on integer constants.

[committed] analyzer: add sm-fd.dot

2022-10-26 Thread David Malcolm via Gcc-patches
Add a .dot file to document the file descriptor state machine. gcc/analyzer/ChangeLog: * sm-fd.dot: New file. Signed-off-by: David Malcolm --- gcc/analyzer/sm-fd.dot | 109 + 1 file changed, 109 insertions(+) create mode 100644

Re: Rust frontend patches v3

2022-10-26 Thread David Malcolm via Gcc-patches
On Wed, 2022-10-26 at 10:17 +0200, arthur.co...@embecosm.com wrote: > This is the fixed version of our previous patch set for gccrs - We've > adressed > the comments raised in our previous emails. [...snip...] (Caveat: I'm not a global reviewer) Sorry if this is answered in the docs in the

Re: [PATCH Rust front-end v3 35/46] gccrs: Add metadata ouptput pass

2022-10-26 Thread David Malcolm via Gcc-patches
%{On Wed, 2022-10-26 at 10:18 +0200, arthur.co...@embecosm.com wrote: > From: Philip Herron > > Extern crates statements to tell the front-end to look for another > library. > The mechanism here is heavily inspired from gccgo, so when we compile > a > library for example we invoke: >

Re: [PATCH Rust front-end v3 20/46] gccrs: Add wrapper for make_unique

2022-10-26 Thread David Malcolm via Gcc-patches
On Wed, 2022-10-26 at 10:17 +0200, arthur.co...@embecosm.com wrote: > From: Philip Herron > > This is a wrapper for make_unique we can likely get rid of this as > there > are other implementations available or simply keep using the > unique_ptr > constructor. [CCing Jonathan] As it happens, I

[PATCH v3] Add gcc/make-unique.h

2022-10-26 Thread David Malcolm via Gcc-patches
Changed in v3: added include of v2: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/604137.html v1: https://gcc.gnu.org/pipermail/gcc-patches/2022-July/598189.html On Tue, 2022-07-12 at 07:48 +0100, Jonathan Wakely wrote: > On Tue, 12 Jul 2022, 01:25 David Malcolm, > wrote: > > > On

Re: [PATCH 1/2] Add gcc/make-unique.h

2022-10-25 Thread David Malcolm via Gcc-patches
On Fri, 2022-10-21 at 12:01 -0400, David Malcolm wrote: > This patch adds gcc/make-unique.h, containing a minimal C++11 > implementation of make_unique (std::make_unique is C++14). > > The followup patch uses this in dozens of places within the analyzer. > > Successfully bootstrapped &

[commited] analyzer: fix ICE on va_copy [PR107349]

2022-10-24 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Lightly tested with aarch64-unknown-linux. Pushed to trunk as r13-3470-g687d11fd74e7de gcc/analyzer/ChangeLog: PR analyzer/107349 * varargs.cc (get_va_copy_arg): Fix the non-pointer case. gcc/testsuite/ChangeLog:

[committed] diagnostics: fix ICE in sarif output with NULL filename [PR107366]

2022-10-24 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-3469-g2e8a0553918adc. gcc/ChangeLog: PR analyzer/107366 * diagnostic-format-sarif.cc (sarif_builder::maybe_make_physical_location_object): Gracefully reject locations with NULL

[committed] analyzer: handle (NULL == ) [PR107345]

2022-10-24 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-3468-g18faaeb3af42f3. gcc/analyzer/ChangeLog: PR analyzer/107345 * region-model.cc (region_model::eval_condition_without_cm): Ensure that constants are on the right-hand side before

[committed] analyzer: simplify sm_state_map lookup

2022-10-24 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-3467-g53881c47e4b357. gcc/analyzer/ChangeLog: * engine.cc (impl_region_model_context::get_malloc_map): Replace with... (impl_region_model_context::get_state_map_by_name): ...this.

[committed] analyzer: handle "pipe" and "pipe2" [PR106300]

2022-10-24 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-3466-g792f039fc37faa. gcc/analyzer/ChangeLog: PR analyzer/106300 * engine.cc (impl_region_model_context::get_fd_map): New. * exploded-graph.h (impl_region_model_context::get_fd_map): New

[PATCH 2/2] analyzer: use std::unique_ptr for pending_diagnostic/note

2022-10-21 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. I can self-approve this, but it requires the patch adding make-unique.h as a prerequisite. gcc/analyzer/ChangeLog: * call-info.cc: Add define of INCLUDE_MEMORY. * call-summary.cc: Likewise. * checker-path.cc:

[PATCH 1/2] Add gcc/make-unique.h

2022-10-21 Thread David Malcolm via Gcc-patches
This patch adds gcc/make-unique.h, containing a minimal C++11 implementation of make_unique (std::make_unique is C++14). The followup patch uses this in dozens of places within the analyzer. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. OK for trunk? gcc/ChangeLog: *

[committed] analyzer: fix ICE on __builtin_ms_va_copy [PR105765]

2022-10-19 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-3390-gebe87edadc4a3f. gcc/analyzer/ChangeLog: PR analyzer/105765 * varargs.cc (get_BT_VALIST_ARG): Rename to... (get_va_copy_arg): ...this, and update logic for determining level

[committed] analyzer: fix ICE introduced in r13-3168 [PR107210]

2022-10-13 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-3285-g99da523359e933. gcc/analyzer/ChangeLog: PR analyzer/107210 * svalue.cc (constant_svalue::maybe_fold_bits_within): Only attempt to extract individual bits when tree_fits_uhwi_p.

Re: [DOCS] Python Language Conventions

2022-10-13 Thread David Malcolm via Gcc-patches
On Thu, 2022-10-13 at 11:44 +0200, Gerald Pfeifer wrote: > Hi Martin, > > On Thu, 13 Oct 2022, Martin Liška wrote: > > I think we should add how Python scripts should be formatted. I > > noticed > > that while reading the Modula-2 patchset where it follows the C/C++ > > style > > when it comes to

Re: [PATCH RESEND 0/1] RFC: P1689R5 support

2022-10-13 Thread David Malcolm via Gcc-patches
On Mon, 2022-10-10 at 16:21 -0400, Jason Merrill wrote: > On 10/4/22 11:11, Ben Boeckel wrote: > > This patch adds initial support for ISO C++'s [P1689R5][], a format > > for > > describing C++ module requirements and provisions based on the > > source > > code. This is required because compiling

[committed] analyzer: extract bits from integer constants [PR105783]

2022-10-07 Thread David Malcolm via Gcc-patches
Fix a false positive from -Wanalyzer-null-dereference due to -fanalyzer failing to grok the value of a particular boolean field initialized to a constant. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-3168-gf09b99550a3c6c. gcc/analyzer/ChangeLog:

[committed] analyzer: fixes to call_summary_replay::dump_to_pp

2022-10-06 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-3137-g30d6356773a838. gcc/analyzer/ChangeLog: * call-summary.cc (call_summary_replay::dump_to_pp): Bulletproof against NULL caller regions/svalues. Signed-off-by: David Malcolm ---

[committed] analyzer: fix another ICE in PR 107158

2022-10-06 Thread David Malcolm via Gcc-patches
I overreduced PR analyzer/107158 in r13-3096-gef878564140cbc, and there was another ICE in the original reproducer, which this patch fixes. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-3138-g629b4813e91aba. gcc/analyzer/ChangeLog: PR

[committed] analyzer: add regression test for PR 107158

2022-10-05 Thread David Malcolm via Gcc-patches
PR analyzer/107158 reports an ICE when using -fanalyzer -fanalyzer-call-summaries on a particular source file. It turns out I just fixed this ICE in r13-3094-g6832c95c0e1a58. This followup patch adds a somewhat reduced reproducer as a regression test. Unfortunately, although the ICE is fixed,

[committed] analyzer: simplify some includes

2022-10-05 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-3095-g2eff4fe383a59d. gcc/analyzer/ChangeLog: * analysis-plan.cc: Simplify includes. * analyzer-pass.cc: Likewise. * analyzer-selftests.cc: Likewise. * analyzer.cc: Likewise.

[committed] analyzer: fix ICEs seen with call summaries on PR 107060

2022-10-05 Thread David Malcolm via Gcc-patches
This doesn't fix the various false positives seen with -fanalyzer-call-summaries on PR 107060, but stops it crashing at -O2. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-3094-g6832c95c0e1a58. gcc/analyzer/ChangeLog: PR analyzer/107060 *

[committed] analyzer: move region_model_manager decl to its own header

2022-10-04 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-3076-g0167154cdd02c9. gcc/analyzer/ChangeLog: * region-model.h: Include "analyzer/region-model-manager.h" (class region_model_manager): Move decl to... * region-model-manager.h: ...this

[committed] analyzer: revamp side-effects of call summaries [PR107072]

2022-10-04 Thread David Malcolm via Gcc-patches
With -fanalyzer-call-summaries the analyzer canl attempt to summarize the effects of some function calls at their call site, rather than simulate the call directly, which can avoid big slowdowns during analysis. Previously, this summarization was extremely simplistic: no attempt was made to

[committed] analyzer: fold -(-(VAL)) to VAL

2022-10-04 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-3075-g7f42f7adfa69fe. gcc/analyzer/ChangeLog: * region-model-manager.cc (region_model_manager::maybe_fold_unaryop): Fold -(-(VAL)) to VAL. Signed-off-by: David Malcolm ---

[committed] analyzer: widening_svalues take a function_point rather than a program_point

2022-10-04 Thread David Malcolm via Gcc-patches
Enabling work towrads better call summarization. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-3074-ge6fe02d8322093. gcc/analyzer/ChangeLog: * region-model-manager.cc (region_model_manager::get_or_create_widening_svalue): Use a

Re: [PATCH] attribs: Add missing auto_diagnostic_group 3 times

2022-10-04 Thread David Malcolm via Gcc-patches
On Tue, 2022-10-04 at 11:11 +0200, Jakub Jelinek wrote: > Hi! > > In these spots, the error/error_at has some inform afterwards which > are > explanation part of the same diagnostics, so should be tied with > auto_diagnostic_group with it. > > Bootstrapped/regtested on x86_64-linux and

Re: [PATCH v2] Libvtv-test: Fix bug that scansarif.exp cannot be found in libvtv regression test.

2022-09-27 Thread David Malcolm via Gcc-patches
On Tue, 2022-09-27 at 14:02 +0800, Lulu Cheng wrote: > SARIF support was added in r13-967 but libvtv wasn't updated. Sorry about breaking this. The patch looks reasonable to me, FWIW, assuming that it fixes the issue, of course! Looks like my normal testing process missed this when I

Re: [PATCH] analyzer: consider empty ranges and zero byte accesses [PR106845]

2022-09-11 Thread David Malcolm via Gcc-patches
On Sun, 2022-09-11 at 10:21 +0200, Bernhard Reutner-Fischer wrote: > On 11 September 2022 10:04:51 CEST, David Malcolm via Gcc-patches > wrote: > > > > +++ b/gcc/testsuite/gcc.dg/analyzer/pr106845.c > > > @@ -0,0 +1,11 @@ > > > +int buf_size;

Re: [PATCH] analyzer: consider empty ranges and zero byte accesses [PR106845]

2022-09-11 Thread David Malcolm via Gcc-patches
On Sun, 2022-09-11 at 00:19 +0200, Tim Lange wrote: > Hi, > > see my patch below for a fix of pr106845.  I decided to allow > bit_ranges > and byte_ranges to have a size of zero and rather only add an > assertion > to the functions that assume a non-zero size.  That way is more > elegant in > the

[committed] analyzer: implement trust boundaries via a plugin for Linux kernel

2022-09-09 Thread David Malcolm via Gcc-patches
This is a less ambitious version of: [PATCH 0/6] RFC: adding support to GCC for detecting trust boundaries https://gcc.gnu.org/pipermail/gcc-patches/2021-November/584372.html Earlier versions of this patch attempted: (a) various ways of identifying "untrusted" memory regions (b) providing a

[committed] analyzer: add support for plugin-supplied known function behaviors

2022-09-09 Thread David Malcolm via Gcc-patches
This patch adds the ability for plugins to register "known functions" with the analyzer, identified by name. If -fanalyzer sees a call to such a function (with no body), it will use a plugin-provided subclass of the new known_function abstract base class to model the possible outcomes of the

[committed] analyzer: add test coverage for flexible array members [PR98247]

2022-09-09 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-2571-g084dc9a0c6cec1. gcc/testsuite/ChangeLog: PR analyzer/98247 * gcc.dg/analyzer/flexible-array-member-1.c: New test. Signed-off-by: David Malcolm ---

Re: [PATCH v2] analyzer: support for symbolic values in the out-of-bounds checker [PR106625]

2022-09-07 Thread David Malcolm via Gcc-patches
On Wed, 2022-09-07 at 17:51 +0200, Tim Lange wrote: > Hi Dave, > > while re-reading that patch, I noticed a small mistake. I accidently > did > not move the op == PLUS_EXPR or MULT_EXPR guard in > symbolic_greater_than > when implementing the "eliminate operands on both sides" feature, > which >

[PATCH] c: fix uninitialized c_expr::m_decimal [PR106830]

2022-09-06 Thread David Malcolm via Gcc-patches
I added c_expr::m_decimal in r13-2386-gbedfca647a9e9c1a as part of the implementation of -Wxor-used-as-pow, but I missed various places where the field needed to be initialized. Fixed thusly (based on searching for places that assign to the original_code field). Successfully bootstrapped &

Re: [PATCH][WIP?] analyzer: support for symbolic values in the out-of-bounds checker [PR106625]

2022-09-05 Thread David Malcolm via Gcc-patches
On Mon, 2022-09-05 at 23:16 +0200, Tim Lange wrote: > Hi, > > below is my patch, adding support for reasoning about buffer > overflows and > overreads with symbolic offsets and capacities. Thanks for the updated patch. Various comments inline below... > > I've already had one off-list

Re: [PATCH 2/2 v2] analyzer: strcpy semantics

2022-09-04 Thread David Malcolm via Gcc-patches
On Sun, 2022-09-04 at 21:17 +0200, Tim Lange wrote: > Hi Dave, > > sorry about the strncpy thing, I should've been more careful. Below > is the > patch with just the strcpy part. Thanks - this patch looks OK for trunk. Dave

Re: [PATCH] c/c++: new warning: -Wxor-used-as-pow [PR90885]

2022-09-02 Thread David Malcolm via Gcc-patches
On Tue, 2022-08-30 at 16:40 -0400, Marek Polacek wrote: > This looks good to me, one thing though: > > On Thu, Aug 11, 2022 at 09:38:12PM -0400, David Malcolm via Gcc- > patches wrote: > > --- a/gcc/c-family/c.opt > > +++ b/gcc/c-family/c.opt > > @@ -1439,6 +1439,10

Re: [PATCH 2/2] analyzer: strcpy and strncpy semantics

2022-09-02 Thread David Malcolm via Gcc-patches
On Fri, 2022-09-02 at 16:08 +0200, Tim Lange wrote: > Hi, > > below is my patch for the strcpy and strncpy semantics inside the > analyzer, enabling the out-of-bounds checker to also complain about > overflows caused by those two functions. > > As the plan is to reason about the inequality of

Re: [PATCH 1/2] analyzer: return a concrete offset for cast_regions

2022-09-02 Thread David Malcolm via Gcc-patches
On Fri, 2022-09-02 at 16:08 +0200, Tim Lange wrote: > This patch fixes a bug where maybe_fold_sub_svalue did not fold the > access of a single char from a string to a char when the offset was > zero > because get_relative_concrete_offset did return false for > cast_regions. > > Regrtested on

Re: Ping [PATCH V2] libcpp: Optimize #pragma once with a hash table [PR58770]

2022-08-21 Thread David Malcolm via Gcc-patches
On Fri, 2022-08-19 at 13:27 -0700, Paul Hollinsky wrote: > Hi all, > > Would love some feedback on this patch! > > Thanks, > Paul Hi Paul. Sorry for not getting back to you before. I'm listed as a libcpp maintainer, but this happens to be a part of libcpp I've not looked at (I'm mostly just

Re: [PATCH v2] analyzer: warn on the use of floating-points operands in the size argument [PR106181]

2022-08-18 Thread David Malcolm via Gcc-patches
On Thu, 2022-08-18 at 11:44 +0200, Tim Lange wrote: > Hi, > > this is the revised version of my patch. I had trouble to get your > point regarding the float_visitor: > > > If the constant is seen first, then the non-constant won't be > > favored > > (though perhaps binary ops get canonicalized

[committed] analyzer: fix direction of -Wanalyzer-out-of-bounds note [PR106626]

2022-08-15 Thread David Malcolm via Gcc-patches
Fix a read/write typo. Also, add more test coverage of -Wanalyzer-out-of-bounds to help establish a baseline for experiments on tweaking the wording of the warning (PR analyzer/106626). Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-2054-g23e8c0b0d99f58.

[committed] analyzer: better fix for -Wanalyzer-use-of-uninitialized-value [PR106573]

2022-08-15 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-2053-gca123e019bb92f. gcc/analyzer/ChangeLog: PR analyzer/106573 * region-model.cc (region_model::on_call_pre): Use check_call_args when ensuring that we call get_arg_svalue on all args.

Re: [PATCH] analyzer: warn on the use of floating points in the size argument [PR106181]

2022-08-15 Thread David Malcolm via Gcc-patches
On Mon, 2022-08-15 at 14:35 +0200, Tim Lange wrote: > This patch fixes the ICE reported in PR106181 and adds a new warning > to > the analyzer complaining about the use of floating point operands. Thanks for the patch. Various comments inline... > > I decided to move the warning for floats

Re: [PATCH] analyzer: fix for ICE in sm-fd.cc [PR106551]

2022-08-15 Thread David Malcolm via Gcc-patches
On Mon, 2022-08-15 at 14:02 +0530, Immad Mir wrote: > This patch fixes the ICE caused by valid_to_unchecked_state > in sm-fd.cc by exiting early if first argument of any "dup" > functions is invalid. > > gcc/analyzer/ChangeLog: > PR analyzer/106551 > * sm-fd.cc (check_for_dup):

[PATCH] c/c++: new warning: -Wxor-used-as-pow [PR90885]

2022-08-11 Thread David Malcolm via Gcc-patches
PR c/90885 notes various places in real-world code where people have written C/C++ code that uses ^ (exclusive or) where presumbably they meant exponentiation. For example https://codesearch.isocpp.org/cgi-bin/cgi_ppsearch?q=2%5E32=Search currently finds 11 places using "2^32", and all of them

Re: [PATCH 2/2 v2] analyzer: out-of-bounds checker [PR106000]

2022-08-11 Thread David Malcolm via Gcc-patches
On Thu, 2022-08-11 at 19:24 +0200, Tim Lange wrote: > This patch adds an experimental out-of-bounds checker to the > analyzer. > > The checker was tested on coreutils, curl, httpd and openssh. It is > mostly > accurate but does produce false-positives on yacc-generated files and > sometimes when

Re: [PATCH 1/2 v2] analyzer: consider that realloc could shrink the buffer [PR106539]

2022-08-11 Thread David Malcolm via Gcc-patches
On Thu, 2022-08-11 at 19:24 +0200, Tim Lange wrote: > This patch adds the "shrinks buffer" case to the success_with_move > modelling of realloc. Thanks for the updated patch. > > Regression-tested on Linux x86-64, further ran the analyzer tests > with > the -m32 option. [...snip...] > ---

Re: [PATCH] analyzer: fix ICE casued by dup2 in sm-fd.cc[PR106551]

2022-08-11 Thread David Malcolm via Gcc-patches
On Thu, 2022-08-11 at 14:41 +0530, Immad Mir wrote: > This patch fixes the ICE caused by valid_to_unchecked_state, > at analyzer/sm-fd.cc by handling the m_start state in > check_for_dup. > > Tested lightly on x86_64. > > gcc/analyzer/ChangeLog: > PR analyzer/106551 > * sm-fd.cc

Re: Rust frontend patches v1

2022-08-10 Thread David Malcolm via Gcc-patches
On Wed, 2022-08-10 at 19:56 +0100, Philip Herron wrote: > Hi everyone > > For my v2 of the patches, I've been spending a lot of time ensuring > each patch is buildable. It would end up being simpler if it was > possible if each patch did not have to be like this so I could split > up the

Re: [PATCH] analyzer: fix ICE casued by dup2 in sm-fd.cc[PR106551]

2022-08-10 Thread David Malcolm via Gcc-patches
On Wed, 2022-08-10 at 22:51 +0530, Mir Immad wrote: >  > Can you please rebase and see if your patch > > does fix it? > > No, the patch that I sent did not attempt to fix this. Now that I > have made > the correction, XFAIL in fd-uninit-1.c has changed to XPASS. Great - that means that, with

Re: [PATCH] analyzer: fix ICE casued by dup2 in sm-fd.cc[PR106551]

2022-08-10 Thread David Malcolm via Gcc-patches
On Wed, 2022-08-10 at 20:34 +0530, Mir Immad wrote: >  > if you convert the "int m;" locals into an extern global, like in > > comment #0 of bug 106551, does that still trigger the crash on the > > unpatched sm-fd.cc? > > Yes, it does, since m would be in "m_start" state. I'm sending an > updated

[committed] analyzer: fix missing -Wanalyzer-use-of-uninitialized-value on special-cased functions [PR106573]

2022-08-09 Thread David Malcolm via Gcc-patches
We were missing checks for uninitialized params on calls to functions that the analyzer has hardcoded knowledge of - both for those that are handled just by state machines, and for those that are handled in region-model-impl-calls.cc (for those arguments for which the svalue wasn't accessed in

Re: [PATCH] libgccjit.h: Make the macro definition for testing gcc_jit_context_new_bitcast correctly available.

2022-08-09 Thread David Malcolm via Gcc-patches
On Tue, 2022-08-09 at 11:39 -0400, David Malcolm wrote: > On Sat, 2022-07-30 at 19:18 +0530, Vibhav Pant wrote: > > I don't have push rights to the repo, so this would need to be > > applied manually. > > I've gone ahead and pushed your fix to trunk (for GCC 13) as r13- > 2004- > g9385cd9c74cf66.

Re: [PATCH 2/2] analyzer: out-of-bounds checker [PR106000]

2022-08-09 Thread David Malcolm via Gcc-patches
On Tue, 2022-08-09 at 23:19 +0200, Tim Lange wrote: > This patch adds an experimental out-of-bounds checker to the > analyzer. > > The checker was tested on coreutils, curl, httpd and openssh. It is > mostly > accurate but does produce false-positives on yacc-generated files and > sometimes when

Re: [PATCH 1/2] analyzer: consider that realloc could shrink the buffer [PR106539]

2022-08-09 Thread David Malcolm via Gcc-patches
On Tue, 2022-08-09 at 23:19 +0200, Tim Lange wrote: > This patch adds the "shrinks buffer" case to the success_with_move > modelling of realloc. Hi Tim, thanks for the patch. > > 2022-08-09  Tim Lange  > > gcc/analyzer/ChangeLog: > > PR analyzer/106539 > *

Re: [PATCH] analyzer: fix ICE casued by dup2 in sm-fd.cc[PR106551]

2022-08-09 Thread David Malcolm via Gcc-patches
On Tue, 2022-08-09 at 21:42 +0530, Immad Mir wrote: > This patch fixes the ICE caused by valid_to_unchecked_state, > at analyzer/sm-fd.cc by handling the m_start state in > check_for_dup. > > Tested lightly on x86_64. > > gcc/analyzer/ChangeLog: > PR analyzer/106551 > * sm-fd.cc

Re: [PATCH] libgccjit.h: Make the macro definition for testing gcc_jit_context_new_bitcast correctly available.

2022-08-09 Thread David Malcolm via Gcc-patches
On Sat, 2022-07-30 at 19:18 +0530, Vibhav Pant wrote: > I don't have push rights to the repo, so this would need to be > applied manually. I've gone ahead and pushed your fix to trunk (for GCC 13) as r13-2004- g9385cd9c74cf66. I plan to also push it to the gcc 12 branch shortly (for gcc 12.2)

[committed] docs: add notes on which functions -fanalyzer has hardcoded knowledge of

2022-08-09 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-2003-g16877cc2006ede. gcc/ChangeLog: * doc/invoke.texi (Static Analyzer Options): Add notes on which functions the analyzer has hardcoded knowledge of. Signed-off-by: David Malcolm ---

Re: [PATCH] analyzer: fix ICE casued by dup2 in sm-fd.cc[PR106551]

2022-08-09 Thread David Malcolm via Gcc-patches
On Tue, 2022-08-09 at 13:16 +0530, Immad Mir wrote: > This patch fixes the ICE caused by valid_to_unchecked_state, > at analyzer/sm-fd.cc by handling the m_start state in > check_for_dup. > > Tested lightly on x86_64. > > gcc/analyzer/ChangeLog: > PR analyzer/106551 > * sm-fd.cc

[committed] New warning: -Wanalyzer-jump-through-null [PR105947]

2022-08-05 Thread David Malcolm via Gcc-patches
This patch adds a new warning to -fanalyzer for jumps through NULL function pointers. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-1979-ge1a9168153d2bf. gcc/analyzer/ChangeLog: PR analyzer/105947 * analyzer.opt

Re: [PATCH] analyzer: support for creat, dup, dup2 and dup3 [PR106298]

2022-08-02 Thread David Malcolm via Gcc-patches
On Tue, 2022-08-02 at 22:08 +0530, Mir Immad wrote: > The above patch is bootstrapped, lightly tested (on x86_64 Linux) and > approved for trunk by David. For reference, Immad sent that version to me off-list to me for review, and I approved it. He's committed it to trunk now (as

[committed] c: improvements to address space diagnostics

2022-08-01 Thread David Malcolm via Gcc-patches
This adds a clarifying "note" to address space mismatch diagnostics. For example, it improves the diagnostic for gcc.target/i386/addr-space-typeck-2.c from: addr-space-typeck-2.c: In function 'test_bad_call': addr-space-typeck-2.c:12:22: error: passing argument 2 of 'expects_seg_gs' from

[committed] docs: fix copy error in -Wanalyzer-putenv-of-auto-var

2022-08-01 Thread David Malcolm via Gcc-patches
Pushed to trunk as r13-1921-gffd12be1394a49. gcc/ChangeLog: * doc/invoke.texi (-Wanalyzer-putenv-of-auto-var): Fix copy error. Signed-off-by: David Malcolm --- gcc/doc/invoke.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/doc/invoke.texi

Re: [PATCH] analyzer: support for creat, dup, dup2 and dup3 in sm-fd.cc [PR106300]

2022-07-29 Thread David Malcolm via Gcc-patches
On Fri, 2022-07-29 at 21:59 +0530, Immad Mir wrote: > This patch extends the state machine in sm-fd.cc to support > creat, dup, dup2 and dup3 functions. Thanks for the patch. Please can you use PR 106298 for this (in the ChangeLog and subject line), rather than 106300, as it's more specific.

[committed] analyzer: expand the comment in region.h

2022-07-28 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-1879-g9cac6811cf0d6c. gcc/analyzer/ChangeLog: * region.h: Add notes to the comment describing the region class hierarchy. Signed-off-by: David Malcolm --- gcc/analyzer/region.h | 52

[committed] analyzer: new warning: -Wanalyzer-putenv-of-auto-var [PR105893]

2022-07-28 Thread David Malcolm via Gcc-patches
This patch implements a new -fanalyzer warning: -Wanalyzer-putenv-of-auto-var which complains about stack pointers passed to putenv(3) calls, as per SEI CERT C Coding Standard rule POS34-C ("Do not call putenv() with a pointer to an automatic variable as the argument"). For example, given:

[committed] analyzer: add CWE identifier URLs to docs

2022-07-28 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-1880-g9c60338061bf36. gcc/analyzer/ChangeLog: * sm-malloc.cc (free_of_non_heap::emit): Add comment about CWE. * sm-taint.cc (tainted_size::emit): Likewise. gcc/ChangeLog: *

[committed] jit: update docs to reflect .c to .cc renaming

2022-07-28 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-1878-gb8ce0c4361c267. gcc/jit/ChangeLog: * docs/internals/index.rst: Remove reference to ".c" extensions of source files. Signed-off-by: David Malcolm --- gcc/jit/docs/internals/index.rst | 3

Backports of various patches to gcc 12 branch (mostly analyzer)

2022-07-27 Thread David Malcolm via Gcc-patches
I've backported the following patches to the releases/gcc-12 branch: r12-8631-g1321183a13540b: "analyzer: add .fpath.txt dumps to -fdump-analyzer-feasibility" from r13-6-gd8586b00dd00a1783862da5f0c8811a740400074 r12-8632-g05530fcea07a9e: "analyzer: handle repeated accesses after init of

Re: Rust frontend patches v1

2022-07-27 Thread David Malcolm via Gcc-patches
On Wed, 2022-07-27 at 14:40 +0100, herron.philip--- via Gcc-patches wrote: > This is the initial version 1 patch set for the Rust front-end. There > are more changes that need to be extracted out for all the target > hooks we have implemented. The goal is to see if we are implementing > the target

[committed] analyzer: fix false +ves from -Wanalyzer-va-arg-type-mismatch on int promotion [PR106319]

2022-07-26 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-1848-gdb613e8fa84125. gcc/analyzer/ChangeLog: PR analyzer/106319 * store.cc (store::set_value): Don't strip away casts if the region has NULL type. gcc/testsuite/ChangeLog: PR

[committed] analyzer: fix stray get_element decls

2022-07-26 Thread David Malcolm via Gcc-patches
These were copy errors. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-1847-g0460ba622e833d. gcc/analyzer/ChangeLog: * region.h (code_region::get_element): Remove stray decl. (function_region::get_element): Likewise. Signed-off-by: David

Re: [PATCH] analyzer: add get_meaning_for_state_change vfunc to fd_diagnostic in sm-fd.cc [PR106286]

2022-07-26 Thread David Malcolm via Gcc-patches
On Tue, 2022-07-26 at 22:07 +0530, Immad Mir wrote: > This patch adds get_meaning_for_state_change vfunc to > fd_diagnostic in sm-fd.cc which could be used by SARIF output. > > Lightly tested on x86_64 Linux. Thanks - looks good for trunk. Dave

Re: [PATCH 7/7] jit,docs: remove :ref:`modindex`

2022-07-26 Thread David Malcolm via Gcc-patches
On Tue, 2022-07-26 at 06:55 +0200, Martin Liška wrote: > gcc/jit/ChangeLog: > > * docs/index.rst: Remove reference to module index > as we don't emit any. Patch is OK Thanks Dave > --- >  gcc/jit/docs/index.rst | 1 - >  1 file changed, 1 deletion(-) > > diff --git

Re: [PATCH 6/7] jit,docs: use :expr:`type *` for pointers to a type

2022-07-26 Thread David Malcolm via Gcc-patches
On Tue, 2022-07-26 at 06:50 +0200, Martin Liška wrote: > On 7/26/22 00:41, David Malcolm wrote: > > On Mon, 2022-07-25 at 14:39 +0200, Martin Liska wrote: > > > gcc/jit/ChangeLog: > > > > > > * docs/cp/intro/tutorial02.rst: Use :expr:`type *` for > > > pointers to a type > > > *

Re: [PATCH 2/7] jit,docs: replace c:type:`int_type` with :expr:`int_type`

2022-07-26 Thread David Malcolm via Gcc-patches
On Tue, 2022-07-26 at 06:48 +0200, Martin Liška wrote: > On 7/26/22 00:37, David Malcolm wrote: > > On Mon, 2022-07-25 at 11:03 +0200, Martin Liska wrote: > > > Use expression that work fine for basic type. > > > > What's the motivation for this change?  Surely the things being > > marked > > up

Re: [PATCH] jit,docs: shorten assembly output

2022-07-26 Thread David Malcolm via Gcc-patches
On Tue, 2022-07-26 at 08:42 +0200, Martin Liška wrote: > Shorten the assembly example so that there is not slider. > > Ready for master? OK, thanks Dave

Re: [PATCH] libgccjit.h: Make the macro definition for testing gcc_jit_context_new_bitcast correctly available.

2022-07-25 Thread David Malcolm via Gcc-patches
On Sat, 2022-07-23 at 13:31 +0530, Vibhav Pant via Jit wrote: > The macro definition for LIBGCCJIT_HAVE_gcc-jit_context_new_bitcast > was earlier located in the documentation comment for > gcc_jit_context_new_bitcast, making it unavailable to code that > consumed libgccjit.h. This patch moves the

Re: [PATCH 6/7] jit,docs: use :expr:`type *` for pointers to a type

2022-07-25 Thread David Malcolm via Gcc-patches
On Mon, 2022-07-25 at 14:39 +0200, Martin Liska wrote: > gcc/jit/ChangeLog: > > * docs/cp/intro/tutorial02.rst: Use :expr:`type *` for > pointers to a type > * docs/cp/topics/asm.rst: Likewise. > * docs/cp/topics/contexts.rst: Likewise. > *

Re: [PATCH 5/7] jit,docs: use list-table instead of fixed table

2022-07-25 Thread David Malcolm via Gcc-patches
On Mon, 2022-07-25 at 12:35 +0200, Martin Liska wrote: > Use rather list-table that is easible to maintainer and one > does not have to wrap lines. Moreover, it provides great > attribute :widths: that correctly works (tested for HTML and PDF). > > gcc/jit/ChangeLog: > > *

Re: [PATCH 4/7] jit,docs: compact function declarations

2022-07-25 Thread David Malcolm via Gcc-patches
On Mon, 2022-07-25 at 11:51 +0200, Martin Liska wrote: > gcc/jit/ChangeLog: > > * docs/cp/topics/expressions.rst: Compact so that the > generated > output is also more compact. OK; thanks Dave

Re: [PATCH 3/7] jit,docs: various fixes

2022-07-25 Thread David Malcolm via Gcc-patches
On Mon, 2022-07-25 at 11:15 +0200, Martin Liska wrote: > gcc/jit/ChangeLog: > > * docs/cp/intro/tutorial02.rst: Use proper reference. > * docs/cp/topics/contexts.rst: Likewise. > * docs/cp/topics/functions.rst: Put `class` directive before > a > function as it is

Re: [PATCH 2/7] jit,docs: replace c:type:`int_type` with :expr:`int_type`

2022-07-25 Thread David Malcolm via Gcc-patches
On Mon, 2022-07-25 at 11:03 +0200, Martin Liska wrote: > Use expression that work fine for basic type. What's the motivation for this change? Surely the things being marked up are types, rather than expressions? Dave > > gcc/jit/ChangeLog: > > * docs/cp/topics/expressions.rst: Use

Re: [PATCH 1/7] jit,docs: use enum directive for enumeral types

2022-07-25 Thread David Malcolm via Gcc-patches
On Mon, 2022-07-25 at 10:52 +0200, Martin Liska wrote: > gcc/jit/ChangeLog: > > * docs/conf.py: Add needs_sphinx = '3.0' where c:type was > added. Looking at the footer of https://gcc.gnu.org/onlinedocs/jit/index.html I see we currently only have sphinx 1.7.6 installed. Have you been

Re: [PATCH] analyzer: fix coding style in sm-fd.cc

2022-07-25 Thread David Malcolm via Gcc-patches
On Mon, 2022-07-25 at 08:44 +0200, Martin Liška wrote: > Hi. > > First, thanks Mir for your contribution. The following patch > addresses > coding style issues I let you know in: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106003#c3 > > Most notably, I converted Windows endlines to Unix

Re: [PATCH] analyzer: convert tests with dos2unix

2022-07-25 Thread David Malcolm via Gcc-patches
On Mon, 2022-07-25 at 08:45 +0200, Martin Liška wrote: > Ready for master? Yes, thanks. Dave > Thanks, > Martin > > gcc/testsuite/ChangeLog: > > * gcc.dg/analyzer/fd-2.c: Convert Windows endlines to Unix > style. > * gcc.dg/analyzer/fd-3.c: Likewise. > *

Re: [PATCH] analyzer: add get_meaning_for_state_change vfunc to fd_diagnostic in sm-fd.cc [PR106286]

2022-07-23 Thread David Malcolm via Gcc-patches
On Sat, 2022-07-23 at 22:08 +0530, Immad Mir wrote: > This patch adds get_meaning_for_state_change vfunc to > fd_diagnostic in sm-fd.cc which could be used by SARIF output. > > Lightly tested in x86_64 Linux. > > gcc/analyzer/ChangeLog: > PR analyzer/106286 > * sm-fd.cc: >    

[committed] analyzer: fix state explosion on va_arg [PR106413]

2022-07-22 Thread David Malcolm via Gcc-patches
Fix state explosion on va_arg when the call to va_start is in the top-level function of the analysis. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-1807-g6d5194a10dc103. gcc/analyzer/ChangeLog: PR analyzer/106413 * varargs.cc

[committed] analyzer: fix ICE in binding_cluster ctor [PR106401]

2022-07-22 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-1806-g0fb35a45a28c67. gcc/analyzer/ChangeLog: PR analyzer/106401 * store.cc (binding_cluster::binding_cluster): Remove overzealous assertion; we're checking for tracked_p in

Re: [PATCH] Adding three new function attributes for static analysis of file descriptors

2022-07-22 Thread David Malcolm via Gcc-patches
On Fri, 2022-07-22 at 21:25 +0530, Immad Mir wrote: > This patch adds three new function attributes to GCC that > are used for static analysis of usage of file descriptors: > > 1) __attribute__ ((fd_arg(N))): The attributes may be applied to a > function that > takes an open file descriptor at

Re: [r13-1786 Regression] FAIL: gcc.dg/analyzer/stdarg-3.c (test for excess errors) on Linux/x86_64

2022-07-22 Thread David Malcolm via Gcc-patches
On Thu, 2022-07-21 at 18:35 -0700, skpan...@sc.intel.com wrote: > On Linux/x86_64, > > b852aa7f265424c8e2036899da5d8306ff06a16c is the first bad commit > commit b852aa7f265424c8e2036899da5d8306ff06a16c > Author: David Malcolm > Date:   Thu Jul 21 17:29:26 2022 -0400 > >     analyzer: fix

Re: [PATCH] Fix handling of zero capacity regions in -Wanalyzer-allocation-size [PR106394]

2022-07-22 Thread David Malcolm via Gcc-patches
On Fri, 2022-07-22 at 16:27 +0200, Tim Lange wrote: > This patch unifies the handling of zero capacity regions for structs > and other types in the allocation size checker. > Regression-tested on x86_64 Linux. Thanks; looks good for trunk. Dave

[committed] analyzer: fix -Wanalyzer-va-list-exhausted false +ve on va_arg in subroutine [PR106383]

2022-07-21 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-1786-gb852aa7f265424. gcc/analyzer/ChangeLog: PR analyzer/106383 * varargs.cc (region_model::impl_call_va_arg): When determining if we're doing interprocedural analysis, use the stack

[committed] analyzer: bulletproof taint warnings against NULL m_arg

2022-07-20 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-1774-g742377ed0f0931. gcc/analyzer/ChangeLog: * sm-taint.cc (tainted_array_index::emit): Bulletproof against NULL m_arg. (tainted_array_index::describe_final_event): Likewise.

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