Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2196536/?format=api
{ "id": 2196536, "url": "http://patchwork.ozlabs.org/api/patches/2196536/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/20260214155201.1049644-3-dmalcolm@redhat.com/", "project": { "id": 17, "url": "http://patchwork.ozlabs.org/api/projects/17/?format=api", "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, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260214155201.1049644-3-dmalcolm@redhat.com>", "list_archive_url": null, "date": "2026-02-14T15:51:58", "name": "[2/5] diagnostics: split out physical_location_maker from libgdiagnostics", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "8480e8db19390e2fefdefd9bab6783f518328b20", "submitter": { "id": 24465, "url": "http://patchwork.ozlabs.org/api/people/24465/?format=api", "name": "David Malcolm", "email": "dmalcolm@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/20260214155201.1049644-3-dmalcolm@redhat.com/mbox/", "series": [ { "id": 492183, "url": "http://patchwork.ozlabs.org/api/series/492183/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=492183", "date": "2026-02-14T15:51:56", "name": "Improve diagnostics for bad JSON inputs [PR124094]", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/492183/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2196536/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2196536/checks/", "tags": {}, "related": [], "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=XOHbWlAd;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=38.145.34.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=XOHbWlAd", "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.129.124" ], "Received": [ "from vm01.sourceware.org (vm01.sourceware.org [38.145.34.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 4fCtqY4Pc7z1xwj\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 15 Feb 2026 02:53:29 +1100 (AEDT)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 8FA4E4BAD164\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 14 Feb 2026 15:53:27 +0000 (GMT)", "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.129.124])\n by sourceware.org (Postfix) with ESMTP id C8DF64BAD169\n for <gcc-patches@gcc.gnu.org>; Sat, 14 Feb 2026 15:52:24 +0000 (GMT)", "from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-373-xakbKt42PWqQ7XIoX6qMvQ-1; Sat,\n 14 Feb 2026 10:52:19 -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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id 87E9018003FC; Sat, 14 Feb 2026 15:52:16 +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 F400D1955D85; Sat, 14 Feb 2026 15:52:12 +0000 (UTC)" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org 8FA4E4BAD164", "OpenDKIM Filter v2.11.0 sourceware.org C8DF64BAD169" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org C8DF64BAD169", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org C8DF64BAD169", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1771084344; cv=none;\n b=q2fSvOBlnJ5y07O4AMx/ztGPDDnKMQP5n1dw9HbnKKKnLRcozsFOSYEoYOQSpMmE/rCCSVqT9S8Ex8V/6/bbQrGHPU7marBfkRiZcMTEuBWCVx0AFORUzngBWxL1cYJqMVtQT+1deCJgoCugI82ZwK5VOu5RLEkRmkLj8GpJGa0=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1771084344; c=relaxed/simple;\n bh=9eOrQ9XhzNZfOF76oKURA15gRhk83ghE+kzzVNyHeH4=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=XhS1lxttJ1X8OV69bwj7rrIYwImydvGAzC7TYjpxf23m7samb6bBMjeRsjw8+hwzBEe8QxYC9tMe5X/YNKxKGeVbhtVtmXHhRZt4RezzN4OZIHCsV/B9+S0NXKHkoFYdqGqrQO+xu242GU0HxCaxZ4U5qx9Xl9HaF6o161pB3cE=", "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=bG+iUVOP/xiQjlYGLfnTACeEjmhPohnLEiW5RkEO1bY=;\n b=XOHbWlAdORwRYAEEDry0R4Sfh+oA7ekL9c+gI4zc9oNDgbQ8jqRGjLdwb9OTPqd9jVeSym\n tsozG5sEU4BWVWp9HpEFAnEe8drzDJRphnHabGaI+EYG5XMY0NpXE9nqgyRI/jEvhaXgxU\n +XRtqa9FYCEsrCsF2Tv+wTpYxy9RiiU=", "X-MC-Unique": "xakbKt42PWqQ7XIoX6qMvQ-1", "X-Mimecast-MFC-AGG-ID": "xakbKt42PWqQ7XIoX6qMvQ_1771084337", "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 2/5] diagnostics: split out physical_location_maker from\n libgdiagnostics", "Date": "Sat, 14 Feb 2026 10:51:58 -0500", "Message-ID": "<20260214155201.1049644-3-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": "smkBrE0g6PpdE6OaeZrnBYgi0cKDIx_2lMQ5Xz2ntEo_1771084337", "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": "Make this code usable elsewhere.\nNo functional change intended.\n\ngcc/ChangeLog:\n\t* Makefile.in (OBJS-libcommon):\n\tAdd diagnostics/physical-location-maker.o.\n\t* diagnostics/physical-location-maker.cc: New file, adapted from\n\tmaterial in libgdiagnostics.cc.\n\t* diagnostics/physical-location-maker.h: New file, adapted from\n\tmaterial in libgdiagnostics.cc.\n\t* libgdiagnostics.cc: Include\n\t\"diagnostics/physical-location-maker.h\".\n\t(diagnostic_manager::diagnostic_manager): Initialize\n\tm_phys_loc_maker.\n\t(diagnostic_manager::new_location_from_file_and_line): Split out\n\tinto physical_location_maker.\n\t(diagnostic_manager::new_location_from_file_line_column):\n\tLikewise.\n\t(diagnostic_manager::ensure_linemap_for_file_and_line): Likewise.\n\t(diagnostic_manager::m_phys_loc_maker): New field.\n\nSigned-off-by: David Malcolm <dmalcolm@redhat.com>\n---\n gcc/Makefile.in | 1 +\n gcc/diagnostics/physical-location-maker.cc | 75 ++++++++++++++++++++++\n gcc/diagnostics/physical-location-maker.h | 60 +++++++++++++++++\n gcc/libgdiagnostics.cc | 41 ++++--------\n 4 files changed, 147 insertions(+), 30 deletions(-)\n create mode 100644 gcc/diagnostics/physical-location-maker.cc\n create mode 100644 gcc/diagnostics/physical-location-maker.h", "diff": "diff --git a/gcc/Makefile.in b/gcc/Makefile.in\nindex 3d3b21abe6ac0..54865765b6ef6 100644\n--- a/gcc/Makefile.in\n+++ b/gcc/Makefile.in\n@@ -1895,6 +1895,7 @@ OBJS-libcommon = \\\n \tdiagnostics/option-classifier.o \\\n \tdiagnostics/paths.o \\\n \tdiagnostics/paths-output.o \\\n+\tdiagnostics/physical-location-maker.o \\\n \tdiagnostics/source-printing.o \\\n \tdiagnostics/state-graphs-to-dot.o \\\n \tdiagnostics/selftest-context.o \\\ndiff --git a/gcc/diagnostics/physical-location-maker.cc b/gcc/diagnostics/physical-location-maker.cc\nnew file mode 100644\nindex 0000000000000..975687d739451\n--- /dev/null\n+++ b/gcc/diagnostics/physical-location-maker.cc\n@@ -0,0 +1,75 @@\n+/* Convenient but inefficient creation of location_t values.\n+ Copyright (C) 2023-2026 Free Software Foundation, Inc.\n+\n+This file is part of GCC.\n+\n+GCC is free software; you can redistribute it and/or modify it under\n+the terms of the GNU General Public License as published by the Free\n+Software Foundation; either version 3, or (at your option) any later\n+version.\n+\n+GCC is distributed in the hope that it will be useful, but WITHOUT ANY\n+WARRANTY; without even the implied warranty of MERCHANTABILITY or\n+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License\n+for more details.\n+\n+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+#include \"config.h\"\n+#include \"system.h\"\n+#include \"coretypes.h\"\n+#include \"cpplib.h\"\n+#include \"diagnostics/physical-location-maker.h\"\n+#include \"diagnostics/dumping.h\"\n+\n+namespace diagnostics {\n+\n+// class physical_location_maker\n+\n+location_t\n+physical_location_maker::\n+new_location_from_file_and_line (const char *filename,\n+\t\t\t\t int line_num)\n+{\n+ ensure_linemap_for_file_and_line (filename, line_num);\n+ return linemap_position_for_column (m_line_table, 0);\n+}\n+\n+location_t\n+physical_location_maker::\n+new_location_from_file_line_column (const char *filename,\n+\t\t\t\t int line_num,\n+\t\t\t\t int column_num)\n+{\n+ ensure_linemap_for_file_and_line (filename, line_num);\n+ return linemap_position_for_column (m_line_table, column_num);\n+}\n+\n+void\n+physical_location_maker::\n+ensure_linemap_for_file_and_line (const char *filename,\n+\t\t\t\t int line_num)\n+{\n+ /* Build a simple linemap describing some locations. */\n+ if (LINEMAPS_ORDINARY_USED (m_line_table) == 0)\n+ linemap_add (m_line_table, LC_ENTER, false, filename, 0);\n+ else\n+ {\n+ line_map_ordinary *last_map\n+\t= LINEMAPS_LAST_ORDINARY_MAP (m_line_table);\n+ if (last_map->to_file != filename\n+\t || (long)line_num < (long)last_map->to_line)\n+\t{\n+\t line_map *map\n+\t = const_cast<line_map *>\n+\t (linemap_add (m_line_table, LC_RENAME_VERBATIM, false,\n+\t\t\t filename, 0));\n+\t ((line_map_ordinary *)map)->included_from = UNKNOWN_LOCATION;\n+\t}\n+ }\n+ linemap_line_start (m_line_table, line_num, 100);\n+}\n+\n+} // namespace diagnostics\ndiff --git a/gcc/diagnostics/physical-location-maker.h b/gcc/diagnostics/physical-location-maker.h\nnew file mode 100644\nindex 0000000000000..f5d568c5f82cc\n--- /dev/null\n+++ b/gcc/diagnostics/physical-location-maker.h\n@@ -0,0 +1,60 @@\n+/* Convenient but inefficient creation of location_t values.\n+ Copyright (C) 2023-2026 Free Software Foundation, Inc.\n+\n+This file is part of GCC.\n+\n+GCC is free software; you can redistribute it and/or modify it under\n+the terms of the GNU General Public License as published by the Free\n+Software Foundation; either version 3, or (at your option) any later\n+version.\n+\n+GCC is distributed in the hope that it will be useful, but WITHOUT ANY\n+WARRANTY; without even the implied warranty of MERCHANTABILITY or\n+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License\n+for more details.\n+\n+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+#ifndef GCC_DIAGNOSTICS_PHYSICAL_LOCATION_MAKER_H\n+#define GCC_DIAGNOSTICS_PHYSICAL_LOCATION_MAKER_H\n+\n+namespace diagnostics {\n+\n+/* A class for generating location_t values for arbitrary\n+ filename/line/column values.\n+ This is less efficient than working with the line_maps\n+ directly, but is more convenient and flexible for occasional\n+ on-demand location_t values. */\n+\n+class physical_location_maker\n+{\n+public:\n+ physical_location_maker (line_maps *line_table_)\n+ : m_line_table (line_table_)\n+ {\n+ }\n+\n+ location_t\n+ new_location_from_file_and_line (const char *filename,\n+\t\t\t\t int line_num);\n+\n+ /* column_num is 1-based. */\n+ location_t\n+ new_location_from_file_line_column (const char *filename,\n+\t\t\t\t int line_num,\n+\t\t\t\t int column_num);\n+\n+private:\n+ void\n+ ensure_linemap_for_file_and_line (const char *filename,\n+\t\t\t\t int linenum);\n+\n+private:\n+ line_maps *m_line_table;\n+};\n+\n+} // namespace diagnostics\n+\n+#endif // #ifndef GCC_DIAGNOSTICS_PHYSICAL_LOCATION_MAKER_H\ndiff --git a/gcc/libgdiagnostics.cc b/gcc/libgdiagnostics.cc\nindex eb2d0ac4cac1a..dd5109229b3dc 100644\n--- a/gcc/libgdiagnostics.cc\n+++ b/gcc/libgdiagnostics.cc\n@@ -39,6 +39,7 @@ along with GCC; see the file COPYING3. If not see\n #include \"diagnostics/logical-locations.h\"\n #include \"diagnostics/dumping.h\"\n #include \"diagnostics/changes.h\"\n+#include \"diagnostics/physical-location-maker.h\"\n #include \"libgdiagnostics.h\"\n #include \"libgdiagnostics-private.h\"\n #include \"pretty-print-format-impl.h\"\n@@ -648,7 +649,8 @@ struct diagnostic_manager\n {\n public:\n diagnostic_manager ()\n- : m_current_diag (nullptr),\n+ : m_phys_loc_maker (&m_line_table),\n+ m_current_diag (nullptr),\n m_prev_diag_logical_loc (nullptr),\n m_debug_physical_locations (false)\n {\n@@ -761,8 +763,9 @@ public:\n if (m_debug_physical_locations)\n fprintf (stderr, \"new_location_from_file_and_line (%s, %i)\",\n \t file->get_name (), line_num);\n- ensure_linemap_for_file_and_line (file, line_num);\n- location_t loc = linemap_position_for_column (&m_line_table, 0);\n+ location_t loc\n+ = m_phys_loc_maker.new_location_from_file_and_line (file->get_name (),\n+\t\t\t\t\t\t\t line_num);\n return new_location (loc);\n }\n \n@@ -774,8 +777,10 @@ public:\n if (m_debug_physical_locations)\n fprintf (stderr, \"new_location_from_file_line_column (%s, %i, %i)\",\n \t file->get_name (), line_num, column_num);\n- ensure_linemap_for_file_and_line (file, line_num);\n- location_t loc = linemap_position_for_column (&m_line_table, column_num);\n+ location_t loc\n+ = m_phys_loc_maker.new_location_from_file_line_column (file->get_name (),\n+\t\t\t\t\t\t\t line_num,\n+\t\t\t\t\t\t\t column_num);\n return new_location (loc);\n }\n \n@@ -892,31 +897,6 @@ public:\n void\n take_global_graph (std::unique_ptr<diagnostic_graph> graph);\n \n-private:\n- void\n- ensure_linemap_for_file_and_line (const diagnostic_file *file,\n-\t\t\t\t diagnostic_line_num_t linenum)\n- {\n- /* Build a simple linemap describing some locations. */\n- if (LINEMAPS_ORDINARY_USED (&m_line_table) == 0)\n- linemap_add (&m_line_table, LC_ENTER, false, file->get_name (), 0);\n- else\n- {\n-\tline_map_ordinary *last_map\n-\t = LINEMAPS_LAST_ORDINARY_MAP (&m_line_table);\n-\tif (last_map->to_file != file->get_name ()\n-\t || linenum < last_map->to_line)\n-\t {\n-\t line_map *map\n-\t = const_cast<line_map *>\n-\t (linemap_add (&m_line_table, LC_RENAME_VERBATIM, false,\n-\t\t\t file->get_name (), 0));\n-\t ((line_map_ordinary *)map)->included_from = UNKNOWN_LOCATION;\n-\t }\n- }\n- linemap_line_start (&m_line_table, linenum, 100);\n- }\n-\n const diagnostic_physical_location *\n new_location (location_t loc)\n {\n@@ -940,6 +920,7 @@ private:\n \n diagnostics::context m_dc;\n line_maps m_line_table;\n+ diagnostics::physical_location_maker m_phys_loc_maker;\n impl_client_version_info m_client_version_info;\n std::vector<std::unique_ptr<sink>> m_sinks;\n hash_map<nofree_string_hash, diagnostic_file *> m_str_to_file_map;\n", "prefixes": [ "2/5" ] }