From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 C09633849AEE for ; Wed, 10 Apr 2024 20:56:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C09633849AEE 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 C09633849AEE 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=xa2d0v03s70gZFyde2O1kKPWw/YSpvzwnYR2L8m+VFse0wc/jGQX0kf7azhRUJ7zStA9kKKlsTfdnW43UbwYN5d+P97UFJkx06oP/a1R3v8XzuU3Uz6Dcs+N/3f3PxcW32HGFsty6oyAY+w7kj+oKilFtWdqGFzba2huRbbPeXI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712782586; c=relaxed/simple; bh=DxODKV0TMRK6wN+XIQrbFiOn2kFNMMQVnkSS8MHRdts=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=pFGcHLejPRvoW9OmhWCgb76fUS60mF2aFJdcCpmnAbsNNT59fl741jvEz89wDOxKoe5fbeq06eg/++A8gM9amPkLcGiLftXYGChpUayQqSSujBhhnpmyyxS42pg15LSp68+BWmbABRe2CerBcUHIREFrXJhfrRfbXHiEbpf3HpE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712782580; 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=NGPmJHCbgkck/tMtVuh0wIvjoNZO0wVUkXT/gUjIp/M=; b=RMDG8Qf6Nq/26ifpxEkRS/nllGO9F0l+Wu9syLZdN4FU3iQ9LvQJQzY84djXdwOvg6TmAP N/+1vpRqc4aUUqOdKVnEyxaoW7Bn3VsvGrEpGYzYq9zNarCSzDHjdb5cGTXtBpTCLVeEc9 l+QrnDh5vkODqlisGpys0u73AekBiIw= 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-57-oZ4CGY_gM6K7Y4_GpZmESw-1; Wed, 10 Apr 2024 16:56:16 -0400 X-MC-Unique: oZ4CGY_gM6K7Y4_GpZmESw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (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 A15EB806602 for ; Wed, 10 Apr 2024 20:56:16 +0000 (UTC) Received: from t14s.localdomain.com (unknown [10.22.33.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D1D92026D06; Wed, 10 Apr 2024 20:56:16 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [pushed] analyzer: add SARIF property bag to -Wanalyzer-infinite-loop Date: Wed, 10 Apr 2024 16:56:15 -0400 Message-Id: <20240410205615.335813-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 List-Id: 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-9901-g107b0e63be023c. gcc/analyzer/ChangeLog: * infinite-loop.cc: Include "diagnostic-format-sarif.h". (infinite_loop::to_json): New. (infinite_loop_diagnostic::maybe_add_sarif_properties): New. Signed-off-by: David Malcolm --- gcc/analyzer/infinite-loop.cc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/gcc/analyzer/infinite-loop.cc b/gcc/analyzer/infinite-loop.cc index 296489b1146d..e277a8384a04 100644 --- a/gcc/analyzer/infinite-loop.cc +++ b/gcc/analyzer/infinite-loop.cc @@ -63,6 +63,7 @@ along with GCC; see the file COPYING3. If not see #include "analyzer/checker-path.h" #include "analyzer/feasible-graph.h" #include "make-unique.h" +#include "diagnostic-format-sarif.h" /* A bundle of data characterizing a particular infinite loop identified within the exploded graph. */ @@ -105,6 +106,18 @@ struct infinite_loop && m_loc == other.m_loc); } + json::object * + to_json () const + { + json::object *loop_obj = new json::object (); + loop_obj->set_integer ("enode", m_enode.m_index); + json::array *edge_arr = new json::array (); + for (auto eedge : m_eedge_vec) + edge_arr->append (eedge->to_json ()); + loop_obj->set ("eedges", edge_arr); + return loop_obj; + } + const exploded_node &m_enode; location_t m_loc; std::vector m_eedge_vec; @@ -297,6 +310,15 @@ public: } } + 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_loop_diagnostic/" + props.set (PROPERTY_PREFIX "inf_loop", m_inf_loop->to_json ()); +#undef PROPERTY_PREFIX + } + private: std::unique_ptr m_inf_loop; }; -- 2.26.3