From patchwork Wed Apr 10 20:56:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 1922232 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=E8asjzoR; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VFFZy3dr4z1yY8 for ; Thu, 11 Apr 2024 07:00:10 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4CB41384AB63 for ; Wed, 10 Apr 2024 21:00:08 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 74E4A384AB4E for ; Wed, 10 Apr 2024 20:56:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 74E4A384AB4E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 74E4A384AB4E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712782586; cv=none; b=VWYpxQgbrxRRskMGocyuzHBf8ryOZxw+6yHIou2lct19uWKQiwq4m5u0tN4CQWpLYoDyxEnHHbECbnrTXX68zCnkM3FV++FNQXDQPbam6/phuMoIHEdB7+qp0SN3ywAanajEXQ3reHQjZTEzsI9Y7XJY4rgbYtknK2uRRP8I0XA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712782586; c=relaxed/simple; bh=LVxR9R3EVZUeV22GrA4IAhwGRSB8n9NZMuaa2DXikd4=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=IvDrqFbs2vW4YIpoc62eJGPVV9se5twjPtUpjmgS41bEKfRfmENBhH7/41IbemYUauGvLHJlUzgJProS2qMGCus270MtFVgZF3JJSWhMhaH/8p9RKUdaKeRosiuvBjLyXcqnCzZh1YIy0SyAlLaiEXkhY3GQfsdzGVGLXByGYuM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712782575; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cH3xCWgS2AtggYdxv4GIfPIMSyg/PMtR9rtWmMt8634=; b=E8asjzoR3jD4/aINbHt1Ro4aWGTEwCX5n9g/HbXv3/eQfPTqQEcNPF/yGEKRYM9OmbaZ6U ue38UENTewP7gMK4MUqju2ldRjDpLGyl++PIavQ2lcGXRwk3gaIcSu6xvOtMIuVPQU9lOa QmLTGw81VItONesf0x2liH39qrzqbxI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-43-lOKGE8cuOMikI7N2Y4u5BQ-1; Wed, 10 Apr 2024 16:56:13 -0400 X-MC-Unique: lOKGE8cuOMikI7N2Y4u5BQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 33A971049B80 for ; Wed, 10 Apr 2024 20:56:13 +0000 (UTC) Received: from t14s.localdomain.com (unknown [10.22.33.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E39F444FE2; Wed, 10 Apr 2024 20:56:13 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [pushed] analyzer: add SARIF property bag to -Wanalyzer-infinite-recursion Date: Wed, 10 Apr 2024 16:56:11 -0400 Message-Id: <20240410205611.335787-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Tested lightly by hand. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Successful run of analyzer integration tests on x86_64-pc-linux-gnu. Pushed to trunk as r14-9900-g960e07d73a5295. gcc/analyzer/ChangeLog: * infinite-recursion.cc: Include "diagnostic-format-sarif.h". (infinite_recursion_diagnostic::maybe_add_sarif_properties): New. Signed-off-by: David Malcolm --- gcc/analyzer/infinite-recursion.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gcc/analyzer/infinite-recursion.cc b/gcc/analyzer/infinite-recursion.cc index 112e4bd08f28..65f136ddad6b 100644 --- a/gcc/analyzer/infinite-recursion.cc +++ b/gcc/analyzer/infinite-recursion.cc @@ -62,6 +62,7 @@ along with GCC; see the file COPYING3. If not see #include "make-unique.h" #include "analyzer/checker-path.h" #include "analyzer/feasible-graph.h" +#include "diagnostic-format-sarif.h" /* A subclass of pending_diagnostic for complaining about suspected infinite recursion. */ @@ -236,6 +237,18 @@ public: return false; } + void maybe_add_sarif_properties (sarif_object &result_obj) + const final override + { + sarif_property_bag &props = result_obj.get_or_create_properties (); +#define PROPERTY_PREFIX "gcc/analyzer/infinite_recursion_diagnostic/" + props.set_integer (PROPERTY_PREFIX "prev_entry_enode", + m_prev_entry_enode->m_index); + props.set_integer (PROPERTY_PREFIX "new_entry_enode", + m_new_entry_enode->m_index); +#undef PROPERTY_PREFIX + } + private: /* Return true iff control flow along FEDGE was affected by a conjured_svalue. */