From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id ITsQKyzR/GpTqBkAWB0awg (envelope-from ) for ; Tue, 17 Nov 2026 17:11:56 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=fx9JXq9U; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id A9E5D1E091; Tue, 17 Nov 2026 17:11:56 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 1B9EB1E023 for ; Tue, 17 Nov 2026 17:11:56 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0EFD04BA2E05 for ; Tue, 17 Nov 2026 22:11:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0EFD04BA2E05 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=fx9JXq9U Received: from mail-ot1-x32e.google.com (mail-ot1-x32e.google.com [IPv6:2607:f8b0:4864:20::32e]) by sourceware.org (Postfix) with ESMTPS id 0C8C34BA2E25 for ; Tue, 17 Nov 2026 22:10:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0C8C34BA2E25 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0C8C34BA2E25 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::32e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1794953424; cv=none; b=Pa3+XX5kx35tekKalrN6Ju4BQ+5/mcCp28z/NmN2fJX5LufF5hNd5XpfBRfPVZ6XspnwBOJdK2VNT4fmfxLROaECLTepqgINyhH1WD27rhUF6RHPsPe9zJ5tom3BhIYb0Mn6BbVE49cdQPA71fvuOGXxsWUe5iz3u16Or3ldQ4Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1794953424; c=relaxed/simple; bh=cwy7S2vk8tMF+AUK9JdMI6wUlUitCK17BJ+soNtve+Y=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=QwtdUqkabcl4PoW9s++pHZxT5oB8BxGRt+9vmBxLhZdqp8l0oMBvldMOBo+AajyzCxeh7iX3vWTxs4HgQLCIuRzVoG5E4OXYq0eIQjws/LLBd8BA+4A9Xe5v0W0j0DSGLYZ2PxhGWSPsGTiiIj5Yo6z8ZpezYzM2CrD7svppXe8= ARC-Authentication-Results: i=1; sourceware.org Received: by mail-ot1-x32e.google.com with SMTP id 46e09a7af769-862bb0a189aso121667a34.1 for ; Tue, 17 Nov 2026 14:10:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1794953415; x=1795558215; darn=sourceware.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=eymo7nZiElJceNGSXDmU2os8tYhUcMIWfpSqDM4Uzns=; b=fx9JXq9UZBwnwq8Kk+g99TYq93zv8w4hdTEOruzf12PmvgSrRdkoUBlsYFqGYL1d2v BZtEQOUKmdd275FrmbYZLRnzJS9hxqQ136DK5dAI/14p7IsrW5NlB3/80EHgj9/nT3pf AnKx7wADLFP/GPuAdTcFk3hNJ82aD6tqPyJlpwLm9fdGpr8EMv0khTgAazaBSLJdJ5ZL C88dqa6Vo9Os67jRZ6TPv9tphuFjIN1T0pG2+vsxXnCcEsWWK4H+UnTjT5b7cLx0ZrNX oZgPp3nl8qMPr1yl0ZSSfuR5QdYCwRYnNZWMEgaRY9HEM8XeHWhCDadGC6MN/QmNlw9O fUUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794953415; x=1795558215; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=eymo7nZiElJceNGSXDmU2os8tYhUcMIWfpSqDM4Uzns=; b=sUvcbXYoJR7asCZBpedwid2fVBSthBc3HUzMj55dbUdluQ4XAb1RqzKP4FHUO+Z+xx Dk1ZswXz9ydXOoGvO4yKux51BKXaFJLomriwoldiBX0yXS6mx0fV3lxh8ynLygIzroqs JVZ7kyiIfR84Aspau/rh0U9qLMw7bA5Zib2UawU1na4XeALGrj4WcqLXOyNKuxDOnpdM GYgoO6cO+hmCmCU7HZxuDNIpazBsiyRKMgEkrZNqlBVH3SJ5D+WcVRxMGHr2BUc3Bb1d QI9pgC467twgVzL1p/hl9KDTBktC87KmJYETXnsbM3j8JXLGcYnBAEh9wBz/ev7FCINE Crqg== X-Gm-Message-State: APuU4Z+dSMMhPgm6bZ1M7+lhAuXoMrRghQATrHhlQ5SsYFk9Z9YF2CVj 25A3P5ExOu0ns77pmKchs9PvPtUxmBfEdG4HvLp/fuf03imL5o3oOsw16inUrE0GRg== X-Gm-Gg: AYBFou20BHztDql7QfShtoNBeF2qS421xlRvFpRJL5liAhjajOyLOBhR6jVBoma6/Cl pnz7MuLGXD2QHloigZ/RMJWp/AZkIRS/Duj444h5Ht0Rl52kM1grTMKhJx7fY8hkGWCAFkhTqdc p+2UU1bgBKU3eWlOc7xs77b7Uk5tP+i4zhGwTk3GlbmrJYzhPqpptWvRjZ44Uu9hBvL04se8L8G /F4jboq+SWms7jIc9n8h9hdofNdZZiHcNj1vErJBlybtQMegp8wL6xnszyBejMGcUZ6HdYP+ao1 2H1nqloLgTs+s2BwzjBjlHkq+1jiQDj21aO/5zLXMx9XmGH6nrL+xHnf/nHHpnQP9SfbNYbf2ZT Gzj4wrvTj5Cs9yps9g97ODJ4QEas/XapFrGxuwKl87BEhAzD+McdJ1vdNgfPwOO3/QWmEqa2lrZ k5MF+1N+M4nuJfraYg8LzHjZZHnXakLqyLJf2y8Jqd+ZWn29lJjWdNJuQ/M7K+xWdPCrWp/jK8T vQw5B0fxaEyFlrLnJUKOK4XBT1bq7bAZ4ZZXLna6TZFgpFZ1Gdv9IwQ3Kf1Mi/ku4zCyKKeZMdi S0ZLxMvUuTGEo33SWN+nEaUhkbZktBMIgSqdqjWHm9e3/XyhANEUWgCXOfrgTA== X-Received: by 2002:a05:6830:3492:b0:814:8259:781e with SMTP id 46e09a7af769-862f07e17cfmr740333a34.1.1794953415452; Tue, 17 Nov 2026 14:10:15 -0800 (PST) Received: from [192.168.0.26] (97-122-110-129.hlrn.qwest.net. [97.122.110.129]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-862f01d4764sm545498a34.5.2026.11.17.14.10.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Nov 2026 14:10:15 -0800 (PST) From: Tom Tromey Date: Tue, 17 Nov 2026 15:10:13 -0700 Subject: [PATCH v3 17/17] Move gdb::ranges::equal to gdbsupport/ranges.h MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261117-span-part-1-v3-17-40b8b11d2d8c@adacore.com> References: <20261117-span-part-1-v3-0-40b8b11d2d8c@adacore.com> In-Reply-To: <20261117-span-part-1-v3-0-40b8b11d2d8c@adacore.com> To: gdb-patches@sourceware.org Cc: Tom Tromey , Simon Marchi X-Mailer: b4 0.16.0 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org This moves the gdb::ranges::equal function to gdbsupport/ranges.h. When moving to C++20, this entire header can be removed. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32660 Approved-By: Simon Marchi --- gdb/dwarf2/read-debug-names.c | 1 + gdb/value.c | 1 + gdbsupport/ranges.h | 27 +++++++++++++++++++++++++++ gdbsupport/span.h | 40 ---------------------------------------- 4 files changed, 29 insertions(+), 40 deletions(-) diff --git a/gdb/dwarf2/read-debug-names.c b/gdb/dwarf2/read-debug-names.c index ca3b46fc9b1..ee35f06dde9 100644 --- a/gdb/dwarf2/read-debug-names.c +++ b/gdb/dwarf2/read-debug-names.c @@ -29,6 +29,7 @@ #include "read.h" #include "stringify.h" #include "extract-store-integer.h" +#include "gdbsupport/ranges.h" #include "gdbsupport/thread-pool.h" #include "cli/cli-style.h" diff --git a/gdb/value.c b/gdb/value.c index 536eef3e00c..195f4bb5185 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -45,6 +45,7 @@ #include #include "completer.h" #include "gdbsupport/cleanups.h" +#include "gdbsupport/ranges.h" #include "gdbsupport/selftest.h" #include "gdbsupport/span.h" #include "cli/cli-style.h" diff --git a/gdbsupport/ranges.h b/gdbsupport/ranges.h index c89506da86d..e19bbb8224f 100644 --- a/gdbsupport/ranges.h +++ b/gdbsupport/ranges.h @@ -20,9 +20,36 @@ #include +/* The 'equal' wrapper here only works on spans, so include this. + When moving to C++20, this will be removed -- in fact this entire + file should be removed. */ +#include "gdbsupport/span.h" + namespace gdb { namespace ranges { +/* Compare LHS and RHS for (deep) equality. That is, whether LHS and + RHS have the same sizes, and whether each pair of elements of LHS + and RHS at the same position compares equal. */ + +template +bool +equal (const gdb::span &lhs, const gdb::span &rhs) +{ +#if __cplusplus >= 202002L + return std::ranges::equal (lhs, rhs); +#else + if (lhs.size () != rhs.size ()) + return false; + + for (size_t i = 0; i < lhs.size (); i++) + if (!(lhs[i] == rhs[i])) + return false; + + return true; +#endif +} + /* Replace all occurrences of a value in the provided range. Note: this helper is a reimplementation of std::ranges::replace, only diff --git a/gdbsupport/span.h b/gdbsupport/span.h index cca1d88350b..9aa2a8b4905 100644 --- a/gdbsupport/span.h +++ b/gdbsupport/span.h @@ -69,20 +69,6 @@ namespace gdb { /* gdb::span. */ template using span = std::span; -namespace ranges -{ - -/* gdb::ranges::equal. */ - -template -constexpr bool -equal (R1 &&r1, R2 &&r2) -{ - return std::ranges::equal (r1, r2); -} - -} /* namespace ranges */ - } /* namespace gdb */ #else /* __cplusplus < 202002L */ @@ -212,32 +198,6 @@ class span size_type m_size; }; -namespace ranges -{ - -namespace ranges -{ - -/* Compare LHS and RHS for (deep) equality. That is, whether LHS and - RHS have the same sizes, and whether each pair of elements of LHS - and RHS at the same position compares equal. */ - -template -bool -equal (const gdb::span &lhs, const gdb::span &rhs) -{ - if (lhs.size () != rhs.size ()) - return false; - - for (size_t i = 0; i < lhs.size (); i++) - if (!(lhs[i] == rhs[i])) - return false; - - return true; -} - -} /* namespace ranges */ - } /* namespace gdb */ #endif /* __cplusplus < 202002L */ -- 2.56.0