public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: mirimnan017@gmail.com, gcc-patches@gcc.gnu.org
Cc: Immad Mir <mirimmad@outlook.com>
Subject: Re: [PATCH] analyzer: add get_meaning_for_state_change vfunc to fd_diagnostic in sm-fd.cc [PR106286]
Date: Sat, 23 Jul 2022 13:43:21 -0400	[thread overview]
Message-ID: <51c80ff004ad34c7c6637d7e7229be1836e8d02f.camel@redhat.com> (raw)
In-Reply-To: <CY4PR1801MB1910FCEE8DA71141850C1B34C6939@CY4PR1801MB1910.namprd18.prod.outlook.com>

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:
>         (fd_diagnostic::get_meaning_for_state_change): New.
> 
> Signed-off-by: Immad Mir <mirimmad@outlook.com>
> ---
>  gcc/analyzer/sm-fd.cc | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/gcc/analyzer/sm-fd.cc b/gcc/analyzer/sm-fd.cc
> index c3dac48509e..f77b1f4d3e2 100644
> --- a/gcc/analyzer/sm-fd.cc
> +++ b/gcc/analyzer/sm-fd.cc
> @@ -229,6 +229,22 @@ public:
>      return label_text ();
>    }
>  
> +  diagnostic_event::meaning
> +  get_meaning_for_state_change (
> +      const evdesc::state_change &change) const final override
> +  {
> +    if (change.m_old_state == m_sm.get_start_state ()
> +            && (change.m_new_state == m_sm.m_unchecked_read_write
> +        || change.m_new_state == m_sm.m_unchecked_read_only
> +        || change.m_new_state == m_sm.m_unchecked_write_only))

I think you can simplify this by using:

   m_sm.is_unchecked_fd_p (change.m_new_state)

for the right-hand side of the &&.


[...snip...]

Other than that, patch looks OK, but please add a test case for this
e.g. "fd-meaning.c"; see:

  gcc/testsuite/gcc.dg/analyzer/file-meaning-1.c

for an analogous one for the sm-file.cc (since otherwise it's too easy
for this kind of thing to regress).

Dave


  reply	other threads:[~2022-07-23 17:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-23 16:38 Immad Mir
2022-07-23 17:43 ` David Malcolm [this message]
2022-07-26 16:37 Immad Mir
2022-07-26 16:42 ` David Malcolm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51c80ff004ad34c7c6637d7e7229be1836e8d02f.camel@redhat.com \
    --to=dmalcolm@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mirimmad@outlook.com \
    --cc=mirimnan017@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).