analyzer: add get_meaning_for_state_change vfunc to fd_diagnostic in sm-fd.cc [PR106286]
Message ID | CY4PR1801MB1910FCEE8DA71141850C1B34C6939@CY4PR1801MB1910.namprd18.prod.outlook.com |
---|---|
State | New, archived |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f503:0:0:0:0:0 with SMTP id q3csp749923wro; Sat, 23 Jul 2022 09:39:48 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uyKW6D/MXrEHi/ch/MEZw0mVpL66xnN+A2l/SRJbRR9x9tnXfQDLzoXdJs+r6C/0bWF/+A X-Received: by 2002:a05:6402:2891:b0:43b:c2a5:dbd0 with SMTP id eg17-20020a056402289100b0043bc2a5dbd0mr5077823edb.96.1658594388580; Sat, 23 Jul 2022 09:39:48 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id qa30-20020a170907869e00b0072f0a99a61asi9998620ejc.617.2022.07.23.09.39.48 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Jul 2022 09:39:48 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=hyxrSriU; arc=fail (signature failed); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1E8513857C5D for <ouuuleilei@gmail.com>; Sat, 23 Jul 2022 16:39:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1E8513857C5D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1658594387; bh=rPVYNiHKnvw8aI66cvUsZEvFoAjFJNabZKIq8cKm66E=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=hyxrSriUMkEdmmduR7xktn/PbWYxncW3Wv0sBP6x8ggbcZPs0qpJ1igfuLmcqCuJo 9rLmQCRUXLol0EPQkkrBrOiXfqc+JcVDrZHC7DQnYrltye0TT1GUa/Hf8JSGVCP+5p F/TnHnV1D/qo73XsX/wjztIPWjXoBkEGPtkgd5jU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12olkn2039.outbound.protection.outlook.com [40.92.21.39]) by sourceware.org (Postfix) with ESMTPS id BC625385803B for <gcc-patches@gcc.gnu.org>; Sat, 23 Jul 2022 16:39:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BC625385803B ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y6rh/g7OpPE3rkTaBqNDuxvfnowerpFYgvSxXCqGeTOpDJAeZzpN0UQhjqtdjzDgbBhSIOs+e9FXGsOcBB/mqvyo86t8dNzC60CdT7qghU7E6m5IKGqRN9hxdCr0Ti27FS0/OOJs1BkXz8Og5i7sigW7yrFFH0sUqLEtJf+89KkCOg2d/mcJuVc78KiKgqRNVNueP2Pzn1ZuE+aGueAAbXg+7+UGAz1wCos/3b8imMBnEOS6q4KyrLUVI20D564LVGkC7+Qytyc+efuKnnsy5iI5QOPlG+rk0VgBEBoxdF+2XqG8+06k/1eKxlEAj71lCD8BuJHuRP7DbT7/8xcfkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rPVYNiHKnvw8aI66cvUsZEvFoAjFJNabZKIq8cKm66E=; b=RG2DQVOwp1wbqavkmLKV2W3POgZaIhxT+7L/XawMFqaMejzKrmaDdwhyyP+2hhXqZtdqBDO62pRQvpEGn8Pg8Xx/pgx+ejD170Ykz7J9pcO6Qsy3hxnCJZgu9Evu7KPQc4UTv9Fw1uQ0mXILJQ741GLPuHu3sEC/5bouj+cxlp/GISws1xhMa7t0Qo1TZNUfiThLnJ1SnzLzBvr6KtMiKTXI23xJs7RaD+iQOaHS8yP65yXRABNV9uNFgGbXgxpiF6ii8+9SdSTYhjp5Z2LElJumSeRKcwItIPgW4oKwIkxZstuDaBu/tzpd3BltORBn3vYH4Jw//u2ovR2E3BbdJg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from CY4PR1801MB1910.namprd18.prod.outlook.com (2603:10b6:910:79::14) by MWHPR18MB1389.namprd18.prod.outlook.com (2603:10b6:320:29::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.21; Sat, 23 Jul 2022 16:39:00 +0000 Received: from CY4PR1801MB1910.namprd18.prod.outlook.com ([fe80::4d74:63e5:d5ee:3647]) by CY4PR1801MB1910.namprd18.prod.outlook.com ([fe80::4d74:63e5:d5ee:3647%2]) with mapi id 15.20.5458.021; Sat, 23 Jul 2022 16:39:00 +0000 To: gcc-patches@gcc.gnu.org Subject: [PATCH] analyzer: add get_meaning_for_state_change vfunc to fd_diagnostic in sm-fd.cc [PR106286] Date: Sat, 23 Jul 2022 22:08:29 +0530 Message-ID: <CY4PR1801MB1910FCEE8DA71141850C1B34C6939@CY4PR1801MB1910.namprd18.prod.outlook.com> X-Mailer: git-send-email 2.25.1 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-TMN: [DopITm+zdWv4lELGtiZt/T9X8+GYqEbYP2kaW7bB3k0P6Ffi8j9/6QR6sVJMXUTD] X-ClientProxiedBy: PN0PR01CA0003.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:4f::8) To CY4PR1801MB1910.namprd18.prod.outlook.com (2603:10b6:910:79::14) X-Microsoft-Original-Message-ID: <20220723163829.6843-1-mirimmad@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f411b5e9-29f2-45ac-775f-08da6cc9d60f X-MS-Exchange-SLBlob-MailProps: aa/WAlXx4eSinjOTp7Mq2Y7qJigwaX1uZBj9vMmcX+5tRVcBNSq3aoV0HZE8WSq6O7Mt3UD5tSCHTvkipjVU+vN28k+ZyPulShSyFfHldK/KRgCuTQ31MCI6OtH2G90XP06v6LM0UDv9ofj/LojmmXK+q8uiBXotk/AbylJMFRPjWPQ7kROl7xx6hKL5DCZ0LYDj+H2SupO2tlYSXuBq1ATM0lMpWREVJM0MCe1J21AjptZQ8TRSlTJxl8woptrD3oiHhAh6YZ5j9o4mESHqhxa58z9+ZYSLT63/dlPxSK67KDKoWS1EAZMHWE2OKZi5CjBhfqGGWk198kmoEx1aKWVyMVPgzzEv219TzvWZff6Wq4mJK8RdSCjPaKVu4l6uqc7CAlSLaOzqXu6EK9Kv0Ib/iX7X5OtsIOluc/wOV8Mt6eNrI5H7Sw80YyzW8SWLeh1tJcFFJTE4RuCJIW2S6tp//A0u9NraDidG4QUeGf8PkVpo0ogCK7DYtUZxbkfK4jCwrjkpeA0BHw6sZYjuIIM8PP91qyhblK62bMHfnK2FG9+71o2XN7ybIJN4oSkrQUluNR5CVZnUtfatgCddqcMNzlVdTpAxvJGrz1aQmdXBGeeHpdqZkA0fmAjzBIpGKCuYYnLmlNNfFEvbYaMhoMmUjsTjrjKn7H3zPiZzJNg5pAlnXgSG1k769bmkykC2SXNwHABx1n/X5gMXu5ST49w15+H2/QtE8Pig3J7LF/OLPDhHM5/Vr9tmO1L967TZdZUo2/3r3nVt5sziKfRmkpf6bbX6D0A2 X-MS-TrafficTypeDiagnostic: MWHPR18MB1389:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5oGQqNlz1oPz7Xta9um8+y1rOiy8t85WBaRQFCSmvekTsDvV6twXvDaf1AmQJFypjAHk/juQfJterYvHlypY/AmyN9HgFppbAGr7HlYoyxuvjQxV2yigMwGVdsMdhFk6ep5qmp/C+HH7pKUXFr5tGaKKU884ZRlmBAGHNh/izT8Gkj7zb3ajldJCu3hZggM7L41qbQZ4Gxu8uafDSaDlrVnGYigzUiKjgFCG83VKlPbruiP2C+QlluX3PCpEjA30MtSYmqjXQ92SlqBGKR/rhT3OJItQrOuC9H2yAXlyIglvrMvxiFcoqd8PnylKpBBra3542v02lMxLASOJuqLqF0qQPRiTcc0+RAjCdVgfgOwkBW3V4Q3ReQsxi6KK6sBqcNM0xp1xJ7bUBxdXRmlL668uMN+rP43uPWStPxnI7UM5xGF12vRyDC27m8Jtq+2mhAc6p+1iJr96dxI3/nF26FzZWY5Dl5SoSiIVUlUfbjnMoBcmWaGnFBxb9sq6g/QBZETCTRBOtLlpxpYqlpjVsSseYeYgDOUqWCJdnD/9zGq0KbDKEcXxjASmIfpM6+dHR4vI/kOfQ76LbbS5kKtERg5iAxwGwj2uXm7k+moCAvw870sghCgUHBQdjUvp6+6JGHmYmWyNKM7eDX8NBEUZkA== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iFhDFJRfXRGKoE+TiKqOndH9kKzQ3BJ8jMs+SrOm3fm+8EqI1UP6DnjpPrhW3LBE/LSirmrG7UGG8BY7vymF7twt7HXNS81twoXxRw/Mue8IahPx+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PkK7gojg+L3DYaPEpEggX2k4pBA1BQvmfTTuPCP1ZCiRi/HT4xpWS01iADs7XtUVf/ewaBmwEcHA8dc7yUEakMsaedZYm1tsaJi9zbbpNMMuGDNJ1+gtdDTZlf96yC6iIAjon38X14ZGChm/FuEdBQVe+etjUYk+V9bkeB+VE9bTuIbQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f411b5e9-29f2-45ac-775f-08da6cc9d60f X-MS-Exchange-CrossTenant-AuthSource: CY4PR1801MB1910.namprd18.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2022 16:38:59.7220 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR18MB1389 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, FREEMAIL_REPLYTO, FREEMAIL_REPLYTO_END_DIGIT, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Immad Mir via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: mirimnan017@gmail.com Cc: Immad Mir <mirimmad@outlook.com>, mirimnan017@gmail.com Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1739162269631870385?= X-GMAIL-MSGID: =?utf-8?q?1739162269631870385?= |
Series |
analyzer: add get_meaning_for_state_change vfunc to fd_diagnostic in sm-fd.cc [PR106286]
|
|
Commit Message
Li, Pan2 via Gcc-patches
July 23, 2022, 4:38 p.m. UTC
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(+)
Comments
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
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)) + return diagnostic_event::meaning (diagnostic_event::VERB_acquire, + diagnostic_event::NOUN_resource); + if (change.m_new_state == m_sm.m_closed) + return diagnostic_event::meaning (diagnostic_event::VERB_release, + diagnostic_event::NOUN_resource); + return diagnostic_event::meaning (); + } + protected: const fd_state_machine &m_sm; tree m_arg;