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

2022-08-15 Thread Immad Mir via Gcc-patches
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): exit early if first argument is invalid for all dup functions

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

2022-08-11 Thread Immad Mir via Gcc-patches
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 (check_for_dup): handle the m_start state when transitioning th

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

2022-08-10 Thread Immad Mir via Gcc-patches
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 (check_for_dup): handle the m_start state when transitioning th

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

2022-08-09 Thread Immad Mir via Gcc-patches
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 (check_for_dup): handle the m_start state when transitioning th

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

2022-08-09 Thread Immad Mir via Gcc-patches
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 (check_for_dup): handle the m_start state when transitioning th

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

2022-07-29 Thread Immad Mir via Gcc-patches
This patch extends the state machine in sm-fd.cc to support creat, dup, dup2 and dup3 functions. Lightly tested on x86_64 Linux. gcc/analyzer/ChangeLog: PR analyzer/106300 * sm-fd.cc (fd_state_machine::on_open): Add creat, dup, dup2 and dup3 functions. (enum dup):

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

2022-07-26 Thread Immad Mir via Gcc-patches
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. gcc/analyzer/ChangeLog: PR analyzer/106286 * sm-fd.cc: (fd_diagnostic::get_meaning_for_state_change): New. gcc/testsuite/Ch

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

2022-07-25 Thread Immad Mir via Gcc-patches
Thanks for this. I’ll keep this in mind for future patches. Immad. Sent from Mail for Windows 10 From: Martin Liška Sent: 25 July 2022 12:14 PM To: gcc-patches@gcc.gnu.org Cc: mirim...@outlook

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

2022-07-23 Thread Immad Mir via Gcc-patches
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: (fd_diagnostic::get_meaning_for_state_change): New. Signed-off-by: I

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

2022-07-22 Thread Immad Mir via Gcc-patches
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 refrenced argument N. It indicates that the passed filedescriptor

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

2022-07-20 Thread Immad Mir via Gcc-patches
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 on open file descriptor at refrenced argument N. It indicates that the passed filedescriptor

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

2022-07-19 Thread Immad Mir via Gcc-patches
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 on open file descriptor at refrenced argument N. It indicates that the passed filedescriptor

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

2022-07-15 Thread Immad Mir via Gcc-patches
--- gcc/analyzer/sm-fd.cc| 257 --- gcc/c-family/c-attribs.cc| 115 gcc/doc/extend.texi | 19 ++ gcc/testsuite/gcc.dg/analyzer/fd-5.c | 53 ++ gcc/testsuite/gcc.dg/analyzer/fd-6.c | 14 ++ 5 files changed, 431

[PATCH 2/3] analyzer: reorder initialization of state m_invalid in sm-fd.cc [PR106184]

2022-07-06 Thread Immad Mir via Gcc-patches
From: Immad Mir This patch reorders the initialization of state m_invalid in sm-fd.cc to conform with standard practice in C++. gcc/analyzer/ChangeLog: PR analyzer/106184 * sm-fd.cc (fd_state_machine): Change ordering of initialization of state m_invalid. Signed-off-by:

[PATCH 3/3] analyzer: add a new testcase to demonstrate passsing of a file descriptor to a function that does not emit any warning

2022-07-06 Thread Immad Mir via Gcc-patches
gcc/testsuite/ChangeLog: * gcc.dg/analyzer/fd-4.c: Add a new testcase to demonstrate passsing of a file descriptor to a function that does not emit any warning. Signed-off-by: Immad Mir --- gcc/testsuite/gcc.dg/analyzer/fd-4.c | 10 ++ 1 file changed, 10 insertions(+) di

[PATCH 1/3] analyzer: show close event for use_after_close diagnostic

2022-07-06 Thread Immad Mir via Gcc-patches
From: Immad Mir This patch saves the "close" event in use_after_close diagnostic and shows it where possible. gcc/analyzer/ChangeLog: * sm-fd.cc (use_after_close): save the "close" event and show it where possible. gcc/testsuite/ChangeLog: * gcc.dg/analyzer/fd-4.c (test_