{"id":2196538,"url":"http://patchwork.ozlabs.org/api/1.0/patches/2196538/?format=json","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/1.0/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20260214155201.1049644-4-dmalcolm@redhat.com>","date":"2026-02-14T15:51:59","name":"[3/5] json: split out replayer_location_map from libsarifreplay.cc","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"1333ab358860c279489fe518cae3cae817c88781","submitter":{"id":24465,"url":"http://patchwork.ozlabs.org/api/1.0/people/24465/?format=json","name":"David Malcolm","email":"dmalcolm@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/20260214155201.1049644-4-dmalcolm@redhat.com/mbox/","series":[{"id":492183,"url":"http://patchwork.ozlabs.org/api/1.0/series/492183/?format=json","date":"2026-02-14T15:51:56","name":"Improve diagnostics for bad JSON inputs [PR124094]","version":1,"mbox":"http://patchwork.ozlabs.org/series/492183/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2196538/checks/","tags":{},"headers":{"Return-Path":"<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":["incoming@patchwork.ozlabs.org","gcc-patches@gcc.gnu.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","gcc-patches@gcc.gnu.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=hJPMWT4z;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n\tdkim=pass (1024-bit key,\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=hJPMWT4z","sourceware.org; dmarc=pass (p=quarantine dis=none)\n header.from=redhat.com","sourceware.org; spf=pass smtp.mailfrom=redhat.com","server2.sourceware.org;\n arc=none smtp.remote-ip=170.10.133.124"],"Received":["from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fCtrZ4l7Hz1xwj\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 15 Feb 2026 02:54:22 +1100 (AEDT)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 6BE2E4BAD158\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 14 Feb 2026 15:54:20 +0000 (GMT)","from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.133.124])\n by sourceware.org (Postfix) with ESMTP id 9F7214BAD167\n for <gcc-patches@gcc.gnu.org>; Sat, 14 Feb 2026 15:52:24 +0000 (GMT)","from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-6-hL_1sT9uMYC_fw3-BZJCvQ-1; Sat,\n 14 Feb 2026 10:52:22 -0500","from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id 9C6911955D88; Sat, 14 Feb 2026 15:52:19 +0000 (UTC)","from t14s.localdomain.com (unknown [10.22.88.22])\n by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id ADCE61955D71; Sat, 14 Feb 2026 15:52:16 +0000 (UTC)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 6BE2E4BAD158","OpenDKIM Filter v2.11.0 sourceware.org 9F7214BAD167"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 9F7214BAD167","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 9F7214BAD167","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1771084344; cv=none;\n b=nh113gc4J5siOZ5XfwO6cH5NkyIc1CJ+Zzc7eY+kCMiWnJQ0liTj2g8cLqvt8prGhHygQ430VgpLckT80qTUGv1KmZd9FTGZhlgVKZPLPkMu2nhRIyCY3eEkpf5Mj54M2hch3g6u/I9cF8PsrcIMRgrMj61D+7H+O3mmHiset0A=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1771084344; c=relaxed/simple;\n bh=0lKZ/dKY7y8lKcvYiITAaCCSFGVfr3gaVz8F9hniX3k=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=YbH3C/OCgmn0S8nRhVgXN9MFi09ciAN/7JIukXK6UUu9KQBhGMRxDxa+4UM2umcdGWzGt1jebFrFqxyKPqdRr1qMgu9DU+gH/ydUBzzYVb2wW3iqAsb9fzjmrNvYlM1EfH4gwumpUAmjKqck+9WSH35zuoQ0Dg/ozkuEDe3+klo=","ARC-Authentication-Results":"i=1; server2.sourceware.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1771084344;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=9tQ+rJ3wG3wwfNa0n8CW7cAyYi7uiIVvyo/LBmQSF4E=;\n b=hJPMWT4zQOrccy39U8GgASdgCxqoyzjJzfjoSg5XTQUgWIZhEfPwSX3yjm/rHxWWH/TtVI\n E9w2k/RhwI6B0gG+nOX5Wvrp7mzjhWkj33hoHQU/qNAT4N9usdsH4vGRpyM9P9dBnLaqyQ\n eip16fV/Gx+Xmfv8dAPyjtuFUZbvMlw=","X-MC-Unique":"hL_1sT9uMYC_fw3-BZJCvQ-1","X-Mimecast-MFC-AGG-ID":"hL_1sT9uMYC_fw3-BZJCvQ_1771084340","From":"David Malcolm <dmalcolm@redhat.com>","To":"gcc-patches@gcc.gnu.org, Yangyu Chen <cyy@cyyself.name>,\n Soumya AR <soumyaa@nvidia.com>, jakub@redhat.com,\n Richard Biener <richard.guenther@gmail.com>","Cc":"Alfie Richards <alfie.richards@arm.com>,\n Sandra Loosemore <sloosemore@baylibre.com>,\n Martin Liska <martin.liska@hey.com>,\n Evgeny Stupachenko <evstupac@gmail.com>,\n Alice Carlotti <alice.carlotti@arm.com>,\n Jeff Law <jeffrey.law@oss.qualcomm.com>,\n Jerry DeLisle <jvdelisle@gcc.gnu.org>, Harald Anlauf <anlauf@gmx.de>,\n Paul Thomas <pault@gcc.gnu.org>,\n Richard Sandiford <rdsandiford@googlemail.com>,\n Joseph Myers <josmyers@redhat.com>, Jason Merrill <jason@redhat.com>,\n David Malcolm <dmalcolm@redhat.com>","Subject":"[PATCH 3/5] json: split out replayer_location_map from\n libsarifreplay.cc","Date":"Sat, 14 Feb 2026 10:51:59 -0500","Message-ID":"<20260214155201.1049644-4-dmalcolm@redhat.com>","In-Reply-To":"<20260214155201.1049644-1-dmalcolm@redhat.com>","References":"<tencent_048DF6A8630E2E590C79C840A31F1FA86006@qq.com>\n <20260214155201.1049644-1-dmalcolm@redhat.com>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.0 on 10.30.177.17","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"CNx9nIpibnHAVqf6aZEUNBou7ptsQ7c2akUf-zYHNLc_1771084340","X-Mimecast-Originator":"redhat.com","Content-Transfer-Encoding":"8bit","content-type":"text/plain; charset=\"US-ASCII\"; x-default=true","X-BeenThere":"gcc-patches@gcc.gnu.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Gcc-patches mailing list <gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <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>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>","Errors-To":"gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"},"content":"No functional change intended, but make this code usable elsewhere.\n\ngcc/ChangeLog:\n\t* config/aarch64/aarch64-json-tunings-parser.cc: Define\n\tINCLUDE_MAP.\n\t* json-parsing.cc: Likewise.\n\t* json-parsing.h (class simple_location_map): New class, moved and\n\trenamed from...\n\t* libsarifreplay.cc (class replayer_location_map): ...here.\n\t(sarif_replayer::m_json_location_map): Update for renaming of\n\tclass.\n\nSigned-off-by: David Malcolm <dmalcolm@redhat.com>\n---\n .../aarch64/aarch64-json-tunings-parser.cc    |  3 ++-\n gcc/json-parsing.cc                           |  1 +\n gcc/json-parsing.h                            | 24 +++++++++++++++++++\n gcc/libsarifreplay.cc                         | 23 +-----------------\n 4 files changed, 28 insertions(+), 23 deletions(-)","diff":"diff --git a/gcc/config/aarch64/aarch64-json-tunings-parser.cc b/gcc/config/aarch64/aarch64-json-tunings-parser.cc\nindex 59c745e347ef2..326d52e02d1ce 100644\n--- a/gcc/config/aarch64/aarch64-json-tunings-parser.cc\n+++ b/gcc/config/aarch64/aarch64-json-tunings-parser.cc\n@@ -17,6 +17,7 @@\n    along with GCC; see the file COPYING3.  If not see\n    <http://www.gnu.org/licenses/>.  */\n \n+#define INCLUDE_MAP\n #define INCLUDE_STRING\n #define INCLUDE_VECTOR\n #define INCLUDE_TYPE_TRAITS\n@@ -627,4 +628,4 @@ aarch64_json_tunings_tests ()\n #undef STR\n #undef STR_\n \n-#endif /* CHECKING_P */\n\\ No newline at end of file\n+#endif /* CHECKING_P */\ndiff --git a/gcc/json-parsing.cc b/gcc/json-parsing.cc\nindex b3711e50f11f5..88c515e3f8606 100644\n--- a/gcc/json-parsing.cc\n+++ b/gcc/json-parsing.cc\n@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License\n along with GCC; see the file COPYING3.  If not see\n <http://www.gnu.org/licenses/>.  */\n \n+#define INCLUDE_MAP\n #include \"config.h\"\n #include \"system.h\"\n #include \"coretypes.h\"\ndiff --git a/gcc/json-parsing.h b/gcc/json-parsing.h\nindex 2b698bcaaf55e..7721dc88c2396 100644\n--- a/gcc/json-parsing.h\n+++ b/gcc/json-parsing.h\n@@ -55,6 +55,30 @@ public:\n   virtual void on_finished_parsing () {}\n };\n \n+/* Implementation of json::location_map that records ranges to a std::map.  */\n+\n+class simple_location_map : public location_map\n+{\n+public:\n+  void\n+  record_range_for_value (json::value *jv,\n+\t\t\t  const range &r) final override\n+  {\n+    m_map_jv_to_range[jv] = r;\n+  }\n+\n+  const json::location_map::range &\n+  get_range_for_value (const json::value &jv) const\n+  {\n+    auto iter = m_map_jv_to_range.find (&jv);\n+    gcc_assert (iter != m_map_jv_to_range.end ());\n+    return iter->second;\n+  }\n+\n+private:\n+  std::map<const json::value *, range> m_map_jv_to_range;\n+};\n+\n /* Class for recording an error within a JSON file.  */\n \n class error\ndiff --git a/gcc/libsarifreplay.cc b/gcc/libsarifreplay.cc\nindex 966e181fa0c58..9cc37fc770855 100644\n--- a/gcc/libsarifreplay.cc\n+++ b/gcc/libsarifreplay.cc\n@@ -316,27 +316,6 @@ public:\n \t\t\t   const replay_options &replay_opts);\n \n private:\n-  class replayer_location_map : public json::location_map\n-  {\n-  public:\n-    void record_range_for_value (json::value *jv,\n-\t\t\t\t const range &r) final override\n-    {\n-      m_map_jv_to_range[jv] = r;\n-    }\n-\n-    const json::location_map::range &\n-    get_range_for_value (const json::value &jv) const\n-    {\n-      auto iter = m_map_jv_to_range.find (&jv);\n-      gcc_assert (iter != m_map_jv_to_range.end ());\n-      return iter->second;\n-    }\n-\n-  private:\n-    std::map<const json::value *, range> m_map_jv_to_range;\n-  };\n-\n   enum status emit_sarif_as_diagnostics (const json::value &jv);\n \n   libgdiagnostics::message_buffer\n@@ -743,7 +722,7 @@ private:\n   /* The file within m_control_mgr representing the .sarif file.  */\n   libgdiagnostics::file m_loaded_file;\n \n-  replayer_location_map m_json_location_map;\n+  json::simple_location_map m_json_location_map;\n \n   const json::object *m_driver_obj;\n   const json::array *m_artifacts_arr;\n","prefixes":["3/5"]}