From patchwork Tue Nov 21 12:04:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lancelot SIX X-Patchwork-Id: 80460 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D0F65385802A for ; Tue, 21 Nov 2023 12:06:12 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2082.outbound.protection.outlook.com [40.107.93.82]) by sourceware.org (Postfix) with ESMTPS id C43CD3858292 for ; Tue, 21 Nov 2023 12:05:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C43CD3858292 Authentication-Results: sourceware.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=amd.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C43CD3858292 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.93.82 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1700568357; cv=pass; b=R/a9k62rHFgR3Ml/OGXYos5kwaBEEV+zsb2D8cf3OWn0IMmTU5PQukUwS+CAA5ifBcRDF1ZE+GB8Fhjt6US15mujs7gqBshOTsLdHbZlGZeqAuwL8YukDLMsD2mGyjBevC3/q/SyfuMPFkKI/nO2sQ7PnTdWqtkuDQeIuRYR9fs= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1700568357; c=relaxed/simple; bh=AetTcozEbwn0pZKJioNQZZqzpCYTaUbw9PcL5Q9J2j0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=oV8DXQ5hkNJDgPV7GyM9Id8BGaTDJgJWmrhfRWJZf9mYQJJz3HrKAumI+fnAh9v/OUryN6//BHZWdVmQ6CF0wGw/FuqMX4w+l6TLuFCpVkvRxCWCSXpuZZtflgvjv8lKa85t419jVCGOZ64mLnuGvJ+xBuHyAFcCpu5s55EqrNA= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QVzGmRR2b8mb7+zwyZYWa1KkOpVdgSGuXF4KZLcaAm7XyMNA0/p9wIO578zsVXqluGyk1bTcR8aZH1CFKYAk+WC88INQIuAwEFUbxrC+p1W8yKeMYI2vbPNPxM5SfLsCVYeQiQsTbt7mKRnLvW8ywj0eApXxyPoCKvaaAuog2qtF1+WecbWbBmZ/fBDqkruf/jRqqS40d3EmFK0CrOK3rcCPH9gfF5GJkfxgYXss7qTPc9wnaYMwXpOESqNAxKrlAs9MuYxKks0DNyueiFqy7Jl3RzQDBOpQT8nd1hXeEtQc+mhmOgIwseS/50SJ31HnP98+4z1UPY15KLAdJ4htnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/z4YU9Qc3nzQLv83hoOcTOXoGve9WscR280pOxnrbc0=; b=AULLHodfoH8mNdHtBB5CIOGBy7Py45FQttZbGnIS2iSepqHQBY5uWI7O26oKLtnzaLqXnj/dbbUV/X474vDqp9fR0TgHhLLqXIozTq8d/rRUX3saW/8bbj0wIx065gfJrwBIe8Ij4RVGwlgM95UO6owiaYgqFA8nMr3kfVTZUXSInkBKgbIOuZ4R9AzYzY6NIQPv29Du036WhaonCpkDGCT/ndcR6JiDa4bXq2CgQaW634J0ex81T63Vgj7CL8ZDqGw1dMTktPCgk8fe5hu22UeWMFXjGGuSGlEpKmqgfd1lmuYWUoi150kpkL2jFM48j9FbiUlkVfHDV82ViEtqtQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=sourceware.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/z4YU9Qc3nzQLv83hoOcTOXoGve9WscR280pOxnrbc0=; b=mPgrXOuBhjDHj7DvI0/obwDBlKyjt6SboFb6Jzo9kulbpEgVIm7u2HoBeeL0HvqrTLgcKwDm9b8Or7/GCNcReSiJ0C/rqJltkXyGdhXQNUct9dXmTCgNmJmrx5S/CJsYq5zEurS5XM6Agm+tCM6VGS9Gh2Sbmwku1CHgBjkjCQo= Received: from MN2PR12CA0022.namprd12.prod.outlook.com (2603:10b6:208:a8::35) by CY8PR12MB7538.namprd12.prod.outlook.com (2603:10b6:930:95::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.28; Tue, 21 Nov 2023 12:05:50 +0000 Received: from MN1PEPF0000F0E4.namprd04.prod.outlook.com (2603:10b6:208:a8:cafe::77) by MN2PR12CA0022.outlook.office365.com (2603:10b6:208:a8::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.27 via Frontend Transport; Tue, 21 Nov 2023 12:05:50 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MN1PEPF0000F0E4.mail.protection.outlook.com (10.167.242.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7025.12 via Frontend Transport; Tue, 21 Nov 2023 12:05:50 +0000 Received: from hpe6u-23.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Tue, 21 Nov 2023 06:05:49 -0600 From: Lancelot Six To: CC: , , Lancelot Six Subject: [COMMITTED PATCH v2 1/9] gdb: Use C++17's std::make_unique instead of gdb::make_unique Date: Tue, 21 Nov 2023 12:04:52 +0000 Message-ID: <20231121120500.1394523-2-lancelot.six@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028204821.fp5hh7bahrmrnpjl@hpe6u-23> References: <20231028204821.fp5hh7bahrmrnpjl@hpe6u-23> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000F0E4:EE_|CY8PR12MB7538:EE_ X-MS-Office365-Filtering-Correlation-Id: a3f9e5a1-1428-4f0e-58da-08dbea8a33ee X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G/7e0OXZDeWbvLeo5yJQaZCf01Cjp1ZjZ2pErkz0ydx7y00Q47lhWXENuRjYHfevAq9pMRnpsmC4qDJnrKO9DhuX/tNOASZcR8d2Xy7q2MtCoMrLBOg+9R7hJhqk0Ndmqi0XJ2WE/+OK8jiQnHP2Qrn0PPT7yFNsT4eAXk6TcA/zmlUzxSSHCDTbjf5AiDsSQS87evptiB8A0E/m94vjb3IN45nQ5K+QsEduv/HAicSaUdyEcAPK3mo9r3+HH+OHPet3cAViSglGWEbqilMF0rUzaJr9fMPaBZXy08rbbs4kCbY4aqCUcWVHJgIiazYIELCgRbEckKPCosbEhScdQQA0CKKL7jDKqzlEG1Nrei/piZs/ukeImBPBhJuyQouV2ZxBC3KNLu5GmoiSByKVqoiDCYlAqUgZWibUAlEGLd0qQfXW124wLlRdorUk9vTuIPCaijSdD3qsvd6NgYntqiGdpITcRKOFh/uUPtASA2WqmxnA8jiu4PUrUZP5Xa+Yx+cwt2/2+7McbU7UGUEdyEJ9PmoVpfX/25xO537Obt6L5EQCPLJgCa8lfQ7aXwZ/Hm/iYSE099Z0cOrzVQNE5IXvynkfCokuyFzH1b/VtRLabA6x+UGggnI2KYEjBk46qvht4U5hvDpGtHt9UCj3vVrIHnplnrgxd7zfTEi//vOXSUQHNLdQ69JvOhsXtuQbshriVmKnZy2EExlR40wupfnewgUVQ3990uhPYOqt/iVZHH+GxCVMCZhARTpjBhwqY7Cu4k3qIWJLC4FBk5cfKw== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(396003)(136003)(376002)(39860400002)(346002)(230922051799003)(186009)(451199024)(1800799012)(82310400011)(64100799003)(40470700004)(46966006)(36840700001)(2906002)(30864003)(5660300002)(44832011)(40480700001)(41300700001)(4326008)(8936002)(8676002)(6916009)(316002)(54906003)(70206006)(70586007)(40460700003)(47076005)(86362001)(1076003)(26005)(478600001)(16526019)(6666004)(36756003)(7696005)(2616005)(336012)(426003)(356005)(81166007)(83380400001)(36860700001)(82740400003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 12:05:50.0076 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a3f9e5a1-1428-4f0e-58da-08dbea8a33ee X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MN1PEPF0000F0E4.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7538 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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: 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+patchwork=sourceware.org@sourceware.org gdb::make_unique is a wrapper around std::make_unique when compiled with C++17. Now that C++17 is required, use std::make_unique directly in the codebase, and remove gdb::make_unique. Change-Id: I80b615e46e4b7c097f09d78e579a9bdce00254ab Approved-By: Tom Tromey Approved-By: Pedro Alves (); + auto map = std::make_unique (); SELF_CHECK (map != nullptr); /* Check initial state. */ diff --git a/gdb/break-catch-load.c b/gdb/break-catch-load.c index 02a98b5d30a..dbf70d8f204 100644 --- a/gdb/break-catch-load.c +++ b/gdb/break-catch-load.c @@ -230,7 +230,7 @@ add_solib_catchpoint (const char *arg, bool is_load, bool is_temp, bool enabled) if (*arg == '\0') arg = nullptr; - auto c = gdb::make_unique (gdbarch, is_temp, nullptr, + auto c = std::make_unique (gdbarch, is_temp, nullptr, is_load, arg); c->enable_state = enabled ? bp_enabled : bp_disabled; diff --git a/gdb/compile/compile-c-support.c b/gdb/compile/compile-c-support.c index 53b7285b366..3a3e4d21136 100644 --- a/gdb/compile/compile-c-support.c +++ b/gdb/compile/compile-c-support.c @@ -118,7 +118,7 @@ get_compile_context (const char *fe_libcc, const char *fe_context, error (_("The loaded version of GCC does not support the required version " "of the API.")); - return gdb::make_unique (context); + return std::make_unique (context); } /* A C-language implementation of get_compile_context. */ diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y index 324166a03ff..e6c8c4c09a9 100644 --- a/gdb/cp-name-parser.y +++ b/gdb/cp-name-parser.y @@ -2038,7 +2038,7 @@ cp_demangled_name_to_comp (const char *demangled_name, state.demangle_info = allocate_info (); - auto result = gdb::make_unique (); + auto result = std::make_unique (); result->info = state.demangle_info; if (yyparse (&state)) diff --git a/gdb/cp-support.c b/gdb/cp-support.c index e02e859b99a..834c4774755 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -675,7 +675,7 @@ mangled_name_to_comp (const char *mangled_name, int options, options, memory); if (ret) { - auto info = gdb::make_unique (); + auto info = std::make_unique (); info->tree = ret; *demangled_p = NULL; return info; diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c index abc8d613482..d72dd0ad971 100644 --- a/gdb/dwarf2/frame.c +++ b/gdb/dwarf2/frame.c @@ -2126,7 +2126,7 @@ dwarf2_build_frame_info (struct objfile *objfile) struct gdbarch *gdbarch = objfile->arch (); /* Build a minimal decoding of the DWARF2 compilation unit. */ - auto unit = gdb::make_unique (objfile); + auto unit = std::make_unique (objfile); if (objfile->separate_debug_objfile_backlink == NULL) { diff --git a/gdb/dwarf2/read-debug-names.c b/gdb/dwarf2/read-debug-names.c index c1b62b38f93..78e0df27314 100644 --- a/gdb/dwarf2/read-debug-names.c +++ b/gdb/dwarf2/read-debug-names.c @@ -464,7 +464,7 @@ create_cus_from_debug_names (dwarf2_per_bfd *per_bfd, bool dwarf2_read_debug_names (dwarf2_per_objfile *per_objfile) { - auto map = gdb::make_unique (); + auto map = std::make_unique (); mapped_debug_names dwz_map; struct objfile *objfile = per_objfile->objfile; dwarf2_per_bfd *per_bfd = per_objfile->per_bfd; diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c index e789e9c2654..064a9f17b0e 100644 --- a/gdb/dwarf2/read-gdb-index.c +++ b/gdb/dwarf2/read-gdb-index.c @@ -828,7 +828,7 @@ dwarf2_read_gdb_index if (main_index_contents.empty ()) return 0; - auto map = gdb::make_unique (); + auto map = std::make_unique (); if (!read_gdb_index_from_buffer (objfile_name (objfile), use_deprecated_index_sections, main_index_contents, map.get (), &cu_list, diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index e8ff4d8f29a..2a7fd8f5de5 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -4372,7 +4372,7 @@ allocate_type_unit_groups_table () static std::unique_ptr create_type_unit_group (struct dwarf2_cu *cu, sect_offset line_offset_struct) { - auto tu_group = gdb::make_unique (); + auto tu_group = std::make_unique (); tu_group->hash.dwo_unit = cu->dwo_unit; tu_group->hash.line_sect_off = line_offset_struct; diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c index 56a4c5ecc91..b72821f4c35 100644 --- a/gdb/gdb_bfd.c +++ b/gdb/gdb_bfd.c @@ -303,7 +303,7 @@ gdb_bfd_open_from_target_memory (CORE_ADDR addr, ULONGEST size, const char *target) { std::unique_ptr buffer - = gdb::make_unique (addr, size); + = std::make_unique (addr, size); return gdb_bfd_openr_iovec (buffer->filename (), target, [&] (bfd *nbfd) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 7011fddd695..e424077c1c0 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -5833,7 +5833,7 @@ static const struct registry::key void allocate_fixed_point_type_info (struct type *type) { - auto up = gdb::make_unique (); + auto up = std::make_unique (); fixed_point_type_info *info; if (type->is_objfile_owned ()) diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index abcd0d392ba..14ed2a1fae9 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -1932,7 +1932,7 @@ mi_execute_command (const char *cmd, int from_tty) = gdb::checked_static_cast (command_interp ()); try { - command = gdb::make_unique (cmd, &token); + command = std::make_unique (cmd, &token); } catch (const gdb_exception &exception) { diff --git a/gdb/mi/mi-out.c b/gdb/mi/mi-out.c index bbd21287b28..0bc13f963bc 100644 --- a/gdb/mi/mi-out.c +++ b/gdb/mi/mi-out.c @@ -340,13 +340,13 @@ std::unique_ptr mi_out_new (const char *mi_version) { if (streq (mi_version, INTERP_MI4) || streq (mi_version, INTERP_MI)) - return gdb::make_unique (4); + return std::make_unique (4); if (streq (mi_version, INTERP_MI3)) - return gdb::make_unique (3); + return std::make_unique (3); if (streq (mi_version, INTERP_MI2)) - return gdb::make_unique (2); + return std::make_unique (2); return nullptr; } diff --git a/gdb/nat/linux-btrace.c b/gdb/nat/linux-btrace.c index 3c217daa488..c0cebbb2f02 100644 --- a/gdb/nat/linux-btrace.c +++ b/gdb/nat/linux-btrace.c @@ -468,7 +468,7 @@ linux_enable_bts (ptid_t ptid, const struct btrace_config_bts *conf) error (_("BTS support has been disabled for the target cpu.")); std::unique_ptr tinfo - { gdb::make_unique (ptid) }; + { std::make_unique (ptid) }; tinfo->conf.format = BTRACE_FORMAT_BTS; @@ -617,7 +617,7 @@ linux_enable_pt (ptid_t ptid, const struct btrace_config_pt *conf) pid = ptid.pid (); std::unique_ptr tinfo - { gdb::make_unique (ptid) }; + { std::make_unique (ptid) }; tinfo->conf.format = BTRACE_FORMAT_PT; diff --git a/gdb/python/py-mi.c b/gdb/python/py-mi.c index a7b4f4fa3cf..aaa225da95e 100644 --- a/gdb/python/py-mi.c +++ b/gdb/python/py-mi.c @@ -290,7 +290,7 @@ gdbpy_execute_mi_command (PyObject *self, PyObject *args, PyObject *kw) try { scoped_restore save_uiout = make_scoped_restore (¤t_uiout, &uiout); - auto parser = gdb::make_unique (std::move (mi_command), + auto parser = std::make_unique (std::move (mi_command), std::move (arg_strings)); mi_execute_command (parser.get ()); } diff --git a/gdb/python/py-varobj.c b/gdb/python/py-varobj.c index 98603cec009..3401cf294ac 100644 --- a/gdb/python/py-varobj.c +++ b/gdb/python/py-varobj.c @@ -170,5 +170,5 @@ py_varobj_get_iterator (struct varobj *var, PyObject *printer, error (_("Could not get children iterator")); } - return gdb::make_unique (var, std::move (iter), opts); + return std::make_unique (var, std::move (iter), opts); } diff --git a/gdb/solib-aix.c b/gdb/solib-aix.c index c8fa865f49d..0fc3a153973 100644 --- a/gdb/solib-aix.c +++ b/gdb/solib-aix.c @@ -484,7 +484,7 @@ solib_aix_current_sos () new_solib->so_original_name = so_name; new_solib->so_name = so_name; - new_solib->lm_info = gdb::make_unique (info); + new_solib->lm_info = std::make_unique (info); /* Add it to the list. */ sos.push_back (*new_solib); diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c index c18791cd7c2..4819afe8863 100644 --- a/gdb/solib-darwin.c +++ b/gdb/solib-darwin.c @@ -274,7 +274,7 @@ darwin_current_sos () /* Create and fill the new struct shobj element. */ shobj *newobj = new shobj; - auto li = gdb::make_unique (); + auto li = std::make_unique (); newobj->so_name = file_path.get (); newobj->so_original_name = newobj->so_name; diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c index 65bb6251a0e..ef561466945 100644 --- a/gdb/solib-dsbt.c +++ b/gdb/solib-dsbt.c @@ -594,7 +594,7 @@ dsbt_current_sos (void) } shobj *sop = new shobj; - auto li = gdb::make_unique (); + auto li = std::make_unique (); li->map = loadmap; /* Fetch the name. */ addr = extract_unsigned_integer (lm_buf.l_name, diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c index 0897bce2325..7ca28982638 100644 --- a/gdb/solib-frv.c +++ b/gdb/solib-frv.c @@ -377,7 +377,7 @@ frv_current_sos () } shobj *sop = new shobj; - auto li = gdb::make_unique (); + auto li = std::make_unique (); li->map = loadmap; li->got_value = got_addr; li->lm_addr = lm_addr; diff --git a/gdb/solib-rocm.c b/gdb/solib-rocm.c index 3a971b3361e..cf56a81a2ee 100644 --- a/gdb/solib-rocm.c +++ b/gdb/solib-rocm.c @@ -212,7 +212,7 @@ so_list_from_rocm_sos (const std::vector &sos) for (const rocm_so &so : sos) { struct shobj *newobj = new struct shobj; - newobj->lm_info = gdb::make_unique (*so.lm_info); + newobj->lm_info = std::make_unique (*so.lm_info); newobj->so_name = so.name; newobj->so_original_name = so.unique_name; @@ -725,7 +725,7 @@ rocm_update_solib_list () gdb::unique_xmalloc_ptr uri_bytes_holder (uri_bytes); - lm_info_svr4_up li = gdb::make_unique (); + lm_info_svr4_up li = std::make_unique (); li->l_addr = l_addr; /* Generate a unique name so that code objects with the same URI but diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index 8a5ad590f6f..5882a4e0070 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -213,7 +213,7 @@ lm_info_read (CORE_ADDR lm_addr) type *ptr_type = builtin_type (current_inferior ()->arch ())->builtin_data_ptr; - lm_info = gdb::make_unique (); + lm_info = std::make_unique (); lm_info->lm_addr = lm_addr; lm_info->l_addr_inferior = extract_typed_address (&lm[lmo->l_addr_offset], @@ -1001,7 +1001,7 @@ so_list_from_svr4_sos (const std::vector &sos) newobj->so_name = so.name; newobj->so_original_name = so.name; - newobj->lm_info = gdb::make_unique (*so.lm_info); + newobj->lm_info = std::make_unique (*so.lm_info); dst.push_back (*newobj); } @@ -1032,7 +1032,7 @@ library_list_start_library (struct gdb_xml_parser *parser, ULONGEST *l_ldp = (ULONGEST *) xml_find_attribute (attributes, "l_ld")->value.get (); - lm_info_svr4_up li = gdb::make_unique (); + lm_info_svr4_up li = std::make_unique (); li->lm_addr = *lmp; li->l_addr_inferior = *l_addrp; li->l_ld = *l_ldp; @@ -1190,7 +1190,7 @@ svr4_default_sos (svr4_info *info) return {}; shobj *newobj = new shobj; - auto li = gdb::make_unique (); + auto li = std::make_unique (); /* Nothing will ever check the other fields if we set l_addr_p. */ li->l_addr = li->l_addr_inferior = info->debug_loader_offset; diff --git a/gdb/ui-out.c b/gdb/ui-out.c index defa8f9dfa4..e8653c6c127 100644 --- a/gdb/ui-out.c +++ b/gdb/ui-out.c @@ -236,7 +236,7 @@ void ui_out_table::append_header (int width, ui_align alignment, internal_error (_("table header must be specified after table_begin and " "before table_body.")); - auto header = gdb::make_unique (m_headers.size () + 1, + auto header = std::make_unique (m_headers.size () + 1, width, alignment, col_name, col_hdr); @@ -328,7 +328,7 @@ ui_out::current_level () const void ui_out::push_level (ui_out_type type) { - auto level = gdb::make_unique (type); + auto level = std::make_unique (type); m_levels.push_back (std::move (level)); } diff --git a/gdb/unittests/parallel-for-selftests.c b/gdb/unittests/parallel-for-selftests.c index 1ad7eaa701c..63e9512ea18 100644 --- a/gdb/unittests/parallel-for-selftests.c +++ b/gdb/unittests/parallel-for-selftests.c @@ -160,7 +160,7 @@ TEST (int n_threads) { if (start == end) any_empty_tasks = true; - return gdb::make_unique (end - start); + return std::make_unique (end - start); }); SELF_CHECK (!any_empty_tasks); SELF_CHECK (std::all_of (intresults.begin (), @@ -178,7 +178,7 @@ TEST (int n_threads) { if (start == end) any_empty_tasks = true; - return gdb::make_unique (end - start); + return std::make_unique (end - start); }, task_size_one); SELF_CHECK (!any_empty_tasks); diff --git a/gdb/varobj.c b/gdb/varobj.c index a4fcbffc311..4ea8d0fd9b3 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -259,7 +259,7 @@ varobj_create (const char *objname, const char *expression, CORE_ADDR frame, enum varobj_type type) { /* Fill out a varobj structure for the (root) variable being constructed. */ - auto var = gdb::make_unique (new varobj_root); + auto var = std::make_unique (new varobj_root); if (expression != NULL) { diff --git a/gdbsupport/gdb_unique_ptr.h b/gdbsupport/gdb_unique_ptr.h index 2b6c0ce3d53..3bef6ff34d6 100644 --- a/gdbsupport/gdb_unique_ptr.h +++ b/gdbsupport/gdb_unique_ptr.h @@ -56,19 +56,6 @@ struct noop_deleter void operator() (T *ptr) const { } }; -/* Create simple std::unique_ptr objects. */ - -template -std::unique_ptr -make_unique (Arg &&...args) -{ -#if __cplusplus >= 201402L - return std::make_unique (std::forward (args)...); -#else - return std::unique_ptr (new T (std::forward (args)...)); -#endif /* __cplusplus < 201402L */ -} - } /* namespace gdb */ /* Dup STR and return a unique_xmalloc_ptr for the result. */ From patchwork Tue Nov 21 12:04:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lancelot SIX X-Patchwork-Id: 80467 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 27FEF3858C29 for ; Tue, 21 Nov 2023 12:07:52 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2085.outbound.protection.outlook.com [40.107.102.85]) by sourceware.org (Postfix) with ESMTPS id 644C1385829B for ; Tue, 21 Nov 2023 12:05:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 644C1385829B Authentication-Results: sourceware.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=amd.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 644C1385829B Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.102.85 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1700568367; cv=pass; b=xv275KlimRny+baLWQlU1JGZy43n+pEU8dj9JOwi2jLMhDrsqAAFSwwFYCwACSG0GbSNhcqE1H4PtckPeyngErImBpwZVyNYblOJuk2O2Gi5ArRZPfUXE4GWqdRhUA6bMpP1NDRty1JN3Cufkq5YWm90iN5GCdUMR9tmMUnxYcI= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1700568367; c=relaxed/simple; bh=Yzox4RSP6uz5fu/6VcqD6lk0bkh9zzEwlTQ2/LYovps=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=mPuz/bZNZMfjncBkj254ku6thYog/F48oH5xtW6ZcFQfgbyMN599O1vnamhtVzaUYYmCM50D5IYsQ40oqyItDYdPfgTdeH4nNhecqFUsrEYqkYyyH65LqQqV0mTtp0xguUOVVVd3Weq9Av48y5+qBQ8NUApd0GTKCkmmY6wffYg= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=djgDpvgBVFsC7WgVWpUbB3BAr9DqjQDMEkUf4dieoEQn9OEAgR88TeM3/3WwrB3A7tOMB1WVcPWPPLCmLeeB99N3yG0MpWyByRWnKozav1zRXf8jfWkxzZT8DmgaLbhCHJYpTk1ScQo1b1aGk3frAc+ioLXH/Tp34/I6lHRGSMo2736ijcExxXU51fzo/K8GNNqr6lXJIkxxc8fDIAXDeboCEp0m+XJk0Dv2u1ra6YycEi3/JVdV/4gTs3xNYI9hCZb2WNeXPY7P1jZ1cyQSfPCyWGJcVY5PQjzWny/MT1eEo+ZPLO/Iw2g1qDA1jOSCITEpGcwDi1jEwBNeSc3DcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kLENllvyz3qgXiuQUOHTKkupB2k60/yDMSnsQqLFYVM=; b=nmHxF4OV2KS5FcBzRdStM99JHXQUBdUWj9Bwj8yMHjxtBCB813FoQhN0+ruOySS3bDHsFXvl7Uxa9FakX4dpHjU7XWHJum7mSJn9OmZRA56fxTtJsPPMaVNzHJM4ejZBN5TyzhVhusM+n+nMW7eYEzvOabC3Hkeuk7DS+GIJWGEeXVosvnlw3aOeoAGEzcr3HDBzcebd9PGSVZpq7hXBDmdfDW19ZM87YupGt/o1WLIY1i4mmOJNg4bSFe0dOKhuqUEXdskDF4MpJK9TAhdF2mwEfjPUmAlQNgd7eMCvJgfmga+2w8z2v0xMSbai6pABccDz/DOhHpjGcpgvDmU+Gg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=sourceware.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kLENllvyz3qgXiuQUOHTKkupB2k60/yDMSnsQqLFYVM=; b=NTb5sdQ5AuxTzZMjgnttYhsyyZr1zQ1ESI746b9IIQP9tIwj7pA7HZOsiMlaJcL9hzlZTeb928gQMJRWaynJXNP939vaCmgLS7onIMPxwXrPmBNhcuB3T8W1QAW6eh2Sxvq7UrTaQnm1mhWXGYF3qfLVn2yzGpurnt4KRPFvIcg= Received: from BL1PR13CA0337.namprd13.prod.outlook.com (2603:10b6:208:2c6::12) by DM4PR12MB6447.namprd12.prod.outlook.com (2603:10b6:8:bf::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.27; Tue, 21 Nov 2023 12:05:51 +0000 Received: from MN1PEPF0000F0E1.namprd04.prod.outlook.com (2603:10b6:208:2c6:cafe::4f) by BL1PR13CA0337.outlook.office365.com (2603:10b6:208:2c6::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.16 via Frontend Transport; Tue, 21 Nov 2023 12:05:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MN1PEPF0000F0E1.mail.protection.outlook.com (10.167.242.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7025.12 via Frontend Transport; Tue, 21 Nov 2023 12:05:50 +0000 Received: from hpe6u-23.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Tue, 21 Nov 2023 06:05:49 -0600 From: Lancelot Six To: CC: , , Lancelot Six Subject: [COMMITTED PATCH v2 2/9] gdb: Replace gdb::optional with std::optional Date: Tue, 21 Nov 2023 12:04:53 +0000 Message-ID: <20231121120500.1394523-3-lancelot.six@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028204821.fp5hh7bahrmrnpjl@hpe6u-23> References: <20231028204821.fp5hh7bahrmrnpjl@hpe6u-23> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000F0E1:EE_|DM4PR12MB6447:EE_ X-MS-Office365-Filtering-Correlation-Id: 3e57dbbd-c966-4b3a-25ba-08dbea8a347b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Gb83lEHx5b6ELGF4OqPahwmdqjhes9wrRAGQ7BwQZt6Y6WxqjTZijIo0pPXU0dVWo6KD5Hk3/aSP0YBxnme41a6AxvhUV2ONNxiYez+wBPZSmQY5eXfRjrCTYn66myptw1fffKGPnexeu4b0svTLNl62kVL36vZ5m36pDFahL8eUpMh+YL1jdDD/MHf1Ytj/PbL8E1VPgYLvthsG5z8R89ZLGtnzhlY98tJGtwpRIKpiYJeLPUjGQNFiTx4rXZTvth4px/vx0cRPsv3TKUkCa5Mw1uuypRb9MzMy7wJUPj5ALGrC4sd9fXfbCLTLWBHyGEGKtOMu3Dj6PFnV1dF38/y8lP8UTQ9fi/EbshdJTMjimK+fmSPJySE7N+/r++g6Uu+lPLUdrKNucyVcHGJ2rtW8PQJmiGd86ymR547yHlVSyEEWeugFelcmL+m+YjUVUquD/X49HLit3taKN789PoTAYt/uBu6vczo1bNJ3SgBe/lCVyDBCQJQ10+INJqf++jc3Ozt6E+4Rk3KFqOvTJHlJhrt8dpfj7L56QzoslUO2w+NeFkTne7h8n3/DsVLg9E2qn5Noi7tL0b2VySmWeZ1a+t1CqvxJPRDBcU0Hy7NvwoiA/35AWBExPyZNBeXfSAC804Obi+hxAYUs5wkdcklZ7dKdfTHBZztde6F+jEGbLtTkiCbLWp2Z2IypvXzy8VrBKzckbC8dxX3HRTdSpaJ1HHyXdn9KrsUFw1883p2c6B1PpfUGY0QfNfU9phJRzBhTlbzAKEaBF0hKn800EtuzUsQKdSI9HHETtSs+TX3mVfZui5dGwr9GL0glWuGAcoaHCrE8woFxAjcy7dc3BPn3k6fO6QI84medq5oKyWjeJ4BT0KO9vwk4RL7UsI92 X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(136003)(346002)(396003)(39860400002)(376002)(230922051799003)(230173577357003)(230273577357003)(451199024)(1800799012)(82310400011)(186009)(64100799003)(40470700004)(46966006)(36840700001)(2906002)(5660300002)(30864003)(44832011)(40480700001)(41300700001)(4326008)(8936002)(8676002)(316002)(6916009)(70206006)(54906003)(70586007)(40460700003)(66899024)(47076005)(86362001)(36756003)(7696005)(478600001)(1076003)(16526019)(26005)(6666004)(2616005)(336012)(426003)(36860700001)(83380400001)(356005)(81166007)(82740400003)(403724002)(36900700001)(579004)(559001)(357404004); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 12:05:50.9460 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3e57dbbd-c966-4b3a-25ba-08dbea8a347b X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MN1PEPF0000F0E1.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6447 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_FILL_THIS_FORM_SHORT, T_SCC_BODY_TEXT_LINE 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: 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+patchwork=sourceware.org@sourceware.org Since GDB now requires C++17, we don't need the internally maintained gdb::optional implementation. This patch does the following replacing: - gdb::optional -> std::optional - gdb::in_place -> std::in_place - #include "gdbsupport/gdb_optional.h" -> #include This change has mostly been done automatically. One exception is gdbsupport/thread-pool.* which did not use the gdb:: prefix as it already lives in the gdb namespace. Change-Id: I19a92fa03e89637bab136c72e34fd351524f65e9 Approved-By: Tom Tromey Approved-By: Pedro Alves --- gdb/aarch64-linux-tdep.c | 10 +++++----- gdb/ada-lang.c | 6 +++--- gdb/ada-lex.l | 2 +- gdb/ada-valprint.c | 4 ++-- gdb/amd-dbgapi-target.c | 4 ++-- gdb/annotate.c | 2 +- gdb/arm-fbsd-tdep.c | 6 +++--- gdb/arm-fbsd-tdep.h | 2 +- gdb/arm-linux-tdep.c | 2 +- gdb/arm-tdep.c | 4 ++-- gdb/auto-load.c | 2 +- gdb/auxv.c | 10 +++++----- gdb/auxv.h | 4 ++-- gdb/avr-tdep.c | 2 +- gdb/breakpoint.c | 19 ++++++++++--------- gdb/buildsym.c | 2 +- gdb/cli/cli-cmds.c | 6 +++--- gdb/cli/cli-cmds.h | 4 ++-- gdb/cli/cli-decode.c | 4 ++-- gdb/cli/cli-decode.h | 2 +- gdb/cli/cli-option.c | 14 +++++++------- gdb/cli/cli-option.h | 2 +- gdb/command.h | 2 +- gdb/compile/compile.c | 4 ++-- gdb/darwin-nat.c | 2 +- gdb/debuginfod-support.c | 10 +++++----- gdb/disasm.c | 14 +++++++------- gdb/disasm.h | 2 +- gdb/dwarf2/attribute.h | 2 +- gdb/dwarf2/cu.h | 8 ++++---- gdb/dwarf2/die.h | 4 ++-- gdb/dwarf2/index-cache.h | 2 +- gdb/dwarf2/index-write.c | 4 ++-- gdb/dwarf2/line-header.c | 4 ++-- gdb/dwarf2/macro.c | 4 ++-- gdb/dwarf2/macro.h | 2 +- gdb/dwarf2/read-gdb-index.c | 4 ++-- gdb/dwarf2/read.c | 24 ++++++++++++------------ gdb/dwarf2/read.h | 4 ++-- gdb/eval.c | 2 +- gdb/event-top.c | 2 +- gdb/exceptions.c | 4 ++-- gdb/extension-priv.h | 6 +++--- gdb/extension.c | 12 ++++++------ gdb/extension.h | 8 ++++---- gdb/f-lang.c | 2 +- gdb/fbsd-nat.c | 6 +++--- gdb/fbsd-nat.h | 4 ++-- gdb/fbsd-tdep.c | 8 ++++---- gdb/gdbthread.h | 8 ++++---- gdb/gdbtypes.c | 18 +++++++++--------- gdb/gdbtypes.h | 8 ++++---- gdb/guile/scm-ports.c | 4 ++-- gdb/ia64-tdep.c | 4 ++-- gdb/inf-child.c | 2 +- gdb/inf-child.h | 2 +- gdb/infcmd.c | 4 ++-- gdb/inferior.c | 4 ++-- gdb/inferior.h | 2 +- gdb/inflow.c | 4 ++-- gdb/infrun.c | 12 ++++++------ gdb/interps.c | 2 +- gdb/interps.h | 4 ++-- gdb/jit.c | 2 +- gdb/linux-nat.c | 10 +++++----- gdb/linux-nat.h | 2 +- gdb/linux-tdep.c | 18 +++++++++--------- gdb/linux-tdep.h | 4 ++-- gdb/linux-thread-db.c | 2 +- gdb/main.c | 4 ++-- gdb/mi/mi-cmd-stack.c | 4 ++-- gdb/mi/mi-cmd-var.c | 2 +- gdb/mi/mi-cmds.c | 2 +- gdb/mi/mi-cmds.h | 8 ++++---- gdb/mi/mi-interp.c | 2 +- gdb/mi/mi-interp.h | 2 +- gdb/mi/mi-main.c | 12 ++++++------ gdb/nat/linux-osdata.c | 8 ++++---- gdb/nat/windows-nat.c | 6 +++--- gdb/nat/windows-nat.h | 4 ++-- gdb/observable.h | 2 +- gdb/osdata.c | 2 +- gdb/parse.c | 4 ++-- gdb/ppc-linux-nat.c | 4 ++-- gdb/ppc-linux-tdep.c | 2 +- gdb/ppc-tdep.h | 2 +- gdb/printcmd.c | 6 +++--- gdb/probe.c | 22 +++++++++++----------- gdb/procfs.c | 2 +- gdb/psymtab.c | 2 +- gdb/psymtab.h | 2 +- gdb/python/py-disasm.c | 22 +++++++++++----------- gdb/python/py-framefilter.c | 10 +++++----- gdb/python/py-inferior.c | 2 +- gdb/python/py-mi.c | 2 +- gdb/python/py-utils.c | 4 ++-- gdb/python/python-internal.h | 4 ++-- gdb/python/python.c | 8 ++++---- gdb/ravenscar-thread.c | 4 ++-- gdb/record-btrace.c | 8 ++++---- gdb/regcache.c | 4 ++-- gdb/remote.c | 16 ++++++++-------- gdb/riscv-tdep.c | 2 +- gdb/s390-linux-tdep.c | 2 +- gdb/skip.c | 4 ++-- gdb/solib-aix.c | 14 +++++++------- gdb/solib-dsbt.c | 2 +- gdb/solib-svr4.c | 16 ++++++++-------- gdb/solib-target.c | 2 +- gdb/source-cache.c | 2 +- gdb/stack.c | 16 ++++++++-------- gdb/stack.h | 2 +- gdb/symfile.c | 2 +- gdb/symtab.c | 24 ++++++++++++------------ gdb/symtab.h | 24 ++++++++++++------------ gdb/target.c | 16 ++++++++-------- gdb/target.h | 10 +++++----- gdb/thread.c | 14 +++++++------- gdb/tracefile-tfile.c | 2 +- gdb/tracepoint.c | 2 +- gdb/tui/tui-disasm.c | 2 +- gdb/tui/tui-layout.c | 2 +- gdb/unittests/optional-selftests.c | 4 ++-- gdb/utils.c | 6 +++--- gdb/valarith.c | 4 ++-- gdb/valops.c | 6 +++--- gdb/value.c | 2 +- gdb/value.h | 4 ++-- gdb/windows-nat.c | 10 +++++----- gdb/xml-support.c | 4 ++-- gdb/xml-support.h | 6 +++--- gdb/xml-syscall.c | 2 +- gdb/xml-tdesc.c | 12 ++++++------ gdb/xml-tdesc.h | 4 ++-- gdbserver/linux-aarch64-low.cc | 4 ++-- gdbserver/regcache.cc | 4 ++-- gdbserver/regcache.h | 2 +- gdbserver/win32-low.cc | 2 +- gdbsupport/common-debug.h | 4 ++-- gdbsupport/event-loop.cc | 6 +++--- gdbsupport/filestuff.cc | 2 +- gdbsupport/filestuff.h | 2 +- gdbsupport/forward-scope-exit.h | 6 +++--- gdbsupport/range-chain.h | 2 +- gdbsupport/scoped_ignore_sigttou.h | 2 +- gdbsupport/thread-pool.cc | 2 +- gdbsupport/thread-pool.h | 4 ++-- 147 files changed, 417 insertions(+), 416 deletions(-) diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index f1fcce9b9eb..cd99b33fed2 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -1609,7 +1609,7 @@ static const struct target_desc * aarch64_linux_core_read_description (struct gdbarch *gdbarch, struct target_ops *target, bfd *abfd) { - gdb::optional auxv = target_read_auxv_raw (target); + std::optional auxv = target_read_auxv_raw (target); CORE_ADDR hwcap = linux_get_hwcap (auxv, target, gdbarch); CORE_ADDR hwcap2 = linux_get_hwcap2 (auxv, target, gdbarch); @@ -2427,7 +2427,7 @@ aarch64_linux_gcc_target_options (struct gdbarch *gdbarch) Return the allocation tag if successful and nullopt otherwise. */ -static gdb::optional +static std::optional aarch64_mte_get_atag (CORE_ADDR address) { gdb::byte_vector tags; @@ -2481,7 +2481,7 @@ aarch64_linux_memtag_matches_p (struct gdbarch *gdbarch, CORE_ADDR addr = value_as_address (address); /* Fetch the allocation tag for ADDRESS. */ - gdb::optional atag + std::optional atag = aarch64_mte_get_atag (gdbarch_remove_non_address_bits (gdbarch, addr)); if (!atag.has_value ()) @@ -2579,7 +2579,7 @@ aarch64_linux_get_memtag (struct gdbarch *gdbarch, struct value *address, /* Remove the top byte. */ addr = gdbarch_remove_non_address_bits (gdbarch, addr); - gdb::optional atag = aarch64_mte_get_atag (addr); + std::optional atag = aarch64_mte_get_atag (addr); if (!atag.has_value ()) return nullptr; @@ -2651,7 +2651,7 @@ aarch64_linux_report_signal_info (struct gdbarch *gdbarch, uiout->field_core_addr ("fault-addr", gdbarch, fault_addr); uiout->text ("\n"); - gdb::optional atag + std::optional atag = aarch64_mte_get_atag (gdbarch_remove_non_address_bits (gdbarch, fault_addr)); gdb_byte ltag = aarch64_mte_get_ltag (fault_addr); diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 9bb649e901d..58c70160d31 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -3098,7 +3098,7 @@ ada_value_slice_from_ptr (struct value *array_ptr, struct type *type, type0->dyn_prop (DYN_PROP_BYTE_STRIDE), type0->field (0).bitsize ()); int base_low = ada_discrete_type_low_bound (type0->index_type ()); - gdb::optional base_low_pos, low_pos; + std::optional base_low_pos, low_pos; CORE_ADDR base; low_pos = discrete_position (base_index_type, low); @@ -3132,7 +3132,7 @@ ada_value_slice (struct value *array, int low, int high) (alloc, type->target_type (), index_type, type->dyn_prop (DYN_PROP_BYTE_STRIDE), type->field (0).bitsize ()); - gdb::optional low_pos, high_pos; + std::optional low_pos, high_pos; low_pos = discrete_position (base_index_type, low); @@ -8792,7 +8792,7 @@ pos_atr (struct value *arg) if (!discrete_type_p (type)) error (_("'POS only defined on discrete types")); - gdb::optional result = discrete_position (type, value_as_long (val)); + std::optional result = discrete_position (type, value_as_long (val)); if (!result.has_value ()) error (_("enumeration value is invalid: can't find 'POS")); diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l index 0547b704eaf..0576f361a42 100644 --- a/gdb/ada-lex.l +++ b/gdb/ada-lex.l @@ -713,7 +713,7 @@ processAttribute (const char *str) if (strcasecmp (str, item.name) == 0) return item.code; - gdb::optional found; + std::optional found; for (const auto &item : attributes) if (subseqMatch (str, item.name)) { diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index b32f1e506d1..f1c4e8b0b70 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -385,7 +385,7 @@ ada_print_scalar (struct type *type, LONGEST val, struct ui_file *stream) case TYPE_CODE_ENUM: { - gdb::optional posn = discrete_position (type, val); + std::optional posn = discrete_position (type, val); if (posn.has_value ()) fputs_styled (ada_enum_name (type->field (*posn).name ()), variable_name_style.style (), stream); @@ -827,7 +827,7 @@ ada_val_print_enum (struct value *value, struct ui_file *stream, int recurse, int offset_aligned = ada_aligned_value_addr (type, valaddr) - valaddr; val = unpack_long (type, valaddr + offset_aligned); - gdb::optional posn = discrete_position (type, val); + std::optional posn = discrete_position (type, val); if (posn.has_value ()) { const char *name = ada_enum_name (type->field (*posn).name ()); diff --git a/gdb/amd-dbgapi-target.c b/gdb/amd-dbgapi-target.c index c03b64ce190..18c0543c40e 100644 --- a/gdb/amd-dbgapi-target.c +++ b/gdb/amd-dbgapi-target.c @@ -528,7 +528,7 @@ amd_dbgapi_target::xfer_partial (enum target_object object, const char *annex, ULONGEST offset, ULONGEST requested_len, ULONGEST *xfered_len) { - gdb::optional maybe_restore_thread; + std::optional maybe_restore_thread; if (!ptid_is_gpu (inferior_ptid)) return beneath ()->xfer_partial (object, annex, readbuf, writebuf, offset, @@ -1901,7 +1901,7 @@ static void amd_dbgapi_log_message_callback (amd_dbgapi_log_level_t level, const char *message) { - gdb::optional tstate; + std::optional tstate; if (target_supports_terminal_ours ()) { diff --git a/gdb/annotate.c b/gdb/annotate.c index 8385429042d..f3ead9e3ce2 100644 --- a/gdb/annotate.c +++ b/gdb/annotate.c @@ -233,7 +233,7 @@ annotate_thread_changed (void) static void annotate_thread_exited (thread_info *t, - gdb::optional exit_code, + std::optional exit_code, bool /* silent */) { if (annotation_level > 1) diff --git a/gdb/arm-fbsd-tdep.c b/gdb/arm-fbsd-tdep.c index 90273a3f5ef..391afec9e67 100644 --- a/gdb/arm-fbsd-tdep.c +++ b/gdb/arm-fbsd-tdep.c @@ -215,7 +215,7 @@ arm_fbsd_iterate_over_regset_sections (struct gdbarch *gdbarch, /* See arm-fbsd-tdep.h. */ const struct target_desc * -arm_fbsd_read_description_auxv (const gdb::optional &auxv, +arm_fbsd_read_description_auxv (const std::optional &auxv, target_ops *target, gdbarch *gdbarch, bool tls) { CORE_ADDR arm_hwcap = 0; @@ -244,7 +244,7 @@ arm_fbsd_read_description_auxv (const gdb::optional &auxv, const struct target_desc * arm_fbsd_read_description_auxv (bool tls) { - const gdb::optional &auxv = target_read_auxv (); + const std::optional &auxv = target_read_auxv (); return arm_fbsd_read_description_auxv (auxv, current_inferior ()->top_target (), current_inferior ()->arch (), @@ -260,7 +260,7 @@ arm_fbsd_core_read_description (struct gdbarch *gdbarch, { asection *tls = bfd_get_section_by_name (abfd, ".reg-aarch-tls"); - gdb::optional auxv = target_read_auxv_raw (target); + std::optional auxv = target_read_auxv_raw (target); return arm_fbsd_read_description_auxv (auxv, target, gdbarch, tls != nullptr); } diff --git a/gdb/arm-fbsd-tdep.h b/gdb/arm-fbsd-tdep.h index 3478e4b6860..7eb1850c1a7 100644 --- a/gdb/arm-fbsd-tdep.h +++ b/gdb/arm-fbsd-tdep.h @@ -47,7 +47,7 @@ extern const struct regset arm_fbsd_tls_regset; AUXV. */ extern const struct target_desc * - arm_fbsd_read_description_auxv (const gdb::optional &auxv, + arm_fbsd_read_description_auxv (const std::optional &auxv, target_ops *target, gdbarch *gdbarch, bool tls); diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c index 86fa3de0fd2..8117d35a4d3 100644 --- a/gdb/arm-linux-tdep.c +++ b/gdb/arm-linux-tdep.c @@ -732,7 +732,7 @@ arm_linux_core_read_description (struct gdbarch *gdbarch, struct target_ops *target, bfd *abfd) { - gdb::optional auxv = target_read_auxv_raw (target); + std::optional auxv = target_read_auxv_raw (target); CORE_ADDR arm_hwcap = linux_get_hwcap (auxv, target, gdbarch); if (arm_hwcap & HWCAP_VFP) diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index d4047ddbb86..7a93b098247 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -302,7 +302,7 @@ struct arm_prologue_cache int framereg; /* True if the return address is signed, false otherwise. */ - gdb::optional ra_signed_state; + std::optional ra_signed_state; /* Saved register offsets. */ trad_frame_saved_reg *saved_regs; @@ -1035,7 +1035,7 @@ thumb_analyze_prologue (struct gdbarch *gdbarch, while (start < limit) { unsigned short insn; - gdb::optional ra_signed_state; + std::optional ra_signed_state; insn = read_code_unsigned_integer (start, 2, byte_order_for_code); diff --git a/gdb/auto-load.c b/gdb/auto-load.c index 8bbe6696dcc..daea75b7437 100644 --- a/gdb/auto-load.c +++ b/gdb/auto-load.c @@ -914,7 +914,7 @@ source_script_file (struct auto_load_pspace_info *pspace_info, return; } - gdb::optional opened = find_and_open_script (file, + std::optional opened = find_and_open_script (file, 1 /*search_path*/); if (opened) diff --git a/gdb/auxv.c b/gdb/auxv.c index 61acd48fc98..994d97c1a2c 100644 --- a/gdb/auxv.c +++ b/gdb/auxv.c @@ -331,7 +331,7 @@ parse_auxv (target_ops *ops, gdbarch *gdbarch, const gdb_byte **readptr, overhead of transfering data from a remote target to the local host. */ struct auxv_info { - gdb::optional data; + std::optional data; }; /* Per-inferior data key for auxv. */ @@ -357,7 +357,7 @@ auxv_all_objfiles_removed (program_space *pspace) /* See auxv.h. */ -const gdb::optional & +const std::optional & target_read_auxv () { inferior *inf = current_inferior (); @@ -374,7 +374,7 @@ target_read_auxv () /* See auxv.h. */ -gdb::optional +std::optional target_read_auxv_raw (target_ops *ops) { return target_read_alloc (ops, TARGET_OBJECT_AUXV, NULL); @@ -413,7 +413,7 @@ target_auxv_search (const gdb::byte_vector &auxv, target_ops *ops, int target_auxv_search (CORE_ADDR match, CORE_ADDR *valp) { - const gdb::optional &auxv = target_read_auxv (); + const std::optional &auxv = target_read_auxv (); if (!auxv.has_value ()) return -1; @@ -572,7 +572,7 @@ fprint_target_auxv (struct ui_file *file) gdbarch *gdbarch = current_inferior ()->arch (); CORE_ADDR type, val; int ents = 0; - const gdb::optional &auxv = target_read_auxv (); + const std::optional &auxv = target_read_auxv (); if (!auxv.has_value ()) return -1; diff --git a/gdb/auxv.h b/gdb/auxv.h index a920f7a5da8..10f31dc84e8 100644 --- a/gdb/auxv.h +++ b/gdb/auxv.h @@ -48,11 +48,11 @@ extern int svr4_auxv_parse (struct gdbarch *gdbarch, const gdb_byte **readptr, /* Read auxv data from the current inferior's target stack. */ -extern const gdb::optional &target_read_auxv (); +extern const std::optional &target_read_auxv (); /* Read auxv data from OPS. */ -extern gdb::optional target_read_auxv_raw (target_ops *ops); +extern std::optional target_read_auxv_raw (target_ops *ops); /* Search AUXV for an entry with a_type matching MATCH. diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c index 92aec3b510f..598d740883c 100644 --- a/gdb/avr-tdep.c +++ b/gdb/avr-tdep.c @@ -1566,7 +1566,7 @@ avr_io_reg_read_command (const char *args, int from_tty) unsigned int val; /* Find out how many io registers the target has. */ - gdb::optional buf + std::optional buf = target_read_alloc (current_inferior ()->top_target (), TARGET_OBJECT_AVR, "avr.io_reg"); diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index cd8f36fbf05..af395fde14a 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -82,7 +82,7 @@ #include #include "progspace-and-thread.h" #include "gdbsupport/array-view.h" -#include "gdbsupport/gdb_optional.h" +#include #include "gdbsupport/common-utils.h" /* Prototypes for local functions. */ @@ -2067,7 +2067,7 @@ update_watchpoint (struct watchpoint *b, bool reparse) if (b->disposition == disp_del_at_next_stop) return; - gdb::optional restore_frame; + std::optional restore_frame; /* Determine if the watchpoint is within scope. */ if (b->exp_valid_block == NULL) @@ -3365,7 +3365,7 @@ remove_breakpoints (void) static void remove_threaded_breakpoints (thread_info *tp, - gdb::optional /* exit_code */, + std::optional /* exit_code */, int /* silent */) { for (breakpoint &b : all_breakpoints_safe ()) @@ -6776,8 +6776,8 @@ print_one_breakpoint_location (struct breakpoint *b, (uiout->test_flags (fix_breakpoint_script_output) || fix_breakpoint_script_output_globally); - gdb::optional tuple_emitter; - gdb::optional list_emitter; + std::optional tuple_emitter; + std::optional list_emitter; if (use_fixed_output) list_emitter.emplace (uiout, "script"); @@ -6850,7 +6850,8 @@ print_one_breakpoint (breakpoint *b, const bp_location **last_loc, int allflag) = (uiout->test_flags (fix_multi_location_breakpoint_output) || fix_multi_location_breakpoint_output_globally); - gdb::optional bkpt_tuple_emitter (gdb::in_place, uiout, "bkpt"); + std::optional bkpt_tuple_emitter (std::in_place, uiout, + "bkpt"); bool printed = print_one_breakpoint_location (b, NULL, 0, last_loc, allflag, false); @@ -6885,7 +6886,7 @@ print_one_breakpoint (breakpoint *b, const bp_location **last_loc, int allflag) || !b->first_loc ().enabled || b->first_loc ().disabled_by_cond)))) { - gdb::optional locations_list; + std::optional locations_list; /* For MI version <= 2, keep the behavior where GDB outputs an invalid MI record. For later versions, place breakpoint locations in a @@ -9950,7 +9951,7 @@ watchpoint::print_it (const bpstat *bs) const string_file stb; - gdb::optional tuple_emitter; + std::optional tuple_emitter; switch (this->type) { case bp_watchpoint: @@ -10928,7 +10929,7 @@ until_break_command (const char *arg, int from_tty, int anywhere) std::vector breakpoints; - gdb::optional lj_deleter; + std::optional lj_deleter; if (frame_id_p (caller_frame_id)) { diff --git a/gdb/buildsym.c b/gdb/buildsym.c index b982afea3d2..32d60cc22d4 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -643,7 +643,7 @@ buildsym_compunit::record_line (struct subfile *subfile, int line, anyway. */ if (line == 0) { - gdb::optional last_line; + std::optional last_line; while (!subfile->line_vector_entries.empty ()) { diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index fd93e5b4ccb..cb9ff554884 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -655,12 +655,12 @@ show_script_ext_mode (struct ui_file *file, int from_tty, If SEARCH_PATH is non-zero, and the file isn't found in cwd, search for it in the source search path. */ -gdb::optional +std::optional find_and_open_script (const char *script_file, int search_path) { int fd; openp_flags search_flags = OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH; - gdb::optional opened; + std::optional opened; gdb::unique_xmalloc_ptr file (tilde_expand (script_file)); @@ -742,7 +742,7 @@ source_script_with_search (const char *file, int from_tty, int search_path) if (file == NULL || *file == 0) error (_("source command requires file name of file to source.")); - gdb::optional opened = find_and_open_script (file, search_path); + std::optional opened = find_and_open_script (file, search_path); if (!opened) { /* The script wasn't found, or was otherwise inaccessible. diff --git a/gdb/cli/cli-cmds.h b/gdb/cli/cli-cmds.h index 429574426ac..a2579dc25f2 100644 --- a/gdb/cli/cli-cmds.h +++ b/gdb/cli/cli-cmds.h @@ -18,7 +18,7 @@ #define CLI_CLI_CMDS_H #include "gdbsupport/filestuff.h" -#include "gdbsupport/gdb_optional.h" +#include #include "completer.h" /* Chain containing all defined commands. */ @@ -179,7 +179,7 @@ struct open_script } }; -extern gdb::optional +extern std::optional find_and_open_script (const char *file, int search_path); /* Command tracing state. */ diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index 0bbe96b5334..940cd6a2c8e 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -24,7 +24,7 @@ #include "cli/cli-cmds.h" #include "cli/cli-decode.h" #include "cli/cli-style.h" -#include "gdbsupport/gdb_optional.h" +#include /* Prototypes for local functions. */ @@ -2727,7 +2727,7 @@ cmd_func (struct cmd_list_element *cmd, const char *args, int from_tty) { if (!cmd->is_command_class_help ()) { - gdb::optional> restore_suppress; + std::optional> restore_suppress; if (cmd->suppress_notification != NULL) restore_suppress.emplace (cmd->suppress_notification, true); diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h index 8fe9325c2da..14d9c29b464 100644 --- a/gdb/cli/cli-decode.h +++ b/gdb/cli/cli-decode.h @@ -233,7 +233,7 @@ struct cmd_list_element void (*destroyer) (struct cmd_list_element *self, void *context) = nullptr; /* Setting affected by "set" and "show". Not used if type is not_set_cmd. */ - gdb::optional var; + std::optional var; /* Pointer to NULL terminated list of enumerated values (like argv). */ diff --git a/gdb/cli/cli-option.c b/gdb/cli/cli-option.c index 9b303b1304e..d2d489b7219 100644 --- a/gdb/cli/cli-option.c +++ b/gdb/cli/cli-option.c @@ -58,11 +58,11 @@ struct option_def_and_value void *ctx; /* The option's value, if any. */ - gdb::optional value; + std::optional value; /* Constructor. */ option_def_and_value (const option_def &option_, void *ctx_, - gdb::optional &&value_ = {}) + std::optional &&value_ = {}) : option (option_), ctx (ctx_), value (std::move (value_)) @@ -99,7 +99,7 @@ struct option_def_and_value allocated on the heap, so we must clear the pointer in the source, to avoid a double free. */ static void clear_value (const option_def &option, - gdb::optional &value) + std::optional &value) { if (value.has_value ()) { @@ -109,7 +109,7 @@ struct option_def_and_value } }; -static void save_option_value_in_ctx (gdb::optional &ov); +static void save_option_value_in_ctx (std::optional &ov); /* Info passed around when handling completion. */ struct parse_option_completion_info @@ -177,7 +177,7 @@ complete_on_all_options (completion_tracker &tracker, /* Parse ARGS, guided by OPTIONS_GROUP. HAVE_DELIMITER is true if the whole ARGS line included the "--" options-terminator delimiter. */ -static gdb::optional +static std::optional parse_option (gdb::array_view options_group, process_options_mode mode, bool have_delimiter, @@ -496,7 +496,7 @@ complete_options (completion_tracker &tracker, } else if (**args == '-') { - gdb::optional ov + std::optional ov = parse_option (options_group, mode, have_delimiter, args, &completion_info); if (!ov && !tracker.have_completions ()) @@ -589,7 +589,7 @@ complete_options (completion_tracker &tracker, /* Save the parsed value in the option's context. */ static void -save_option_value_in_ctx (gdb::optional &ov) +save_option_value_in_ctx (std::optional &ov) { switch (ov->option.type) { diff --git a/gdb/cli/cli-option.h b/gdb/cli/cli-option.h index 7b015b89f47..4c62227f31c 100644 --- a/gdb/cli/cli-option.h +++ b/gdb/cli/cli-option.h @@ -20,7 +20,7 @@ #ifndef CLI_OPTION_H #define CLI_OPTION_H 1 -#include "gdbsupport/gdb_optional.h" +#include #include "gdbsupport/array-view.h" #include "completer.h" #include diff --git a/gdb/command.h b/gdb/command.h index 467bb283cdc..1ab953b996b 100644 --- a/gdb/command.h +++ b/gdb/command.h @@ -126,7 +126,7 @@ struct literal_def LONGEST use; /* An optional number accepted that stands for the literal. */ - gdb::optional val; + std::optional val; }; /* Return true if a setting of type VAR_TYPE is backed with type T. diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c index a93c9404660..be1bcca47b4 100644 --- a/gdb/compile/compile.c +++ b/gdb/compile/compile.c @@ -40,7 +40,7 @@ #include "osabi.h" #include "gdbsupport/gdb_wait.h" #include "valprint.h" -#include "gdbsupport/gdb_optional.h" +#include #include "gdbsupport/gdb_unlinker.h" #include "gdbsupport/pathstuff.h" #include "gdbsupport/scoped_ignore_signal.h" @@ -768,7 +768,7 @@ compile_to_object (struct command_line *cmd, const char *cmd_string, compile_file_names fnames = get_new_file_names (); - gdb::optional source_remover; + std::optional source_remover; { gdb_file_up src = gdb_fopen_cloexec (fnames.source_file (), "w"); diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c index 0de476b022b..f5624956e76 100644 --- a/gdb/darwin-nat.c +++ b/gdb/darwin-nat.c @@ -1968,7 +1968,7 @@ darwin_nat_target::create_inferior (const char *exec_file, const std::string &allargs, char **env, int from_tty) { - gdb::optional> restore_startup_with_shell; + std::optional> restore_startup_with_shell; darwin_nat_target *the_target = this; if (startup_with_shell && may_have_sip ()) diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c index 902af405cc6..1ebd98ca705 100644 --- a/gdb/debuginfod-support.c +++ b/gdb/debuginfod-support.c @@ -21,7 +21,7 @@ #include #include "gdbsupport/scoped_fd.h" #include "debuginfod-support.h" -#include "gdbsupport/gdb_optional.h" +#include #include "cli/cli-cmds.h" #include "cli/cli-style.h" #include "cli-out.h" @@ -320,7 +320,7 @@ debuginfod_source_query (const unsigned char *build_id, char *dname = nullptr; scoped_fd fd; - gdb::optional term_state; + std::optional term_state; { user_data data ("source file", srcpath); @@ -366,7 +366,7 @@ debuginfod_debuginfo_query (const unsigned char *build_id, char *dname = nullptr; scoped_fd fd; - gdb::optional term_state; + std::optional term_state; { user_data data ("separate debug info for", filename); @@ -409,7 +409,7 @@ debuginfod_exec_query (const unsigned char *build_id, char *dname = nullptr; scoped_fd fd; - gdb::optional term_state; + std::optional term_state; { user_data data ("executable for", filename); @@ -458,7 +458,7 @@ debuginfod_section_query (const unsigned char *build_id, char *dname = nullptr; std::string desc = std::string ("section ") + section_name + " for"; scoped_fd fd; - gdb::optional term_state; + std::optional term_state; { user_data data (desc.c_str (), filename); diff --git a/gdb/disasm.c b/gdb/disasm.c index 2e866f6865e..82b7e990ff9 100644 --- a/gdb/disasm.c +++ b/gdb/disasm.c @@ -29,7 +29,7 @@ #include "source.h" #include "gdbsupport/gdb-safe-ctype.h" #include -#include "gdbsupport/gdb_optional.h" +#include #include "valprint.h" #include "cli/cli-style.h" #include "objfiles.h" @@ -653,8 +653,8 @@ do_mixed_source_and_assembly_deprecated ui_out_emit_list asm_insns_list (uiout, "asm_insns"); - gdb::optional outer_tuple_emitter; - gdb::optional inner_list_emitter; + std::optional outer_tuple_emitter; + std::optional inner_list_emitter; for (i = 0; i < newlines; i++) { @@ -810,8 +810,8 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch, ui_out_emit_list asm_insns_emitter (uiout, "asm_insns"); - gdb::optional tuple_emitter; - gdb::optional list_emitter; + std::optional tuple_emitter; + std::optional list_emitter; last_symtab = NULL; last_line = 0; @@ -1093,7 +1093,7 @@ gdb_print_insn_1 (struct gdbarch *gdbarch, CORE_ADDR vma, struct disassemble_info *info) { /* Call into the extension languages to do the disassembly. */ - gdb::optional length = ext_lang_print_insn (gdbarch, vma, info); + std::optional length = ext_lang_print_insn (gdbarch, vma, info); if (length.has_value ()) return *length; @@ -1125,7 +1125,7 @@ gdb_disassembler::print_insn (CORE_ADDR memaddr, this output. */ if (length > 0 && use_ext_lang_for_styling ()) { - gdb::optional ext_contents; + std::optional ext_contents; ext_contents = ext_lang_colorize_disasm (m_buffer.string (), arch ()); if (ext_contents.has_value ()) m_buffer = std::move (*ext_contents); diff --git a/gdb/disasm.h b/gdb/disasm.h index dbc63e52ed2..5596bd62a10 100644 --- a/gdb/disasm.h +++ b/gdb/disasm.h @@ -275,7 +275,7 @@ struct gdb_disassembler : public gdb_printing_disassembler, negative value (which indicates an error), then, if this variable has a value, we report a memory error to the user, otherwise, we report a non-memory error. */ - gdb::optional m_err_memaddr; + std::optional m_err_memaddr; /* The stream to which disassembler output will be written. */ ui_file *m_dest; diff --git a/gdb/dwarf2/attribute.h b/gdb/dwarf2/attribute.h index 4cfdaa1e355..fdb579a368a 100644 --- a/gdb/dwarf2/attribute.h +++ b/gdb/dwarf2/attribute.h @@ -29,7 +29,7 @@ #include "dwarf2.h" #include "dwarf2/types.h" -#include "gdbsupport/gdb_optional.h" +#include /* Blocks are a bunch of untyped bytes. */ struct dwarf_block diff --git a/gdb/dwarf2/cu.h b/gdb/dwarf2/cu.h index ef8db480e3f..a8879de73e5 100644 --- a/gdb/dwarf2/cu.h +++ b/gdb/dwarf2/cu.h @@ -22,7 +22,7 @@ #include "buildsym.h" #include "dwarf2/comp-unit-head.h" -#include "gdbsupport/gdb_optional.h" +#include #include "language.h" /* Type used for delaying computation of method physnames. @@ -101,7 +101,7 @@ struct dwarf2_cu struct comp_unit_head header; /* Base address of this compilation unit. */ - gdb::optional base_address; + std::optional base_address; /* The language we are debugging. */ const struct language_defn *language_defn = nullptr; @@ -189,7 +189,7 @@ struct dwarf2_cu /* The DW_AT_addr_base (DW_AT_GNU_addr_base) attribute if present. Note this value comes from the Fission stub CU/TU's DIE. */ - gdb::optional addr_base; + std::optional addr_base; /* The DW_AT_GNU_ranges_base attribute, if present. @@ -242,7 +242,7 @@ struct dwarf2_cu files, the value is implicitly zero. For DWARF 5 version DWO files, the value is often implicit and is the size of the header of .debug_str_offsets section (8 or 4, depending on the address size). */ - gdb::optional str_offsets_base; + std::optional str_offsets_base; /* Mark used when releasing cached dies. */ bool m_mark : 1; diff --git a/gdb/dwarf2/die.h b/gdb/dwarf2/die.h index cdee46996d6..c7040776b07 100644 --- a/gdb/dwarf2/die.h +++ b/gdb/dwarf2/die.h @@ -59,7 +59,7 @@ struct die_info /* Return the address base of the compile unit, which, if exists, is stored either at the attribute DW_AT_GNU_addr_base, or DW_AT_addr_base. */ - gdb::optional addr_base () + std::optional addr_base () { for (unsigned i = 0; i < num_attrs; ++i) if (attrs[i].name == DW_AT_addr_base @@ -73,7 +73,7 @@ struct die_info complaint (_("address base attribute (offset %s) as wrong form"), sect_offset_str (sect_off)); } - return gdb::optional (); + return std::optional (); } /* Return the base address of the compile unit into the .debug_ranges section, diff --git a/gdb/dwarf2/index-cache.h b/gdb/dwarf2/index-cache.h index cfa45435fbd..023fc86fc89 100644 --- a/gdb/dwarf2/index-cache.h +++ b/gdb/dwarf2/index-cache.h @@ -52,7 +52,7 @@ struct index_cache_store_context std::string build_id_str; /* Captured value of dwz build id. */ - gdb::optional dwz_build_id_str; + std::optional dwz_build_id_str; }; /* Class to manage the access to the DWARF index cache. */ diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index c9d6e633bf3..d1b10a28823 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -1474,7 +1474,7 @@ struct index_wip_file FILENAME_TEMP is unlinked, because on MS-Windows one cannot delete a file that is still open. So, we wrap the unlinker in an optional and emplace it once we know the file name. */ - gdb::optional unlink_file; + std::optional unlink_file; gdb_file_up out_file; }; @@ -1497,7 +1497,7 @@ write_dwarf_index (dwarf2_per_bfd *per_bfd, const char *dir, ? INDEX5_SUFFIX : INDEX4_SUFFIX); index_wip_file objfile_index_wip (dir, basename, index_suffix); - gdb::optional dwz_index_wip; + std::optional dwz_index_wip; if (dwz_basename != NULL) dwz_index_wip.emplace (dir, dwz_basename, index_suffix); diff --git a/gdb/dwarf2/line-header.c b/gdb/dwarf2/line-header.c index d072a91bac9..ddaf7e4a527 100644 --- a/gdb/dwarf2/line-header.c +++ b/gdb/dwarf2/line-header.c @@ -160,8 +160,8 @@ read_formatted_entries (dwarf2_per_objfile *per_objfile, bfd *abfd, ULONGEST form = read_unsigned_leb128 (abfd, format, &bytes_read); format += bytes_read; - gdb::optional string; - gdb::optional uint; + std::optional string; + std::optional uint; switch (form) { diff --git a/gdb/dwarf2/macro.c b/gdb/dwarf2/macro.c index 78cce2d69eb..2e88e670216 100644 --- a/gdb/dwarf2/macro.c +++ b/gdb/dwarf2/macro.c @@ -444,7 +444,7 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile, unsigned int offset_size, struct dwarf2_section_info *str_section, struct dwarf2_section_info *str_offsets_section, - gdb::optional str_offsets_base, + std::optional str_offsets_base, htab_t include_hash, struct dwarf2_cu *cu) { struct objfile *objfile = per_objfile->objfile; @@ -805,7 +805,7 @@ dwarf_decode_macros (dwarf2_per_objfile *per_objfile, const struct line_header *lh, unsigned int offset_size, unsigned int offset, struct dwarf2_section_info *str_section, struct dwarf2_section_info *str_offsets_section, - gdb::optional str_offsets_base, + std::optional str_offsets_base, int section_is_gnu, struct dwarf2_cu *cu) { bfd *abfd; diff --git a/gdb/dwarf2/macro.h b/gdb/dwarf2/macro.h index d92994fef16..7daf147033a 100644 --- a/gdb/dwarf2/macro.h +++ b/gdb/dwarf2/macro.h @@ -30,7 +30,7 @@ extern void dwarf_decode_macros (dwarf2_per_objfile *per_objfile, unsigned int offset, dwarf2_section_info *str_section, dwarf2_section_info *str_offsets_section, - gdb::optional str_offsets_base, + std::optional str_offsets_base, int section_is_gnu, struct dwarf2_cu *cu); #endif /* GDB_DWARF2_MACRO_H */ diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c index 064a9f17b0e..7788626b67a 100644 --- a/gdb/dwarf2/read-gdb-index.c +++ b/gdb/dwarf2/read-gdb-index.c @@ -181,7 +181,7 @@ struct dw2_symtab_iterator dwarf2_per_objfile *per_objfile; /* If set, only look for symbols that match that block. Valid values are GLOBAL_BLOCK and STATIC_BLOCK. */ - gdb::optional block_index; + std::optional block_index; /* The kind of symbol we're looking for. */ domain_enum domain; /* The list of CUs from the index entry of the symbol, @@ -203,7 +203,7 @@ struct dw2_symtab_iterator static void dw2_symtab_iter_init (struct dw2_symtab_iterator *iter, dwarf2_per_objfile *per_objfile, - gdb::optional block_index, + std::optional block_index, domain_enum domain, offset_type namei, mapped_gdb_index &index) { diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 2a7fd8f5de5..6d86d28d8c0 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -78,7 +78,7 @@ #include "build-id.h" #include "namespace.h" #include "gdbsupport/function-view.h" -#include "gdbsupport/gdb_optional.h" +#include #include "gdbsupport/underlying.h" #include "gdbsupport/hash_enum.h" #include "filename-seen-cache.h" @@ -3916,7 +3916,7 @@ read_cutu_die_from_dwo (dwarf2_cu *cu, /* Return the signature of the compile unit, if found. In DWARF 4 and before, the signature is in the DW_AT_GNU_dwo_id attribute. In DWARF 5 and later, the signature is part of the header. */ -static gdb::optional +static std::optional lookup_dwo_id (struct dwarf2_cu *cu, struct die_info* comp_unit_die) { if (cu->header.version >= 5) @@ -3924,7 +3924,7 @@ lookup_dwo_id (struct dwarf2_cu *cu, struct die_info* comp_unit_die) struct attribute *attr; attr = dwarf2_attr (comp_unit_die, DW_AT_GNU_dwo_id, cu); if (attr == nullptr || !attr->form_is_unsigned ()) - return gdb::optional (); + return std::optional (); return attr->as_unsigned (); } @@ -3957,7 +3957,7 @@ lookup_dwo_unit (dwarf2_cu *cu, die_info *comp_unit_die, const char *dwo_name) dwo_unit = lookup_dwo_type_unit (cu, dwo_name, comp_dir); else { - gdb::optional signature = lookup_dwo_id (cu, comp_unit_die); + std::optional signature = lookup_dwo_id (cu, comp_unit_die); if (!signature.has_value ()) error (_("Dwarf Error: missing dwo_id for dwo_name %s" @@ -7829,7 +7829,7 @@ create_dwo_cu_reader (const struct die_reader_specs *reader, sect_offset sect_off = cu->per_cu->sect_off; struct dwarf2_section_info *section = cu->per_cu->section; - gdb::optional signature = lookup_dwo_id (cu, comp_unit_die); + std::optional signature = lookup_dwo_id (cu, comp_unit_die); if (!signature.has_value ()) { complaint (_("Dwarf Error: debug entry at offset %s is missing" @@ -10633,7 +10633,7 @@ dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu, struct objfile *objfile = per_objfile->objfile; bfd *obfd = objfile->obfd.get (); /* Base address selection entry. */ - gdb::optional base; + std::optional base; const gdb_byte *buffer; bool overflow = false; ULONGEST addr_index; @@ -10839,7 +10839,7 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu, dwarf_tag tag, unsigned int addr_size = cu_header->addr_size; CORE_ADDR mask = ~(~(CORE_ADDR)1 << (addr_size * 8 - 1)); /* Base address selection entry. */ - gdb::optional base; + std::optional base; unsigned int dummy; const gdb_byte *buffer; @@ -16070,8 +16070,8 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu, bool is_declaration = false; sect_offset origin_offset {}; - gdb::optional low_pc; - gdb::optional high_pc; + std::optional low_pc; + std::optional high_pc; bool high_pc_relative = false; for (int i = 0; i < abbrev->num_attrs; ++i) @@ -17448,7 +17448,7 @@ dwarf2_per_objfile::read_line_string (const gdb_byte *buf, static unrelocated_addr read_addr_index_1 (dwarf2_per_objfile *per_objfile, unsigned int addr_index, - gdb::optional addr_base, int addr_size) + std::optional addr_base, int addr_size) { struct objfile *objfile = per_objfile->objfile; bfd *abfd = objfile->obfd.get (); @@ -17501,7 +17501,7 @@ dwarf2_read_addr_index (dwarf2_per_cu_data *per_cu, unsigned int addr_index) { struct dwarf2_cu *cu = per_objfile->get_cu (per_cu); - gdb::optional addr_base; + std::optional addr_base; int addr_size; /* We need addr_base and addr_size. @@ -21270,7 +21270,7 @@ dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset, struct dwarf2_section_info *str_offsets_section; struct dwarf2_section_info *str_section; - gdb::optional str_offsets_base; + std::optional str_offsets_base; if (cu->dwo_unit != nullptr) { diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index da907729320..7bb6d4c4d4b 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -524,7 +524,7 @@ struct dwarf2_per_bfd /* The shared '.dwz' file, if one exists. This is used when the original data was compressed using 'dwz -m'. */ - gdb::optional> dwz_file; + std::optional> dwz_file; /* Whether copy relocations are supported by this object format. */ bool can_copy; @@ -743,7 +743,7 @@ struct dwarf2_per_objfile dwarf2_cu *sym_cu = nullptr; /* CUs that are queued to be read. */ - gdb::optional> queue; + std::optional> queue; private: /* Hold the corresponding compunit_symtab for each CU or TU. This diff --git a/gdb/eval.c b/gdb/eval.c index b859e825925..3358b0d8d32 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -102,7 +102,7 @@ expression::uses_objfile (struct objfile *objfile) const struct value * expression::evaluate (struct type *expect_type, enum noside noside) { - gdb::optional stack_temporaries; + std::optional stack_temporaries; if (target_has_execution () && inferior_ptid != null_ptid && language_defn->la_language == language_cplus && !thread_stack_temporaries_enabled_p (inferior_thread ())) diff --git a/gdb/event-top.c b/gdb/event-top.c index 6ce53704539..d47e703d961 100644 --- a/gdb/event-top.c +++ b/gdb/event-top.c @@ -706,7 +706,7 @@ void gdb_rl_deprep_term_function (void) { #ifdef RL_STATE_EOF - gdb::optional> restore_eof_found; + std::optional> restore_eof_found; if (RL_ISSTATE (RL_STATE_EOF)) { diff --git a/gdb/exceptions.c b/gdb/exceptions.c index 2ba5a9c9fad..61fe74f648c 100644 --- a/gdb/exceptions.c +++ b/gdb/exceptions.c @@ -27,7 +27,7 @@ #include "serial.h" #include "gdbthread.h" #include "ui.h" -#include "gdbsupport/gdb_optional.h" +#include static void print_flush (void) @@ -38,7 +38,7 @@ print_flush (void) if (deprecated_error_begin_hook) deprecated_error_begin_hook (); - gdb::optional term_state; + std::optional term_state; if (target_supports_terminal_ours ()) { term_state.emplace (); diff --git a/gdb/extension-priv.h b/gdb/extension-priv.h index e71eac20d4e..ccb63e694a5 100644 --- a/gdb/extension-priv.h +++ b/gdb/extension-priv.h @@ -256,13 +256,13 @@ struct extension_language_ops CONTENTS is the contents of the file. This should either return colorized (using ANSI terminal escapes) version of the contents, or an empty option. */ - gdb::optional (*colorize) (const std::string &name, + std::optional (*colorize) (const std::string &name, const std::string &contents); /* Colorize a single line of disassembler output, CONTENT. This should either return colorized (using ANSI terminal escapes) version of the contents, or an empty optional. */ - gdb::optional (*colorize_disasm) (const std::string &content, + std::optional (*colorize_disasm) (const std::string &content, gdbarch *gdbarch); /* Print a single instruction from ADDRESS in architecture GDBARCH. INFO @@ -276,7 +276,7 @@ struct extension_language_ops If no instruction can be disassembled then return an empty value and other extension languages will get a chance to perform the disassembly. */ - gdb::optional (*print_insn) (struct gdbarch *gdbarch, + std::optional (*print_insn) (struct gdbarch *gdbarch, CORE_ADDR address, struct disassemble_info *info); diff --git a/gdb/extension.c b/gdb/extension.c index 9cb393e1d50..2d7a381e426 100644 --- a/gdb/extension.c +++ b/gdb/extension.c @@ -939,10 +939,10 @@ xmethod_worker::get_result_type (value *object, gdb::array_view args) /* See extension.h. */ -gdb::optional +std::optional ext_lang_colorize (const std::string &filename, const std::string &contents) { - gdb::optional result; + std::optional result; for (const struct extension_language_defn *extlang : extension_languages) { @@ -959,10 +959,10 @@ ext_lang_colorize (const std::string &filename, const std::string &contents) /* See extension.h. */ -gdb::optional +std::optional ext_lang_colorize_disasm (const std::string &content, gdbarch *gdbarch) { - gdb::optional result; + std::optional result; for (const struct extension_language_defn *extlang : extension_languages) { @@ -979,7 +979,7 @@ ext_lang_colorize_disasm (const std::string &content, gdbarch *gdbarch) /* See extension.h. */ -gdb::optional +std::optional ext_lang_print_insn (struct gdbarch *gdbarch, CORE_ADDR address, struct disassemble_info *info) { @@ -988,7 +988,7 @@ ext_lang_print_insn (struct gdbarch *gdbarch, CORE_ADDR address, if (extlang->ops == nullptr || extlang->ops->print_insn == nullptr) continue; - gdb::optional length + std::optional length = extlang->ops->print_insn (gdbarch, address, info); if (length.has_value ()) return length; diff --git a/gdb/extension.h b/gdb/extension.h index 282d591be43..530f6ce72ac 100644 --- a/gdb/extension.h +++ b/gdb/extension.h @@ -22,7 +22,7 @@ #include "mi/mi-cmds.h" #include "gdbsupport/array-view.h" -#include "gdbsupport/gdb_optional.h" +#include struct breakpoint; struct command_line; @@ -316,7 +316,7 @@ extern void get_matching_xmethod_workers either a colorized (using ANSI terminal escapes) version of the source code, or an empty value if colorizing could not be done. */ -extern gdb::optional ext_lang_colorize +extern std::optional ext_lang_colorize (const std::string &filename, const std::string &contents); /* Try to colorize a single line of disassembler output, CONTENT for @@ -324,7 +324,7 @@ extern gdb::optional ext_lang_colorize escapes) version of CONTENT, or an empty value if colorizing could not be done. */ -extern gdb::optional ext_lang_colorize_disasm +extern std::optional ext_lang_colorize_disasm (const std::string &content, gdbarch *gdbarch); /* Calls extension_language_ops::print_insn for each extension language, @@ -334,7 +334,7 @@ extern gdb::optional ext_lang_colorize_disasm All arguments are forwarded to extension_language_ops::print_insn, see that function for a full description. */ -extern gdb::optional ext_lang_print_insn +extern std::optional ext_lang_print_insn (struct gdbarch *gdbarch, CORE_ADDR address, struct disassemble_info *info); /* When GDB calls into an extension language because an objfile was diff --git a/gdb/f-lang.c b/gdb/f-lang.c index fc0614e5761..ebcca7adea3 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -306,7 +306,7 @@ class fortran_array_repacker_base_impl /* Set and reset to handle removing intermediate values from the value chain. */ - gdb::optional m_mark; + std::optional m_mark; }; /* A class used by FORTRAN_VALUE_SUBARRAY when repacking Fortran array diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c index 0e0d0cdf621..211b83f555a 100644 --- a/gdb/fbsd-nat.c +++ b/gdb/fbsd-nat.c @@ -99,7 +99,7 @@ fbsd_nat_target::have_pending_event (ptid_t filter) /* See fbsd-nat.h. */ -gdb::optional +std::optional fbsd_nat_target::take_pending_event (ptid_t filter) { for (auto it = m_pending_events.begin (); it != m_pending_events.end (); it++) @@ -1663,7 +1663,7 @@ fbsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus, target_options_to_string (target_options).c_str ()); /* If there is a valid pending event, return it. */ - gdb::optional event = take_pending_event (ptid); + std::optional event = take_pending_event (ptid); if (event.has_value ()) { /* Stop any other inferiors currently running. */ @@ -1899,7 +1899,7 @@ fbsd_nat_target::detach_fork_children (inferior *inf) while (1) { - gdb::optional event = take_pending_event (ptid); + std::optional event = take_pending_event (ptid); if (!event.has_value ()) break; diff --git a/gdb/fbsd-nat.h b/gdb/fbsd-nat.h index 7016cc0242a..8118408bf47 100644 --- a/gdb/fbsd-nat.h +++ b/gdb/fbsd-nat.h @@ -20,7 +20,7 @@ #ifndef FBSD_NAT_H #define FBSD_NAT_H -#include "gdbsupport/gdb_optional.h" +#include #include "inf-ptrace.h" #include "regcache.h" #include "regset.h" @@ -262,7 +262,7 @@ class fbsd_nat_target : public inf_ptrace_target FILTER. If there is a matching event, the event is removed from the pending list and returned. */ - gdb::optional take_pending_event (ptid_t filter); + std::optional take_pending_event (ptid_t filter); /* List of pending events. */ diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c index d166d785736..4ac33697082 100644 --- a/gdb/fbsd-tdep.c +++ b/gdb/fbsd-tdep.c @@ -650,10 +650,10 @@ find_signalled_thread (struct thread_info *info, void *data) the data is prefixed with a 32-bit integer size to match the format used in FreeBSD NT_PROCSTAT_* notes. */ -static gdb::optional +static std::optional fbsd_make_note_desc (enum target_object object, uint32_t structsize) { - gdb::optional buf = + std::optional buf = target_read_alloc (current_inferior ()->top_target (), object, NULL); if (!buf || buf->empty ()) return {}; @@ -735,7 +735,7 @@ fbsd_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size) /* Auxiliary vector. */ uint32_t structsize = gdbarch_ptr_bit (gdbarch) / 4; /* Elf_Auxinfo */ - gdb::optional note_desc = + std::optional note_desc = fbsd_make_note_desc (TARGET_OBJECT_AUXV, structsize); if (note_desc && !note_desc->empty ()) { @@ -2340,7 +2340,7 @@ fbsd_vdso_range (struct gdbarch *gdbarch, struct mem_range *range) else { /* Fetch the list of address space entries from the running target. */ - gdb::optional buf = + std::optional buf = target_read_alloc (current_inferior ()->top_target (), TARGET_OBJECT_FREEBSD_VMMAP, nullptr); if (!buf || buf->empty ()) diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h index 938a47ff012..b2c6baf4432 100644 --- a/gdb/gdbthread.h +++ b/gdb/gdbthread.h @@ -211,10 +211,10 @@ struct thread_suspend_state - If the thread is running, then this field has its value removed by calling stop_pc.reset() (see thread_info::set_executing()). - Attempting to read a gdb::optional with no value is undefined + Attempting to read a std::optional with no value is undefined behaviour and will trigger an assertion error when _GLIBCXX_DEBUG is defined, which should make error easier to track down. */ - gdb::optional stop_pc; + std::optional stop_pc; }; /* Base class for target-specific thread data. */ @@ -661,7 +661,7 @@ extern void delete_thread_silent (struct thread_info *thread); available. If SILENT, then don't inform the CLI about the exit. */ extern void set_thread_exited (thread_info *tp, - gdb::optional exit_code = {}, + std::optional exit_code = {}, bool silent = false); /* Delete a step_resume_breakpoint from the thread database. */ @@ -1058,7 +1058,7 @@ extern bool switch_to_thread_if_alive (thread_info *thr); exception if !FLAGS.SILENT and !FLAGS.CONT and CMD fails. */ extern void thread_try_catch_cmd (thread_info *thr, - gdb::optional ada_task, + std::optional ada_task, const char *cmd, int from_tty, const qcs_flags &flags); diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index e424077c1c0..04598c6f4be 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1045,7 +1045,7 @@ has_static_range (const struct range_bounds *bounds) /* See gdbtypes.h. */ -gdb::optional +std::optional get_discrete_low_bound (struct type *type) { type = check_typedef (type); @@ -1061,7 +1061,7 @@ get_discrete_low_bound (struct type *type) if (type->target_type ()->code () == TYPE_CODE_ENUM) { - gdb::optional low_pos + std::optional low_pos = discrete_position (type->target_type (), low); if (low_pos.has_value ()) @@ -1112,7 +1112,7 @@ get_discrete_low_bound (struct type *type) /* See gdbtypes.h. */ -gdb::optional +std::optional get_discrete_high_bound (struct type *type) { type = check_typedef (type); @@ -1128,7 +1128,7 @@ get_discrete_high_bound (struct type *type) if (type->target_type ()->code () == TYPE_CODE_ENUM) { - gdb::optional high_pos + std::optional high_pos = discrete_position (type->target_type (), high); if (high_pos.has_value ()) @@ -1191,11 +1191,11 @@ get_discrete_high_bound (struct type *type) bool get_discrete_bounds (struct type *type, LONGEST *lowp, LONGEST *highp) { - gdb::optional low = get_discrete_low_bound (type); + std::optional low = get_discrete_low_bound (type); if (!low.has_value ()) return false; - gdb::optional high = get_discrete_high_bound (type); + std::optional high = get_discrete_high_bound (type); if (!high.has_value ()) return false; @@ -1243,7 +1243,7 @@ get_array_bounds (struct type *type, LONGEST *low_bound, LONGEST *high_bound) in which case the value of POS is unmodified. */ -gdb::optional +std::optional discrete_position (struct type *type, LONGEST val) { if (type->code () == TYPE_CODE_RANGE) @@ -2534,7 +2534,7 @@ compute_variant_fields_inner (struct type *type, std::vector &flags) { /* Evaluate the discriminant. */ - gdb::optional discr_value; + std::optional discr_value; if (part.discriminant_index != -1) { int idx = part.discriminant_index; @@ -2757,7 +2757,7 @@ resolve_dynamic_type_internal (struct type *type, if (!is_dynamic_type_internal (real_type, top_level)) return type; - gdb::optional type_length; + std::optional type_length; prop = TYPE_DYNAMIC_LENGTH (type); if (prop != NULL && dwarf2_evaluate_property (prop, frame, addr_stack, &value)) diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 505c8ba12b5..d5bd6d2d2d7 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -47,7 +47,7 @@ #include "hashtab.h" #include "gdbsupport/array-view.h" #include "gdbsupport/gdb-hashtab.h" -#include "gdbsupport/gdb_optional.h" +#include #include "gdbsupport/offset-type.h" #include "gdbsupport/enum-flags.h" #include "gdbsupport/underlying.h" @@ -2663,11 +2663,11 @@ extern bool get_discrete_bounds (struct type *type, LONGEST *lowp, /* If TYPE's low bound is a known constant, return it, else return nullopt. */ -extern gdb::optional get_discrete_low_bound (struct type *type); +extern std::optional get_discrete_low_bound (struct type *type); /* If TYPE's high bound is a known constant, return it, else return nullopt. */ -extern gdb::optional get_discrete_high_bound (struct type *type); +extern std::optional get_discrete_high_bound (struct type *type); /* Assuming TYPE is a simple, non-empty array type, compute its upper and lower bound. Save the low bound into LOW_BOUND if not NULL. @@ -2679,7 +2679,7 @@ extern gdb::optional get_discrete_high_bound (struct type *type); extern bool get_array_bounds (struct type *type, LONGEST *low_bound, LONGEST *high_bound); -extern gdb::optional discrete_position (struct type *type, +extern std::optional discrete_position (struct type *type, LONGEST val); extern int class_types_same_p (const struct type *, const struct type *); diff --git a/gdb/guile/scm-ports.c b/gdb/guile/scm-ports.c index a27ea8b3c80..ceca60b37e5 100644 --- a/gdb/guile/scm-ports.c +++ b/gdb/guile/scm-ports.c @@ -26,7 +26,7 @@ #include "ui.h" #include "target.h" #include "guile-internal.h" -#include "gdbsupport/gdb_optional.h" +#include #ifdef HAVE_POLL #if defined (HAVE_POLL_H) @@ -602,7 +602,7 @@ ioscm_with_output_to_port_worker (SCM port, SCM thunk, enum oport oport, ? &gdb_stderr : &gdb_stdout); { - gdb::optional redirect_popper; + std::optional redirect_popper; if (oport == GDB_STDERR) gdb_stderr = port_file.get (); else diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c index cdd5553cf5d..6d537c4c8d3 100644 --- a/gdb/ia64-tdep.c +++ b/gdb/ia64-tdep.c @@ -69,7 +69,7 @@ struct ia64_table_entry }; static struct ia64_table_entry *ktab = NULL; -static gdb::optional ktab_buf; +static std::optional ktab_buf; #endif @@ -2648,7 +2648,7 @@ ia64_access_mem (unw_addr_space_t as, } /* Call low-level function to access the kernel unwind table. */ -static gdb::optional +static std::optional getunwind_table () { /* FIXME drow/2005-09-10: This code used to call diff --git a/gdb/inf-child.c b/gdb/inf-child.c index 25afdb2202e..4eeb68be8f0 100644 --- a/gdb/inf-child.c +++ b/gdb/inf-child.c @@ -352,7 +352,7 @@ inf_child_target::fileio_unlink (struct inferior *inf, const char *filename, /* Implementation of to_fileio_readlink. */ -gdb::optional +std::optional inf_child_target::fileio_readlink (struct inferior *inf, const char *filename, fileio_error *target_errno) { diff --git a/gdb/inf-child.h b/gdb/inf-child.h index 017e8e35680..4aeb3898028 100644 --- a/gdb/inf-child.h +++ b/gdb/inf-child.h @@ -85,7 +85,7 @@ class inf_child_target int fileio_unlink (struct inferior *inf, const char *filename, fileio_error *target_errno) override; - gdb::optional fileio_readlink (struct inferior *inf, + std::optional fileio_readlink (struct inferior *inf, const char *filename, fileio_error *target_errno) override; bool use_agent (bool use) override; diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 2fc0eb138a6..ec818bc6936 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -52,7 +52,7 @@ #include "ui.h" #include "interps.h" #include "skip.h" -#include "gdbsupport/gdb_optional.h" +#include #include "source.h" #include "cli/cli-style.h" #include "dwarf2/loc.h" @@ -2790,7 +2790,7 @@ notice_new_inferior (thread_info *thr, bool leave_running, int from_tty) enum attach_post_wait_mode mode = leave_running ? ATTACH_POST_WAIT_RESUME : ATTACH_POST_WAIT_NOTHING; - gdb::optional restore_thread; + std::optional restore_thread; if (inferior_ptid != null_ptid) restore_thread.emplace (); diff --git a/gdb/inferior.c b/gdb/inferior.c index 927c5f16ae2..fbe27c8b873 100644 --- a/gdb/inferior.c +++ b/gdb/inferior.c @@ -728,10 +728,10 @@ switch_to_inferior_no_thread (inferior *inf) /* See regcache.h. */ -gdb::optional +std::optional maybe_switch_inferior (inferior *inf) { - gdb::optional maybe_restore_thread; + std::optional maybe_restore_thread; if (inf != current_inferior ()) { maybe_restore_thread.emplace (); diff --git a/gdb/inferior.h b/gdb/inferior.h index 33eff7a9141..f8f9395aec4 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -340,7 +340,7 @@ extern void switch_to_inferior_no_thread (inferior *inf); If the current inferior was changed, return an RAII object that will restore the original current context. */ -extern gdb::optional maybe_switch_inferior +extern std::optional maybe_switch_inferior (inferior *inf); /* Info about an inferior's target description. There's one of these diff --git a/gdb/inflow.c b/gdb/inflow.c index 095c5f03672..749f620739d 100644 --- a/gdb/inflow.c +++ b/gdb/inflow.c @@ -113,9 +113,9 @@ static struct terminal_info *get_inflow_inferior_data (struct inferior *); we save our handlers in these two variables and set SIGINT and SIGQUIT to SIG_IGN. */ -static gdb::optional sigint_ours; +static std::optional sigint_ours; #ifdef SIGQUIT -static gdb::optional sigquit_ours; +static std::optional sigquit_ours; #endif /* The name of the tty (from the `tty' command) that we're giving to diff --git a/gdb/infrun.c b/gdb/infrun.c index 70c33a9c392..a1543ab2443 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -62,7 +62,7 @@ #include "thread-fsm.h" #include "gdbsupport/enum-flags.h" #include "progspace-and-thread.h" -#include "gdbsupport/gdb_optional.h" +#include #include "arch-utils.h" #include "gdbsupport/scope-exit.h" #include "gdbsupport/forward-scope-exit.h" @@ -713,7 +713,7 @@ holding the child stopped. Try \"set detach-on-fork\" or \ { /* If FOLLOW_CHILD, we leave CHILD_INF as the current inferior (do not restore the parent as the current inferior). */ - gdb::optional maybe_restore; + std::optional maybe_restore; if (!follow_child && !sched_multi) maybe_restore.emplace (); @@ -4587,7 +4587,7 @@ fetch_inferior_event () debugging. If we're looking at traceframes while the target is running, we're going to need to get back to that mode after handling the event. */ - gdb::optional maybe_restore_traceframe; + std::optional maybe_restore_traceframe; if (non_stop) { maybe_restore_traceframe.emplace (); @@ -4960,7 +4960,7 @@ adjust_pc_after_break (struct thread_info *thread, || (target_is_non_stop_p () && moribund_breakpoint_here_p (aspace, breakpoint_pc))) { - gdb::optional> restore_operation_disable; + std::optional> restore_operation_disable; if (record_full_is_used ()) restore_operation_disable.emplace @@ -7109,7 +7109,7 @@ handle_signal_stop (struct execution_control_state *ecs) decr_pc = gdbarch_decr_pc_after_break (gdbarch); if (decr_pc != 0) { - gdb::optional> + std::optional> restore_operation_disable; if (record_full_is_used ()) @@ -9343,7 +9343,7 @@ normal_stop () && last.kind () != TARGET_WAITKIND_THREAD_EXITED) finish_ptid = inferior_ptid; - gdb::optional maybe_finish_thread_state; + std::optional maybe_finish_thread_state; if (finish_ptid != null_ptid) { maybe_finish_thread_state.emplace diff --git a/gdb/interps.c b/gdb/interps.c index 2fbf92fa0a2..bec2c85e2fd 100644 --- a/gdb/interps.c +++ b/gdb/interps.c @@ -430,7 +430,7 @@ interps_notify_new_thread (thread_info *t) void interps_notify_thread_exited (thread_info *t, - gdb::optional exit_code, + std::optional exit_code, int silent) { interps_notify (&interp::on_thread_exited, t, exit_code, silent); diff --git a/gdb/interps.h b/gdb/interps.h index 728155ae81b..f662f54e950 100644 --- a/gdb/interps.h +++ b/gdb/interps.h @@ -123,7 +123,7 @@ class interp : public intrusive_list_node /* Notify the interpreter that thread T has exited. */ virtual void on_thread_exited (thread_info *, - gdb::optional exit_code, + std::optional exit_code, int silent) {} /* Notify the interpreter that inferior INF was added. */ @@ -292,7 +292,7 @@ extern void interps_notify_new_thread (thread_info *t); /* Notify all interpreters that thread T has exited. */ extern void interps_notify_thread_exited (thread_info *t, - gdb::optional exit_code, + std::optional exit_code, int silent); /* Notify all interpreters that inferior INF was added. */ diff --git a/gdb/jit.c b/gdb/jit.c index 9e8325ab803..0e3a4285bdd 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -76,7 +76,7 @@ maint_info_jit_cmd (const char *args, int from_tty) inferior *inf = current_inferior (); bool printed_header = false; - gdb::optional table_emitter; + std::optional table_emitter; /* Print a line for each JIT-ed objfile. */ for (objfile *obj : inf->pspace->objfiles ()) diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index d3e9560c2fc..7b0562cf89b 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -1295,7 +1295,7 @@ get_detach_signal (struct lwp_info *lp) /* If LP has a pending fork/vfork/clone status, return it. */ -static gdb::optional +static std::optional get_pending_child_status (lwp_info *lp) { LINUX_NAT_SCOPED_DEBUG_ENTER_EXIT; @@ -1369,7 +1369,7 @@ detach_one_lwp (struct lwp_info *lp, int *signo_p) event, there is a process/thread GDB is attached to that the core of GDB doesn't know about. Detach from it. */ - gdb::optional ws = get_pending_child_status (lp); + std::optional ws = get_pending_child_status (lp); if (ws.has_value ()) detach_one_pid (ws->child_ptid ().lwp (), 0); @@ -3616,7 +3616,7 @@ kill_wait_callback (struct lwp_info *lp) static int kill_unfollowed_child_callback (lwp_info *lp) { - gdb::optional ws = get_pending_child_status (lp); + std::optional ws = get_pending_child_status (lp); if (ws.has_value ()) { ptid_t child_ptid = ws->child_ptid (); @@ -4074,7 +4074,7 @@ linux_proc_xfer_memory_partial (int pid, gdb_byte *readbuf, static bool proc_mem_file_is_writable () { - static gdb::optional writable; + static std::optional writable; if (writable.has_value ()) return *writable; @@ -4463,7 +4463,7 @@ linux_nat_target::fileio_open (struct inferior *inf, const char *filename, /* Implementation of to_fileio_readlink. */ -gdb::optional +std::optional linux_nat_target::fileio_readlink (struct inferior *inf, const char *filename, fileio_error *target_errno) { diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h index cce8bb3ddcc..428bb9f1628 100644 --- a/gdb/linux-nat.h +++ b/gdb/linux-nat.h @@ -103,7 +103,7 @@ class linux_nat_target : public inf_ptrace_target int flags, int mode, int warn_if_slow, fileio_error *target_errno) override; - gdb::optional + std::optional fileio_readlink (struct inferior *inf, const char *filename, fileio_error *target_errno) override; diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index eff7a0ca42e..db29b032018 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -38,7 +38,7 @@ #include "gdbcmd.h" #include "gdbsupport/gdb_regex.h" #include "gdbsupport/enum-flags.h" -#include "gdbsupport/gdb_optional.h" +#include #include "gcore.h" #include "gcore-elf.h" #include "solib-svr4.h" @@ -229,7 +229,7 @@ struct linux_info int vsyscall_range_p = 0; /* Inferior's displaced step buffers. */ - gdb::optional disp_step_bufs; + std::optional disp_step_bufs; }; /* Per-inferior data key. */ @@ -589,7 +589,7 @@ struct mapping_regexes static int mapping_is_anonymous_p (const char *filename) { - static gdb::optional regexes; + static std::optional regexes; static int init_regex_p = 0; if (!init_regex_p) @@ -873,7 +873,7 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args, if (cwd_f) { xsnprintf (filename, sizeof filename, "/proc/%ld/cwd", pid); - gdb::optional contents + std::optional contents = target_fileio_readlink (NULL, filename, &target_errno); if (contents.has_value ()) gdb_printf ("cwd = '%s'\n", contents->c_str ()); @@ -883,7 +883,7 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args, if (exe_f) { xsnprintf (filename, sizeof filename, "/proc/%ld/exe", pid); - gdb::optional contents + std::optional contents = target_fileio_readlink (NULL, filename, &target_errno); if (contents.has_value ()) gdb_printf ("exe = '%s'\n", contents->c_str ()); @@ -2108,7 +2108,7 @@ linux_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size) return NULL; /* Auxillary vector. */ - gdb::optional auxv = + std::optional auxv = target_read_alloc (current_inferior ()->top_target (), TARGET_OBJECT_AUXV, NULL); if (auxv && !auxv->empty ()) @@ -2675,7 +2675,7 @@ linux_displaced_step_restore_all_in_ptid (inferior *parent_inf, ptid_t ptid) /* Helper for linux_get_hwcap and linux_get_hwcap2. */ static CORE_ADDR -linux_get_hwcap_helper (const gdb::optional &auxv, +linux_get_hwcap_helper (const std::optional &auxv, target_ops *target, gdbarch *gdbarch, CORE_ADDR match) { CORE_ADDR field; @@ -2688,7 +2688,7 @@ linux_get_hwcap_helper (const gdb::optional &auxv, /* See linux-tdep.h. */ CORE_ADDR -linux_get_hwcap (const gdb::optional &auxv, +linux_get_hwcap (const std::optional &auxv, target_ops *target, gdbarch *gdbarch) { return linux_get_hwcap_helper (auxv, target, gdbarch, AT_HWCAP); @@ -2707,7 +2707,7 @@ linux_get_hwcap () /* See linux-tdep.h. */ CORE_ADDR -linux_get_hwcap2 (const gdb::optional &auxv, +linux_get_hwcap2 (const std::optional &auxv, target_ops *target, gdbarch *gdbarch) { return linux_get_hwcap_helper (auxv, target, gdbarch, AT_HWCAP2); diff --git a/gdb/linux-tdep.h b/gdb/linux-tdep.h index e09a6ef32b1..819b221e599 100644 --- a/gdb/linux-tdep.h +++ b/gdb/linux-tdep.h @@ -94,7 +94,7 @@ extern int linux_is_uclinux (void); parse auxv entries. On error, 0 is returned. */ -extern CORE_ADDR linux_get_hwcap (const gdb::optional &auxv, +extern CORE_ADDR linux_get_hwcap (const std::optional &auxv, struct target_ops *target, gdbarch *gdbarch); /* Same as the above, but obtain all the inputs from the current inferior. */ @@ -105,7 +105,7 @@ extern CORE_ADDR linux_get_hwcap (); parse auxv entries. On error, 0 is returned. */ -extern CORE_ADDR linux_get_hwcap2 (const gdb::optional &auxv, +extern CORE_ADDR linux_get_hwcap2 (const std::optional &auxv, struct target_ops *target, gdbarch *gdbarch); /* Same as the above, but obtain all the inputs from the current inferior. */ diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index cef78f599be..c2ec422b7f3 100644 --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -312,7 +312,7 @@ struct thread_db_thread_info : public private_thread_info /* Cached thread state. */ td_thrhandle_t th {}; thread_t tid {}; - gdb::optional thread_handle; + std::optional thread_handle; }; static thread_db_thread_info * diff --git a/gdb/main.c b/gdb/main.c index 2da39f89a90..486c1ffe071 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -361,7 +361,7 @@ get_init_files (std::vector *system_gdbinit, { /* Cache the file lookup object so we only actually search for the files once. */ - static gdb::optional init_files; + static std::optional init_files; if (!init_files.has_value ()) init_files.emplace (GDBINIT, SYSTEM_GDBINIT, SYSTEM_GDBINIT_RELOCATABLE, SYSTEM_GDBINIT_DIR, SYSTEM_GDBINIT_DIR_RELOCATABLE, @@ -381,7 +381,7 @@ get_earlyinit_files (std::string *home_gdbearlyinit) { /* Cache the file lookup object so we only actually search for the files once. */ - static gdb::optional init_files; + static std::optional init_files; if (!init_files.has_value ()) init_files.emplace (GDBEARLYINIT, nullptr, false, nullptr, false, false); diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index e473be7d465..6982338751a 100644 --- a/gdb/mi/mi-cmd-stack.c +++ b/gdb/mi/mi-cmd-stack.c @@ -34,7 +34,7 @@ #include "extension.h" #include #include "mi-parse.h" -#include "gdbsupport/gdb_optional.h" +#include #include "gdbsupport/gdb-safe-ctype.h" #include "inferior.h" #include "observable.h" @@ -515,7 +515,7 @@ list_arg_or_local (const struct frame_arg *arg, enum what_to_list what, arg->val->type ()->length ())))) return; - gdb::optional tuple_emitter; + std::optional tuple_emitter; if (values != PRINT_NO_VALUES || what == all) tuple_emitter.emplace (uiout, nullptr); diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c index 8b4dd6d0c96..87c54c8c95d 100644 --- a/gdb/mi/mi-cmd-var.c +++ b/gdb/mi/mi-cmd-var.c @@ -30,7 +30,7 @@ #include "mi-getopt.h" #include "gdbthread.h" #include "mi-parse.h" -#include "gdbsupport/gdb_optional.h" +#include #include "inferior.h" static void varobj_update_one (struct varobj *var, diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c index 5ea31fc98d1..dbee2d010ea 100644 --- a/gdb/mi/mi-cmds.c +++ b/gdb/mi/mi-cmds.c @@ -183,7 +183,7 @@ mi_command::mi_command (const char *name, int *suppress_notification) /* See mi-cmds.h. */ -gdb::optional> +std::optional> mi_command::do_suppress_notification () const { if (m_suppress_notification != nullptr) diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h index e67c486a997..f99c24313b9 100644 --- a/gdb/mi/mi-cmds.h +++ b/gdb/mi/mi-cmds.h @@ -23,7 +23,7 @@ #define MI_MI_CMDS_H #include "gdbsupport/function-view.h" -#include "gdbsupport/gdb_optional.h" +#include #include "mi/mi-main.h" enum print_values { @@ -180,12 +180,12 @@ struct mi_command /* If this command was created with a suppress notifications pointer, then this function will set the suppress flag and return a - gdb::optional with its value set to an object that will restore the + std::optional with its value set to an object that will restore the previous value of the suppress notifications flag. If this command was created without a suppress notifications points, - then this function returns an empty gdb::optional. */ - gdb::optional> do_suppress_notification () const; + then this function returns an empty std::optional. */ + std::optional> do_suppress_notification () const; private: diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index ebd7f150c49..afd2737e29d 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -278,7 +278,7 @@ mi_interp::on_new_thread (thread_info *t) void mi_interp::on_thread_exited (thread_info *t, - gdb::optional /* exit_code */, + std::optional /* exit_code */, int /* silent */) { target_terminal::scoped_restore_terminal_state term_state; diff --git a/gdb/mi/mi-interp.h b/gdb/mi/mi-interp.h index 3110c0a6a48..25c25512fba 100644 --- a/gdb/mi/mi-interp.h +++ b/gdb/mi/mi-interp.h @@ -51,7 +51,7 @@ class mi_interp final : public interp void on_command_error () override; void on_user_selected_context_changed (user_selected_what selection) override; void on_new_thread (thread_info *t) override; - void on_thread_exited (thread_info *t, gdb::optional exit_code, + void on_thread_exited (thread_info *t, std::optional exit_code, int silent) override; void on_inferior_added (inferior *inf) override; void on_inferior_appeared (inferior *inf) override; diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 14ed2a1fae9..487b0a92025 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -52,7 +52,7 @@ #include "extension.h" #include "gdbcmd.h" #include "observable.h" -#include "gdbsupport/gdb_optional.h" +#include #include "gdbsupport/byte-vector.h" #include @@ -2095,7 +2095,7 @@ mi_cmd_execute (struct mi_parse *parse) user_selected_context current_user_selected_context; - gdb::optional thread_saver; + std::optional thread_saver; if (parse->thread != -1) { thread_info *tp = find_thread_global_id (parse->thread); @@ -2112,7 +2112,7 @@ mi_cmd_execute (struct mi_parse *parse) switch_to_thread (tp); } - gdb::optional frame_saver; + std::optional frame_saver; if (parse->frame != -1) { frame_info_ptr fid; @@ -2130,7 +2130,7 @@ mi_cmd_execute (struct mi_parse *parse) error (_("Invalid frame id: %d"), frame); } - gdb::optional lang_saver; + std::optional lang_saver; if (parse->language != language_unknown) { lang_saver.emplace (); @@ -2141,7 +2141,7 @@ mi_cmd_execute (struct mi_parse *parse) gdb_assert (parse->cmd != nullptr); - gdb::optional> restore_suppress_notification + std::optional> restore_suppress_notification = parse->cmd->do_suppress_notification (); parse->cmd->invoke (parse); @@ -2512,7 +2512,7 @@ print_variable_or_computed (const char *expression, enum print_values values) else val = expr->evaluate (); - gdb::optional tuple_emitter; + std::optional tuple_emitter; if (values != PRINT_NO_VALUES) tuple_emitter.emplace (uiout, nullptr); uiout->field_string ("name", expression); diff --git a/gdb/nat/linux-osdata.c b/gdb/nat/linux-osdata.c index 103b7ab26cd..e85384660d4 100644 --- a/gdb/nat/linux-osdata.c +++ b/gdb/nat/linux-osdata.c @@ -66,7 +66,7 @@ linux_common_core_of_thread (ptid_t ptid) sprintf (filename, "/proc/%lld/task/%lld/stat", (PID_T) ptid.pid (), (PID_T) ptid.lwp ()); - gdb::optional content = read_text_file_to_string (filename); + std::optional content = read_text_file_to_string (filename); if (!content.has_value ()) return -1; @@ -257,10 +257,10 @@ get_cores_used_by_process (PID_T pid, int *cores, const int num_cores) /* get_core_array_size helper that uses /sys/devices/system/cpu/possible. */ -static gdb::optional +static std::optional get_core_array_size_using_sys_possible () { - gdb::optional possible + std::optional possible = read_text_file_to_string ("/sys/devices/system/cpu/possible"); if (!possible.has_value ()) @@ -310,7 +310,7 @@ get_core_array_size () we are in a container that has access to a subset of the host's cores. It will return a size that considers all the CPU cores available to the host. If that fails for some reason, fall back to sysconf. */ - gdb::optional count = get_core_array_size_using_sys_possible (); + std::optional count = get_core_array_size_using_sys_possible (); if (count.has_value ()) return *count; diff --git a/gdb/nat/windows-nat.c b/gdb/nat/windows-nat.c index 8028494de20..bf4c4387886 100644 --- a/gdb/nat/windows-nat.c +++ b/gdb/nat/windows-nat.c @@ -698,10 +698,10 @@ windows_process_info::matching_pending_stop (bool debug_events) /* See nat/windows-nat.h. */ -gdb::optional +std::optional windows_process_info::fetch_pending_stop (bool debug_events) { - gdb::optional result; + std::optional result; for (auto iter = pending_stops.begin (); iter != pending_stops.end (); ++iter) @@ -818,7 +818,7 @@ create_process_wrapper (FUNC *do_create_process, const CHAR *image, InitializeProcThreadAttributeList (info_ex.lpAttributeList, 1, 0, &size); - gdb::optional return_value; + std::optional return_value; DWORD attr_flags = relocate_aslr_flags; if (!UpdateProcThreadAttribute (info_ex.lpAttributeList, 0, mitigation_policy, diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h index e3ea7dbb525..0dc37b29705 100644 --- a/gdb/nat/windows-nat.h +++ b/gdb/nat/windows-nat.h @@ -23,7 +23,7 @@ #include #include -#include "gdbsupport/gdb_optional.h" +#include #include "target/waitstatus.h" #define STATUS_WX86_BREAKPOINT 0x4000001F @@ -246,7 +246,7 @@ struct windows_process_info remove it from the list of pending stops, set 'current_event', and return it. Otherwise, return an empty optional. */ - gdb::optional fetch_pending_stop (bool debug_events); + std::optional fetch_pending_stop (bool debug_events); const char *pid_to_exec_file (int); diff --git a/gdb/observable.h b/gdb/observable.h index 5869489bcff..32ef65435cc 100644 --- a/gdb/observable.h +++ b/gdb/observable.h @@ -123,7 +123,7 @@ extern observable new_thread; removing the thread from its tables without wanting to notify the CLI about it. */ extern observable /* exit_code */, + std::optional /* exit_code */, bool /* silent */> thread_exit; /* An explicit stop request was issued to PTID. If PTID equals diff --git a/gdb/osdata.c b/gdb/osdata.c index 21b8eb01f6b..cb1e950df5c 100644 --- a/gdb/osdata.c +++ b/gdb/osdata.c @@ -162,7 +162,7 @@ std::unique_ptr get_osdata (const char *type) { std::unique_ptr osdata; - gdb::optional xml = target_get_osdata (type); + std::optional xml = target_get_osdata (type); if (xml) { diff --git a/gdb/parse.c b/gdb/parse.c index c69b53addff..b57d112fafd 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -49,7 +49,7 @@ #include "objfiles.h" #include "user-regs.h" #include -#include "gdbsupport/gdb_optional.h" +#include #include "c-exp.h" static unsigned int expressiondebug = 0; @@ -471,7 +471,7 @@ parse_expression (const char *string, innermost_block_tracker *tracker, expression_up parse_expression_with_language (const char *string, enum language lang) { - gdb::optional lang_saver; + std::optional lang_saver; if (current_language->la_language != lang) { lang_saver.emplace (); diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c index a0205119f00..f34de9cb666 100644 --- a/gdb/ppc-linux-nat.c +++ b/gdb/ppc-linux-nat.c @@ -464,7 +464,7 @@ class ppc_linux_dreg_interface }; /* The interface option. Initialized if has_value () returns true. */ - gdb::optional m_interface; + std::optional m_interface; /* The info returned by the kernel with PPC_PTRACE_GETHWDBGINFO. Only valid if we determined that the interface is HWDEBUG. */ @@ -485,7 +485,7 @@ struct ppc_linux_process_info /* The watchpoint value that GDB requested for this process. Only used when the interface is DEBUGREG. */ - gdb::optional requested_wp_val; + std::optional requested_wp_val; }; struct ppc_linux_nat_target final : public linux_nat_target diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c index 1cc26ed69a5..24e1b455afd 100644 --- a/gdb/ppc-linux-tdep.c +++ b/gdb/ppc-linux-tdep.c @@ -1611,7 +1611,7 @@ ppc_linux_core_read_description (struct gdbarch *gdbarch, if (vsx) features.vsx = true; - gdb::optional auxv = target_read_auxv_raw (target); + std::optional auxv = target_read_auxv_raw (target); CORE_ADDR hwcap = linux_get_hwcap (auxv, target, gdbarch); features.isa205 = ppc_linux_has_isa205 (hwcap); diff --git a/gdb/ppc-tdep.h b/gdb/ppc-tdep.h index ddeb810f35b..b24154998ec 100644 --- a/gdb/ppc-tdep.h +++ b/gdb/ppc-tdep.h @@ -447,7 +447,7 @@ struct ppc_inferior_data /* This is an optional in case we add more fields to ppc_inferior_data, we don't want it instantiated as soon as we get the ppc_inferior_data for an inferior. */ - gdb::optional disp_step_buf; + std::optional disp_step_buf; }; extern ppc_inferior_data * get_ppc_per_inferior (inferior *inf); diff --git a/gdb/printcmd.c b/gdb/printcmd.c index c5e6a815580..98f38b2598d 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -52,7 +52,7 @@ #include "gdbsupport/format.h" #include "source.h" #include "gdbsupport/byte-vector.h" -#include "gdbsupport/gdb_optional.h" +#include #include "gdbsupport/gdb-safe-ctype.h" #include "gdbsupport/rsp-low.h" #include "inferior.h" @@ -435,7 +435,7 @@ print_scalar_formatted (const gdb_byte *valaddr, struct type *type, /* Some cases below will unpack the value again. In the biased range case, we want to avoid this, so we store the unpacked value here for possible use later. */ - gdb::optional val_long; + std::optional val_long; if ((is_fixed_point_type (type) && (options->format == 'o' || options->format == 'x' @@ -2452,7 +2452,7 @@ printf_wide_c_string (struct ui_file *stream, const char *format, struct type *wctype = lookup_typename (current_language, "wchar_t", NULL, 0); int wcwidth = wctype->length (); - gdb::optional tem_str; + std::optional tem_str; if (value->lval () == lval_internalvar && c_is_string_type_p (value->type ())) diff --git a/gdb/probe.c b/gdb/probe.c index 13e95bcfb20..d9079be4d62 100644 --- a/gdb/probe.c +++ b/gdb/probe.c @@ -36,7 +36,7 @@ #include "location.h" #include #include -#include "gdbsupport/gdb_optional.h" +#include /* Class that implements the static probe methods for "any" probe. */ @@ -280,7 +280,7 @@ collect_probes (const std::string &objname, const std::string &provider, const std::string &probe_name, const static_probe_ops *spops) { std::vector result; - gdb::optional obj_pat, prov_pat, probe_pat; + std::optional obj_pat, prov_pat, probe_pat; if (!provider.empty ()) prov_pat.emplace (provider.c_str (), REG_NOSUB, @@ -683,9 +683,9 @@ disable_probes_command (const char *arg, int from_tty) static bool ignore_probes_p = false; static bool ignore_probes_idx = 0; static bool ignore_probes_verbose_p; -static gdb::optional ignore_probes_prov_pat[2]; -static gdb::optional ignore_probes_name_pat[2]; -static gdb::optional ignore_probes_obj_pat[2]; +static std::optional ignore_probes_prov_pat[2]; +static std::optional ignore_probes_name_pat[2]; +static std::optional ignore_probes_obj_pat[2]; /* See comments in probe.h. */ @@ -696,11 +696,11 @@ ignore_probe_p (const char *provider, const char *name, if (!ignore_probes_p) return false; - gdb::optional &re_prov + std::optional &re_prov = ignore_probes_prov_pat[ignore_probes_idx]; - gdb::optional &re_name + std::optional &re_name = ignore_probes_name_pat[ignore_probes_idx]; - gdb::optional &re_obj + std::optional &re_obj = ignore_probes_obj_pat[ignore_probes_idx]; bool res @@ -755,11 +755,11 @@ ignore_probes_command (const char *arg, int from_tty) /* Parse the regular expressions, making sure that the old regular expressions are still valid if an exception is throw. */ int new_ignore_probes_idx = 1 - ignore_probes_idx; - gdb::optional &re_prov + std::optional &re_prov = ignore_probes_prov_pat[new_ignore_probes_idx]; - gdb::optional &re_name + std::optional &re_name = ignore_probes_name_pat[new_ignore_probes_idx]; - gdb::optional &re_obj + std::optional &re_obj = ignore_probes_obj_pat[new_ignore_probes_idx]; re_prov.reset (); re_name.reset (); diff --git a/gdb/procfs.c b/gdb/procfs.c index 3a5d173ee42..1a543a60202 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -3615,7 +3615,7 @@ procfs_target::make_corefile_notes (bfd *obfd, int *note_size) proc_iterate_over_threads (pi, procfs_corefile_thread_callback, &thread_args); - gdb::optional auxv = + std::optional auxv = target_read_alloc (current_inferior ()->top_target (), TARGET_OBJECT_AUXV, NULL); if (auxv && !auxv->empty ()) diff --git a/gdb/psymtab.c b/gdb/psymtab.c index 41ecf31424b..484d4eaa651 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -1025,7 +1025,7 @@ psymbol_functions::expand_symtabs_matching for (partial_symtab *ps : partial_symbols (objfile)) ps->searched_flag = PST_NOT_SEARCHED; - gdb::optional psym_lookup_name; + std::optional psym_lookup_name; if (lookup_name != nullptr) psym_lookup_name = lookup_name->make_ignore_params (); diff --git a/gdb/psymtab.h b/gdb/psymtab.h index 41337d0db89..4bafc6e998e 100644 --- a/gdb/psymtab.h +++ b/gdb/psymtab.h @@ -131,7 +131,7 @@ class psymtab_storage /* The obstack where allocations are made. This is lazily allocated so that we don't waste memory when there are no psymtabs. */ - gdb::optional m_obstack; + std::optional m_obstack; }; /* A partial_symbol records the name, domain, and address class of diff --git a/gdb/python/py-disasm.c b/gdb/python/py-disasm.c index 6f0fed137e6..7a13b81a0c2 100644 --- a/gdb/python/py-disasm.c +++ b/gdb/python/py-disasm.c @@ -176,7 +176,7 @@ struct gdbpy_disassembler : public gdb_disassemble_info /* Return a reference to an optional that contains the address at which a memory error occurred. The optional will only have a value if a memory error actually occurred. */ - const gdb::optional &memory_error_address () const + const std::optional &memory_error_address () const { return m_memory_error_address; } /* Return the content of the disassembler as a string. The contents are @@ -221,7 +221,7 @@ struct gdbpy_disassembler : public gdb_disassemble_info /* When the user indicates that a memory error has occurred then the address of the memory error is stored in here. */ - gdb::optional m_memory_error_address; + std::optional m_memory_error_address; /* When the user calls the builtin_disassemble function, if they pass a memory source object then a pointer to the object is placed in here, @@ -245,7 +245,7 @@ struct gdbpy_disassembler : public gdb_disassemble_info /* Store a single exception. This is used to pass Python exceptions back from ::memory_read to disasmpy_builtin_disassemble. */ - gdb::optional m_stored_exception; + std::optional m_stored_exception; }; /* Return true if OBJ is still valid, otherwise, return false. A valid OBJ @@ -1215,7 +1215,7 @@ struct scoped_disasm_info_object /* See python-internal.h. */ -gdb::optional +std::optional gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr, disassemble_info *info) { @@ -1294,7 +1294,7 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr, addr = disasm_info->address; info->memory_error_func (-1, addr, info); - return gdb::optional (-1); + return std::optional (-1); } else if (PyErr_ExceptionMatches (gdbpy_gdberror_exc)) { @@ -1302,12 +1302,12 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr, gdb::unique_xmalloc_ptr msg = err.to_string (); info->fprintf_func (info->stream, "%s", msg.get ()); - return gdb::optional (-1); + return std::optional (-1); } else { gdbpy_print_stack (); - return gdb::optional (-1); + return std::optional (-1); } } @@ -1326,7 +1326,7 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr, PyErr_SetString (PyExc_TypeError, _("Result is not a DisassemblerResult.")); gdbpy_print_stack (); - return gdb::optional (-1); + return std::optional (-1); } /* The result from the Python disassembler has the correct type. Convert @@ -1345,7 +1345,7 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr, (PyExc_ValueError, _("Invalid length attribute: length must be greater than 0.")); gdbpy_print_stack (); - return gdb::optional (-1); + return std::optional (-1); } if (length > max_insn_length) { @@ -1354,7 +1354,7 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr, _("Invalid length attribute: length %d greater than architecture maximum of %d"), length, max_insn_length); gdbpy_print_stack (); - return gdb::optional (-1); + return std::optional (-1); } /* It is impossible to create a DisassemblerResult object with an empty @@ -1390,7 +1390,7 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr, } } - return gdb::optional (length); + return std::optional (length); } /* The tp_dealloc callback for the DisassemblerResult type. Takes care of diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c index e555dc3d879..dc7e47d70f0 100644 --- a/gdb/python/py-framefilter.c +++ b/gdb/python/py-framefilter.c @@ -32,7 +32,7 @@ #include "demangle.h" #include "mi/mi-cmds.h" #include "python-internal.h" -#include "gdbsupport/gdb_optional.h" +#include #include "cli/cli-style.h" enum mi_print_types @@ -322,7 +322,7 @@ py_print_single_arg (struct ui_out *out, else val = fv; - gdb::optional maybe_tuple; + std::optional maybe_tuple; /* MI has varying rules for tuples, but generally if there is only one element in each item in the list, do not start a tuple. The @@ -562,7 +562,7 @@ enumerate_locals (PyObject *iter, struct symbol *sym; const struct block *sym_block; int local_indent = 8 + (8 * indent); - gdb::optional tuple; + std::optional tuple; gdbpy_ref<> item (PyIter_Next (iter)); if (item == NULL) @@ -773,7 +773,7 @@ py_print_frame (PyObject *filter, frame_filter_flags flags, get_user_print_options (&opts); if (print_frame_info) { - gdb::optional user_frame_info_print_what; + std::optional user_frame_info_print_what; get_user_print_what_frame_info (&user_frame_info_print_what); if (!out->is_mi_like_p () && user_frame_info_print_what.has_value ()) @@ -808,7 +808,7 @@ py_print_frame (PyObject *filter, frame_filter_flags flags, return EXT_LANG_BT_OK; } - gdb::optional tuple; + std::optional tuple; /* -stack-list-locals does not require a wrapping frame attribute. */ diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c index c0bd6a69895..ed153d668ac 100644 --- a/gdb/python/py-inferior.c +++ b/gdb/python/py-inferior.c @@ -364,7 +364,7 @@ add_thread_object (struct thread_info *tp) static void delete_thread_object (thread_info *tp, - gdb::optional /* exit_code */, + std::optional /* exit_code */, bool /* silent */) { if (!gdb_python_initialized) diff --git a/gdb/python/py-mi.c b/gdb/python/py-mi.c index aaa225da95e..d38a0ff1724 100644 --- a/gdb/python/py-mi.c +++ b/gdb/python/py-mi.c @@ -145,7 +145,7 @@ class py_ui_out : public ui_out /* If an error occurred, this holds the exception information for use by the 'release' method. */ - gdb::optional m_error; + std::optional m_error; /* Return a reference to the object under construction. */ object_desc ¤t () diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c index 15520849f15..f1ca9ea0a5d 100644 --- a/gdb/python/py-utils.c +++ b/gdb/python/py-utils.c @@ -469,12 +469,12 @@ gdbpy_fix_doc_string_indentation (gdb::unique_xmalloc_ptr doc) (user left a single stray space at the start of an otherwise blank line), we don't consider lines without content when updating the MIN_WHITESPACE value. */ - gdb::optional min_whitespace; + std::optional min_whitespace; /* The index into WS_INFO at which the processing of DOC can be considered "all done", that is, after this point there are no further lines with useful content and we should just stop. */ - gdb::optional all_done_idx; + std::optional all_done_idx; /* White-space information for each line in DOC. */ std::vector ws_info; diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index 847bed84dfe..86eb5436f2a 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -732,7 +732,7 @@ class gdbpy_enter /* An optional is used here because we don't want to call PyErr_Fetch too early. */ - gdb::optional m_error; + std::optional m_error; }; /* Like gdbpy_enter, but takes a varobj. This is a subclass just to @@ -953,7 +953,7 @@ extern gdb::unique_xmalloc_ptr gdbpy_fix_doc_string_indentation If no instruction can be disassembled then return an empty value. */ -extern gdb::optional gdbpy_print_insn (struct gdbarch *gdbarch, +extern std::optional gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR address, disassemble_info *info); diff --git a/gdb/python/python.c b/gdb/python/python.c index 7e48165db21..8a36673a3e4 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -124,9 +124,9 @@ static void gdbpy_set_quit_flag (const struct extension_language_defn *); static int gdbpy_check_quit_flag (const struct extension_language_defn *); static enum ext_lang_rc gdbpy_before_prompt_hook (const struct extension_language_defn *, const char *current_gdb_prompt); -static gdb::optional gdbpy_colorize +static std::optional gdbpy_colorize (const std::string &filename, const std::string &contents); -static gdb::optional gdbpy_colorize_disasm +static std::optional gdbpy_colorize_disasm (const std::string &content, gdbarch *gdbarch); static ext_lang_missing_debuginfo_result gdbpy_handle_missing_debuginfo (const struct extension_language_defn *extlang, struct objfile *objfile); @@ -1198,7 +1198,7 @@ gdbpy_before_prompt_hook (const struct extension_language_defn *extlang, /* This is the extension_language_ops.colorize "method". */ -static gdb::optional +static std::optional gdbpy_colorize (const std::string &filename, const std::string &contents) { if (!gdb_python_initialized) @@ -1275,7 +1275,7 @@ gdbpy_colorize (const std::string &filename, const std::string &contents) /* This is the extension_language_ops.colorize_disasm "method". */ -static gdb::optional +static std::optional gdbpy_colorize_disasm (const std::string &content, gdbarch *gdbarch) { if (!gdb_python_initialized) diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c index 3558cfd3875..f147b66b3c6 100644 --- a/gdb/ravenscar-thread.c +++ b/gdb/ravenscar-thread.c @@ -685,7 +685,7 @@ ravenscar_thread_target::fetch_registers (struct regcache *regcache, struct gdbarch *gdbarch = regcache->arch (); bool is_active = task_is_currently_active (ptid); struct ravenscar_arch_ops *arch_ops = gdbarch_ravenscar_ops (gdbarch); - gdb::optional fp_state; + std::optional fp_state; int low_reg = regnum == -1 ? 0 : regnum; int high_reg = regnum == -1 ? gdbarch_num_regs (gdbarch) : regnum + 1; @@ -731,7 +731,7 @@ ravenscar_thread_target::store_registers (struct regcache *regcache, struct gdbarch *gdbarch = regcache->arch (); bool is_active = task_is_currently_active (ptid); struct ravenscar_arch_ops *arch_ops = gdbarch_ravenscar_ops (gdbarch); - gdb::optional fp_state; + std::optional fp_state; int low_reg = regnum == -1 ? 0 : regnum; int high_reg = regnum == -1 ? gdbarch_num_regs (gdbarch) : regnum + 1; diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index f0e190f9bf7..e084196b841 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -758,8 +758,8 @@ btrace_find_line_range (CORE_ADDR pc) static void btrace_print_lines (struct btrace_line_range lines, struct ui_out *uiout, - gdb::optional *src_and_asm_tuple, - gdb::optional *asm_list, + std::optional *src_and_asm_tuple, + std::optional *asm_list, gdb_disassembly_flags flags) { print_source_lines_flags psl_flags; @@ -798,8 +798,8 @@ btrace_insn_history (struct ui_out *uiout, ui_out_emit_list list_emitter (uiout, "asm_insns"); - gdb::optional src_and_asm_tuple; - gdb::optional asm_list; + std::optional src_and_asm_tuple; + std::optional asm_list; gdb_pretty_print_disassembler disasm (gdbarch, uiout); diff --git a/gdb/regcache.c b/gdb/regcache.c index 48d7db47c06..9dc354ec2b3 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -578,7 +578,7 @@ regcache::raw_update (int regnum) if (get_register_status (regnum) == REG_UNKNOWN) { - gdb::optional maybe_restore_thread + std::optional maybe_restore_thread = maybe_switch_inferior (m_inf_for_target_calls); target_fetch_registers (this, regnum); @@ -832,7 +832,7 @@ regcache::raw_write (int regnum, const gdb_byte *buf) m_descr->sizeof_register[regnum]) == 0)) return; - gdb::optional maybe_restore_thread + std::optional maybe_restore_thread = maybe_switch_inferior (m_inf_for_target_calls); target_prepare_to_store (this); diff --git a/gdb/remote.c b/gdb/remote.c index 501270041d8..1bc59928dcf 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -930,7 +930,7 @@ class remote_target : public process_stratum_target const char *filename, fileio_error *target_errno) override; - gdb::optional + std::optional fileio_readlink (struct inferior *inf, const char *filename, fileio_error *target_errno) override; @@ -4091,7 +4091,7 @@ remote_target::remote_get_threads_with_qxfer (threads_listing_context *context) #if defined(HAVE_LIBEXPAT) if (m_features.packet_support (PACKET_qXfer_threads) == PACKET_ENABLE) { - gdb::optional xml + std::optional xml = target_read_stralloc (this, TARGET_OBJECT_THREADS, NULL); if (xml && (*xml)[0] != '\0') @@ -11913,7 +11913,7 @@ std::vector remote_target::memory_map () { std::vector result; - gdb::optional text + std::optional text = target_read_stralloc (current_inferior ()->top_target (), TARGET_OBJECT_MEMORY_MAP, NULL); @@ -12878,7 +12878,7 @@ remote_target::fileio_unlink (struct inferior *inf, const char *filename, /* Implementation of to_fileio_readlink. */ -gdb::optional +std::optional remote_target::fileio_readlink (struct inferior *inf, const char *filename, fileio_error *remote_errno) { @@ -14145,7 +14145,7 @@ remote_target::set_circular_trace_buffer (int val) traceframe_info_up remote_target::traceframe_info () { - gdb::optional text + std::optional text = target_read_stralloc (current_inferior ()->top_target (), TARGET_OBJECT_TRACEFRAME_INFO, NULL); @@ -14686,7 +14686,7 @@ btrace_read_config (thread_info *tp, btrace_config *conf) scoped_restore_current_thread restore_thread; switch_to_thread (tp); - gdb::optional xml + std::optional xml = target_read_stralloc (current_inferior ()->top_target (), TARGET_OBJECT_BTRACE_CONF, ""); if (xml) @@ -14886,7 +14886,7 @@ remote_target::read_btrace (struct btrace_data *btrace, (unsigned int) type); } - gdb::optional xml + std::optional xml = target_read_stralloc (current_inferior ()->top_target (), TARGET_OBJECT_BTRACE, annex); if (!xml) @@ -14926,7 +14926,7 @@ remote_target::load (const char *name, int from_tty) const char * remote_target::pid_to_exec_file (int pid) { - static gdb::optional filename; + static std::optional filename; char *annex = NULL; if (m_features.packet_support (PACKET_qXfer_exec_file) != PACKET_ENABLE) diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index 3a2891c2c92..3725be44276 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -1676,7 +1676,7 @@ class riscv_insn passed, is the value to place in rs1, otherwise rd is duplicated into rs1. */ void decode_ci_type_insn (enum opcode opcode, ULONGEST ival, - gdb::optional rs1_regnum = {}) + std::optional rs1_regnum = {}) { m_opcode = opcode; m_rd = decode_register_index (ival, OP_SH_CRS1S); diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c index 414238a4db2..ae45ec6b5df 100644 --- a/gdb/s390-linux-tdep.c +++ b/gdb/s390-linux-tdep.c @@ -332,7 +332,7 @@ s390_core_read_description (struct gdbarch *gdbarch, struct target_ops *target, bfd *abfd) { asection *section = bfd_get_section_by_name (abfd, ".reg"); - gdb::optional auxv = target_read_auxv_raw (target); + std::optional auxv = target_read_auxv_raw (target); CORE_ADDR hwcap = linux_get_hwcap (auxv, target, gdbarch); bool high_gprs, v1, v2, te, vx, gs; diff --git a/gdb/skip.c b/gdb/skip.c index 28902a6d326..465978ff9cc 100644 --- a/gdb/skip.c +++ b/gdb/skip.c @@ -34,7 +34,7 @@ #include "filenames.h" #include "fnmatch.h" #include "gdbsupport/gdb_regex.h" -#include "gdbsupport/gdb_optional.h" +#include #include #include "cli/cli-style.h" #include "gdbsupport/buildargv.h" @@ -113,7 +113,7 @@ class skiplist_entry std::string m_function; /* If this is a function regexp, the compiled form. */ - gdb::optional m_compiled_function_regexp; + std::optional m_compiled_function_regexp; /* Enabled/disabled state. */ bool m_enabled = true; diff --git a/gdb/solib-aix.c b/gdb/solib-aix.c index 0fc3a153973..1a70f98ba59 100644 --- a/gdb/solib-aix.c +++ b/gdb/solib-aix.c @@ -65,7 +65,7 @@ struct solib_aix_inferior_data the same principles applied to shared libraries also apply to the main executable. So it's simpler to keep it as part of this list. */ - gdb::optional> library_list; + std::optional> library_list; }; /* Key to our per-inferior data. */ @@ -91,7 +91,7 @@ get_solib_aix_inferior_data (struct inferior *inf) /* Dummy implementation if XML support is not compiled in. */ -static gdb::optional> +static std::optional> solib_aix_parse_libraries (const char *library) { static int have_warned; @@ -201,7 +201,7 @@ static const struct gdb_xml_element library_list_elements[] = Return an empty option if the parsing failed. */ -static gdb::optional> +static std::optional> solib_aix_parse_libraries (const char *library) { std::vector result; @@ -225,7 +225,7 @@ solib_aix_parse_libraries (const char *library) is not NULL, then print a warning including WARNING_MSG and a description of the error. */ -static gdb::optional> & +static std::optional> & solib_aix_get_library_list (struct inferior *inf, const char *warning_msg) { struct solib_aix_inferior_data *data; @@ -235,7 +235,7 @@ solib_aix_get_library_list (struct inferior *inf, const char *warning_msg) if (data->library_list.has_value ()) return data->library_list; - gdb::optional library_document + std::optional library_document = target_read_stralloc (current_inferior ()->top_target (), TARGET_OBJECT_LIBRARIES_AIX, NULL); @@ -421,7 +421,7 @@ solib_aix_solib_create_inferior_hook (int from_tty) /* We need to relocate the main executable... */ - gdb::optional> &library_list + std::optional> &library_list = solib_aix_get_library_list (current_inferior (), warning_msg); if (!library_list.has_value ()) return; /* Warning already printed. */ @@ -448,7 +448,7 @@ solib_aix_solib_create_inferior_hook (int from_tty) static intrusive_list solib_aix_current_sos () { - gdb::optional> &library_list + std::optional> &library_list = solib_aix_get_library_list (current_inferior (), NULL); if (!library_list.has_value ()) return {}; diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c index ef561466945..0d98ae85cc0 100644 --- a/gdb/solib-dsbt.c +++ b/gdb/solib-dsbt.c @@ -276,7 +276,7 @@ static void dsbt_get_initial_loadmaps (void) { dsbt_info *info = get_dsbt_info (current_program_space); - gdb::optional buf + std::optional buf = target_read_alloc (current_inferior ()->top_target (), TARGET_OBJECT_FDPIC, "exec"); diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index 5882a4e0070..d7fd199703c 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -454,7 +454,7 @@ static int match_main (const char *); architecture size (32-bit or 64-bit) is returned to *P_ARCH_SIZE. Likewise, the base address of the section is returned in *BASE_ADDR. */ -static gdb::optional +static std::optional read_program_header (int type, int *p_arch_size, CORE_ADDR *base_addr) { bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ()); @@ -587,7 +587,7 @@ read_program_header (int type, int *p_arch_size, CORE_ADDR *base_addr) /* Return program interpreter string. */ -static gdb::optional +static std::optional find_program_interpreter (void) { /* If we have a current exec_bfd, use its section table. */ @@ -632,7 +632,7 @@ scan_dyntag_auxv (const int desired_dyntag, CORE_ADDR *ptr, CORE_ADDR base_addr; /* Read in .dynamic section. */ - gdb::optional ph_data + std::optional ph_data = read_program_header (PT_DYNAMIC, &arch_size, &base_addr); if (!ph_data) return 0; @@ -1159,7 +1159,7 @@ svr4_current_sos_via_xfer_libraries (struct svr4_library_list *list, gdb_assert (annex == NULL || target_augmented_libraries_svr4_read ()); /* Fetch the list of shared libraries. */ - gdb::optional svr4_library_document + std::optional svr4_library_document = target_read_stralloc (current_inferior ()->top_target (), TARGET_OBJECT_LIBRARIES_SVR4, annex); @@ -2309,7 +2309,7 @@ enable_break (struct svr4_info *info, int from_tty) /* Find the program interpreter; if not found, warn the user and drop into the old breakpoint at symbol code. */ - gdb::optional interp_name_holder + std::optional interp_name_holder = find_program_interpreter (); if (interp_name_holder) { @@ -2519,7 +2519,7 @@ enable_break (struct svr4_info *info, int from_tty) /* Read the ELF program headers from ABFD. */ -static gdb::optional +static std::optional read_program_headers_from_bfd (bfd *abfd) { Elf_Internal_Ehdr *ehdr = elf_elfheader (abfd); @@ -2632,9 +2632,9 @@ svr4_exec_displacement (CORE_ADDR *displacementp) really do not match. */ int arch_size; - gdb::optional phdrs_target + std::optional phdrs_target = read_program_header (-1, &arch_size, NULL); - gdb::optional phdrs_binary + std::optional phdrs_binary = read_program_headers_from_bfd (current_program_space->exec_bfd ()); if (phdrs_target && phdrs_binary) { diff --git a/gdb/solib-target.c b/gdb/solib-target.c index c6125072812..b311c76965d 100644 --- a/gdb/solib-target.c +++ b/gdb/solib-target.c @@ -233,7 +233,7 @@ solib_target_current_sos (void) intrusive_list sos; /* Fetch the list of shared libraries. */ - gdb::optional library_document + std::optional library_document = target_read_stralloc (current_inferior ()->top_target (), TARGET_OBJECT_LIBRARIES, NULL); if (!library_document) diff --git a/gdb/source-cache.c b/gdb/source-cache.c index c955929b543..eb467fd3da5 100644 --- a/gdb/source-cache.c +++ b/gdb/source-cache.c @@ -343,7 +343,7 @@ source_cache::ensure (struct symtab *s) if (!already_styled) { - gdb::optional ext_contents; + std::optional ext_contents; ext_contents = ext_lang_colorize (fullname, contents); if (ext_contents.has_value ()) { diff --git a/gdb/stack.c b/gdb/stack.c index ef565445c16..20bb85efd19 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -97,7 +97,7 @@ static const char *const print_frame_info_choices[] = /* print_frame_info_print_what[i] maps a choice to the corresponding print_what enum. */ -static const gdb::optional print_frame_info_print_what[] = +static const std::optional print_frame_info_print_what[] = {{}, /* Empty value for "auto". */ SRC_LINE, LOCATION, SRC_AND_LOC, LOC_AND_ADDRESS, SHORT_LOCATION}; @@ -973,7 +973,7 @@ do_gdb_disassembly (struct gdbarch *gdbarch, Value not present indicates to the caller to use default values specific to the command being executed. */ -static gdb::optional +static std::optional print_frame_info_to_print_what (const char *print_frame_info) { for (int i = 0; print_frame_info_choices[i] != NULL; i++) @@ -1004,7 +1004,7 @@ print_pc (struct ui_out *uiout, struct gdbarch *gdbarch, frame_info_ptr frame, /* See stack.h. */ void -get_user_print_what_frame_info (gdb::optional *what) +get_user_print_what_frame_info (std::optional *what) { *what = print_frame_info_to_print_what @@ -2261,8 +2261,8 @@ iterate_over_block_local_vars (const struct block *block, struct print_variable_and_value_data { - gdb::optional preg; - gdb::optional treg; + std::optional preg; + std::optional treg; struct frame_id frame_id; int num_tabs; struct ui_file *stream; @@ -2307,7 +2307,7 @@ print_variable_and_value_data::operator() (const char *print_name, If REGEXP is NULL, it results in an empty regular expression. */ static void -prepare_reg (const char *regexp, gdb::optional *reg) +prepare_reg (const char *regexp, std::optional *reg) { if (regexp != NULL) { @@ -2499,8 +2499,8 @@ print_frame_arg_vars (frame_info_ptr frame, struct print_variable_and_value_data cb_data; struct symbol *func; CORE_ADDR pc; - gdb::optional preg; - gdb::optional treg; + std::optional preg; + std::optional treg; if (!get_frame_pc_if_available (frame, &pc)) { diff --git a/gdb/stack.h b/gdb/stack.h index 1b0c2b342a4..a64abaf52b5 100644 --- a/gdb/stack.h +++ b/gdb/stack.h @@ -38,7 +38,7 @@ void iterate_over_block_local_vars (const struct block *block, information to print, otherwise the printing function should print the relevant information. */ -void get_user_print_what_frame_info (gdb::optional *what); +void get_user_print_what_frame_info (std::optional *what); /* Return true if we should display the address in addition to the location, because we are in the middle of a statement. */ diff --git a/gdb/symfile.c b/gdb/symfile.c index bbac6ad9df1..c5af186ad33 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -913,7 +913,7 @@ syms_from_objfile_1 (struct objfile *objfile, /* Make sure that partially constructed symbol tables will be cleaned up if an error occurs during symbol reading. */ - gdb::optional defer_clear_users; + std::optional defer_clear_users; objfile_up objfile_holder (objfile); diff --git a/gdb/symtab.c b/gdb/symtab.c index 5ec56f4f2af..17d1987608f 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -66,7 +66,7 @@ #include "parser-defs.h" #include "completer.h" #include "progspace-and-thread.h" -#include "gdbsupport/gdb_optional.h" +#include #include "filename-seen-cache.h" #include "arch-utils.h" #include @@ -943,7 +943,7 @@ void general_symbol_info::compute_and_set_names (gdb::string_view linkage_name, bool copy_name, objfile_per_bfd_storage *per_bfd, - gdb::optional hash) + std::optional hash) { struct demangled_name_entry **slot; @@ -3714,7 +3714,7 @@ skip_prologue_using_lineinfo (CORE_ADDR func_addr, struct symtab *symtab) the function starting at FUNC_ADDR which has prologue_end set to true if such entry exist, otherwise return an empty optional. */ -static gdb::optional +static std::optional skip_prologue_using_linetable (CORE_ADDR func_addr) { CORE_ADDR start_pc, end_pc; @@ -3838,7 +3838,7 @@ skip_prologue_sal (struct symtab_and_line *sal) be placed to skip the prologue. */ if (!ignore_prologue_end_flag && skip) { - gdb::optional linetable_pc + std::optional linetable_pc = skip_prologue_using_linetable (pc); if (linetable_pc) { @@ -4450,8 +4450,8 @@ info_sources_worker (struct ui_out *uiout, output_source_filename_data data (uiout, filter); ui_out_emit_list results_emitter (uiout, "files"); - gdb::optional output_tuple; - gdb::optional sources_list; + std::optional output_tuple; + std::optional sources_list; gdb_assert (group_by_objfile || uiout->is_mi_like_p ()); @@ -4652,7 +4652,7 @@ global_symbol_searcher::is_suitable_msymbol bool global_symbol_searcher::expand_symtabs - (objfile *objfile, const gdb::optional &preg) const + (objfile *objfile, const std::optional &preg) const { enum search_domain kind = m_kind; bool found_msymbol = false; @@ -4734,8 +4734,8 @@ global_symbol_searcher::expand_symtabs bool global_symbol_searcher::add_matching_symbols (objfile *objfile, - const gdb::optional &preg, - const gdb::optional &treg, + const std::optional &preg, + const std::optional &treg, std::set *result_set) const { enum search_domain kind = m_kind; @@ -4813,7 +4813,7 @@ global_symbol_searcher::add_matching_symbols bool global_symbol_searcher::add_matching_msymbols - (objfile *objfile, const gdb::optional &preg, + (objfile *objfile, const std::optional &preg, std::vector *results) const { enum search_domain kind = m_kind; @@ -4860,8 +4860,8 @@ global_symbol_searcher::add_matching_msymbols std::vector global_symbol_searcher::search () const { - gdb::optional preg; - gdb::optional treg; + std::optional preg; + std::optional treg; gdb_assert (m_kind != ALL_DOMAIN); diff --git a/gdb/symtab.h b/gdb/symtab.h index 8dfc873b1c9..0fb0c8683cb 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -30,7 +30,7 @@ #include "gdbsupport/gdb_regex.h" #include "gdbsupport/enum-flags.h" #include "gdbsupport/function-view.h" -#include "gdbsupport/gdb_optional.h" +#include #include "gdbsupport/gdb_string_view.h" #include "gdbsupport/next-iterator.h" #include "gdbsupport/iterator-range.h" @@ -364,10 +364,10 @@ class lookup_name_info final around by const reference (see intro), and they're conceptually "cache" that can always be reconstructed from the non-mutable fields. */ - mutable gdb::optional m_ada; - mutable gdb::optional m_cplus; - mutable gdb::optional m_d; - mutable gdb::optional m_go; + mutable std::optional m_ada; + mutable std::optional m_cplus; + mutable std::optional m_d; + mutable std::optional m_go; /* The demangled hashes. Stored in an array with one entry for each possible language. The second array records whether we've @@ -511,8 +511,8 @@ struct general_symbol_info copy_name must be set to true. */ void compute_and_set_names (gdb::string_view linkage_name, bool copy_name, struct objfile_per_bfd_storage *per_bfd, - gdb::optional hash - = gdb::optional ()); + std::optional hash + = std::optional ()); CORE_ADDR value_address () const { @@ -2598,7 +2598,7 @@ class global_symbol_searcher true if any msymbols were seen that we should later consider adding to the results list. */ bool expand_symtabs (objfile *objfile, - const gdb::optional &preg) const; + const std::optional &preg) const; /* Add symbols from symtabs in OBJFILE that match PREG, and TREG, and are of type M_KIND, to the results set RESULTS_SET. Return false if we @@ -2607,8 +2607,8 @@ class global_symbol_searcher Returning true does not indicate that any results were added, just that we didn't _not_ add a result due to reaching MAX_SEARCH_RESULTS. */ bool add_matching_symbols (objfile *objfile, - const gdb::optional &preg, - const gdb::optional &treg, + const std::optional &preg, + const std::optional &treg, std::set *result_set) const; /* Add msymbols from OBJFILE that match PREG and M_KIND, to the results @@ -2618,7 +2618,7 @@ class global_symbol_searcher does not indicate that any results were added, just that we didn't _not_ add a result due to reaching MAX_SEARCH_RESULTS. */ bool add_matching_msymbols (objfile *objfile, - const gdb::optional &preg, + const std::optional &preg, std::vector *results) const; /* Return true if MSYMBOL is of type KIND. */ @@ -2907,7 +2907,7 @@ struct info_sources_filter /* A compiled version of M_REGEXP. This object is only given a value if M_REGEXP is not nullptr and is not the empty string. */ - gdb::optional m_c_regexp; + std::optional m_c_regexp; }; /* Perform the core of the 'info sources' command. diff --git a/gdb/target.c b/gdb/target.c index 92aa1dd882e..c3dad38f317 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -2231,7 +2231,7 @@ target_write (struct target_ops *ops, for details. */ template -gdb::optional> +std::optional> target_read_alloc_1 (struct target_ops *ops, enum target_object object, const char *annex) { @@ -2280,7 +2280,7 @@ target_read_alloc_1 (struct target_ops *ops, enum target_object object, /* See target.h */ -gdb::optional +std::optional target_read_alloc (struct target_ops *ops, enum target_object object, const char *annex) { @@ -2289,11 +2289,11 @@ target_read_alloc (struct target_ops *ops, enum target_object object, /* See target.h. */ -gdb::optional +std::optional target_read_stralloc (struct target_ops *ops, enum target_object object, const char *annex) { - gdb::optional buf + std::optional buf = target_read_alloc_1 (ops, object, annex); if (!buf) @@ -2977,7 +2977,7 @@ target_supports_multi_process (void) /* See target.h. */ -gdb::optional +std::optional target_get_osdata (const char *type) { struct target_ops *t; @@ -3206,7 +3206,7 @@ target_ops::fileio_unlink (struct inferior *inf, const char *filename, return -1; } -gdb::optional +std::optional target_ops::fileio_readlink (struct inferior *inf, const char *filename, fileio_error *target_errno) { @@ -3377,13 +3377,13 @@ target_fileio_unlink (struct inferior *inf, const char *filename, /* See target.h. */ -gdb::optional +std::optional target_fileio_readlink (struct inferior *inf, const char *filename, fileio_error *target_errno) { for (target_ops *t = default_fileio_target (); t != NULL; t = t->beneath ()) { - gdb::optional ret + std::optional ret = t->fileio_readlink (inf, filename, target_errno); if (!ret.has_value () && *target_errno == FILEIO_ENOSYS) diff --git a/gdb/target.h b/gdb/target.h index fca0bbbf66e..c54bd28c88c 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -345,7 +345,7 @@ LONGEST target_write_with_progress (struct target_ops *ops, size is known in advance. Don't try to read TARGET_OBJECT_MEMORY through this function. */ -extern gdb::optional target_read_alloc +extern std::optional target_read_alloc (struct target_ops *ops, enum target_object object, const char *annex); /* Read OBJECT/ANNEX using OPS. The result is a NUL-terminated character vector @@ -355,7 +355,7 @@ extern gdb::optional target_read_alloc the returned vector is guaranteed to have at least one element. A warning is issued if the result contains any embedded NUL bytes. */ -extern gdb::optional target_read_stralloc +extern std::optional target_read_stralloc (struct target_ops *ops, enum target_object object, const char *annex); /* See target_ops->to_xfer_partial. */ @@ -1001,7 +1001,7 @@ struct target_ops seen by the debugger (GDB or, for remote targets, the remote stub). Return a string, or an empty optional if an error occurs (and set *TARGET_ERRNO). */ - virtual gdb::optional fileio_readlink (struct inferior *inf, + virtual std::optional fileio_readlink (struct inferior *inf, const char *filename, fileio_error *target_errno); @@ -2206,7 +2206,7 @@ extern int target_fileio_unlink (struct inferior *inf, by the debugger (GDB or, for remote targets, the remote stub). Return a null-terminated string allocated via xmalloc, or NULL if an error occurs (and set *TARGET_ERRNO). */ -extern gdb::optional target_fileio_readlink +extern std::optional target_fileio_readlink (struct inferior *inf, const char *filename, fileio_error *target_errno); /* Read target file FILENAME, in the filesystem as seen by INF. If @@ -2469,7 +2469,7 @@ struct target_ops *find_target_at (enum strata stratum); /* Read OS data object of type TYPE from the target, and return it in XML format. The return value follows the same rules as target_read_stralloc. */ -extern gdb::optional target_get_osdata (const char *type); +extern std::optional target_get_osdata (const char *type); /* Stuff that should be shared among the various remote targets. */ diff --git a/gdb/thread.c b/gdb/thread.c index 810fdae18a8..c0ed64e5f8b 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -46,7 +46,7 @@ #include "thread-fsm.h" #include "tid-parse.h" #include -#include "gdbsupport/gdb_optional.h" +#include #include "inline-frame.h" #include "stack.h" #include "interps.h" @@ -194,7 +194,7 @@ clear_thread_inferior_resources (struct thread_info *tp) /* Notify interpreters and observers that thread T has exited. */ static void -notify_thread_exited (thread_info *t, gdb::optional exit_code, +notify_thread_exited (thread_info *t, std::optional exit_code, int silent) { if (!silent && print_thread_events) @@ -215,7 +215,7 @@ notify_thread_exited (thread_info *t, gdb::optional exit_code, /* See gdbthread.h. */ void -set_thread_exited (thread_info *tp, gdb::optional exit_code, +set_thread_exited (thread_info *tp, std::optional exit_code, bool silent) { /* Dead threads don't need to step-over. Remove from chain. */ @@ -504,7 +504,7 @@ global_thread_step_over_chain_remove (struct thread_info *tp) /* Helper for the different delete_thread variants. */ static void -delete_thread_1 (thread_info *thr, gdb::optional exit_code, +delete_thread_1 (thread_info *thr, std::optional exit_code, bool silent) { gdb_assert (thr != nullptr); @@ -1112,8 +1112,8 @@ print_thread_info_1 (struct ui_out *uiout, const char *requested_threads, /* For backward compatibility, we make a list for MI. A table is preferable for the CLI, though, because it shows table headers. */ - gdb::optional list_emitter; - gdb::optional table_emitter; + std::optional list_emitter; + std::optional table_emitter; /* We'll be switching threads temporarily below. */ scoped_restore_current_thread restore_thread; @@ -1543,7 +1543,7 @@ tp_array_compar_descending (const thread_info_ref &a, const thread_info_ref &b) /* See gdbthread.h. */ void -thread_try_catch_cmd (thread_info *thr, gdb::optional ada_task, +thread_try_catch_cmd (thread_info *thr, std::optional ada_task, const char *cmd, int from_tty, const qcs_flags &flags) { diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c index b698b4004cc..a710246d7ad 100644 --- a/gdb/tracefile-tfile.c +++ b/gdb/tracefile-tfile.c @@ -305,7 +305,7 @@ tfile_write_tdesc (struct trace_file_writer *self) struct tfile_trace_file_writer *writer = (struct tfile_trace_file_writer *) self; - gdb::optional tdesc + std::optional tdesc = target_fetch_description_xml (current_inferior ()->top_target ()); if (!tdesc) diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 750185341ea..05b5f681571 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -3732,7 +3732,7 @@ sdata_make_value (struct gdbarch *gdbarch, struct internalvar *var, void *ignore) { /* We need to read the whole object before we know its size. */ - gdb::optional buf + std::optional buf = target_read_alloc (current_inferior ()->top_target (), TARGET_OBJECT_STATIC_TRACE_DATA, NULL); diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c index ffcb95bb635..b5d5a4cc20f 100644 --- a/gdb/tui/tui-disasm.c +++ b/gdb/tui/tui-disasm.c @@ -234,7 +234,7 @@ tui_find_disassembly_address (struct gdbarch *gdbarch, CORE_ADDR pc, int from) promising starting point then we record it in this structure. If the next address we try is not a suitable starting point then we will fall back to the address held here. */ - gdb::optional possible_new_low; + std::optional possible_new_low; /* The previous value of NEW_LOW so we know if the new value is different or not. */ diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c index 159445dc520..b932649b3ac 100644 --- a/gdb/tui/tui-layout.c +++ b/gdb/tui/tui-layout.c @@ -819,7 +819,7 @@ tui_layout_split::apply (int x_, int y_, int width_, int height_, }; /* This is given a value only if we fix the size of the cmd window. */ - gdb::optional old_cmd_info; + std::optional old_cmd_info; std::vector info (m_splits.size ()); diff --git a/gdb/unittests/optional-selftests.c b/gdb/unittests/optional-selftests.c index 8a727c02159..51135b8b98c 100644 --- a/gdb/unittests/optional-selftests.c +++ b/gdb/unittests/optional-selftests.c @@ -31,7 +31,7 @@ #define VERIFY SELF_CHECK /* Used to disable testing features not supported by - gdb::optional. */ + std::optional. */ #define GDB_OPTIONAL namespace selftests { @@ -41,7 +41,7 @@ namespace optional { copied over from libstdc++'s testsuite. To preserve the structure and help with comparison with the original tests, the file names have been preserved, and only minimal modification was done to have - them compile against gdb::optional instead of std::optional: + them compile against std::optional instead of std::optional: - std::optional->gdb:optional, etc. - ATTRIBUTE_UNUSED in a few places diff --git a/gdb/utils.c b/gdb/utils.c index f959af3219b..7a1841ba21e 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -68,7 +68,7 @@ #include "gdbsupport/gdb_regex.h" #include "gdbsupport/job-control.h" #include "gdbsupport/selftest.h" -#include "gdbsupport/gdb_optional.h" +#include #include "cp-support.h" #include #include "gdbsupport/pathstuff.h" @@ -143,7 +143,7 @@ vwarning (const char *string, va_list args) (*deprecated_warning_hook) (string, args); else { - gdb::optional term_state; + std::optional term_state; if (target_supports_terminal_ours ()) { term_state.emplace (); @@ -375,7 +375,7 @@ internal_vproblem (struct internal_problem *problem, } /* Try to get the message out and at the start of a new line. */ - gdb::optional term_state; + std::optional term_state; if (target_supports_terminal_ours ()) { term_state.emplace (); diff --git a/gdb/valarith.c b/gdb/valarith.c index f3acf98c98b..6cf56302aee 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -150,14 +150,14 @@ value_subscript (struct value *array, LONGEST index) || tarray->code () == TYPE_CODE_STRING) { struct type *range_type = tarray->index_type (); - gdb::optional lowerbound = get_discrete_low_bound (range_type); + std::optional lowerbound = get_discrete_low_bound (range_type); if (!lowerbound.has_value ()) lowerbound = 0; if (array->lval () != lval_memory) return value_subscripted_rvalue (array, index, *lowerbound); - gdb::optional upperbound + std::optional upperbound = get_discrete_high_bound (range_type); if (!upperbound.has_value ()) diff --git a/gdb/valops.c b/gdb/valops.c index 70851cd40b4..a8760ccf3e4 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -52,7 +52,7 @@ static struct value *search_struct_field (const char *, struct value *, struct type *, int); static struct value *search_struct_method (const char *, struct value **, - gdb::optional>, + std::optional>, LONGEST, int *, struct type *); static int find_oload_champ_namespace (gdb::array_view args, @@ -2196,7 +2196,7 @@ search_struct_field (const char *name, struct value *arg1, static struct value * search_struct_method (const char *name, struct value **arg1p, - gdb::optional> args, + std::optional> args, LONGEST offset, int *static_memfuncp, struct type *type) { @@ -2332,7 +2332,7 @@ search_struct_method (const char *name, struct value **arg1p, struct value * value_struct_elt (struct value **argp, - gdb::optional> args, + std::optional> args, const char *name, int *static_memfuncp, const char *err) { struct type *t; diff --git a/gdb/value.c b/gdb/value.c index 17b7c53d052..7067ae94df0 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -826,7 +826,7 @@ exceeds_max_value_size (ULONGEST length) /* When this has a value, it is used to limit the number of array elements of an array that are loaded into memory when an array value is made non-lazy. */ -static gdb::optional array_length_limiting_element_count; +static std::optional array_length_limiting_element_count; /* See value.h. */ scoped_array_length_limiting::scoped_array_length_limiting (int elements) diff --git a/gdb/value.h b/gdb/value.h index e4912717684..6d91e8eee7a 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -1269,7 +1269,7 @@ extern struct value *value_neg (struct value *arg1); extern struct value *value_complement (struct value *arg1); extern struct value *value_struct_elt (struct value **argp, - gdb::optional> args, + std::optional> args, const char *name, int *static_memfuncp, const char *err); @@ -1635,7 +1635,7 @@ struct scoped_array_length_limiting private: /* Used to hold the previous array value element limit. */ - gdb::optional m_old_value; + std::optional m_old_value; }; #endif /* !defined (VALUE_H) */ diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 205bf01174f..b3440344c74 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -1335,7 +1335,7 @@ windows_nat_target::windows_continue (DWORD continue_status, int id, th->suspend (); } - gdb::optional err; + std::optional err; do_synchronously ([&] () { if (!continue_last_debug_event (continue_status, debug_events)) @@ -1561,7 +1561,7 @@ windows_nat_target::get_windows_debug_event /* If there is a relevant pending stop, report it now. See the comment by the definition of "pending_stops" for details on why this is needed. */ - gdb::optional stop + std::optional stop = windows_process.fetch_pending_stop (debug_events); if (stop.has_value ()) { @@ -2024,7 +2024,7 @@ windows_nat_target::attach (const char *args, int from_tty) windows_init_thread_list (); windows_process.saw_create = 0; - gdb::optional err; + std::optional err; do_synchronously ([&] () { BOOL ok = DebugActiveProcess (pid); @@ -2074,7 +2074,7 @@ windows_nat_target::detach (inferior *inf, int from_tty) { windows_continue (DBG_CONTINUE, -1, 0, true); - gdb::optional err; + std::optional err; do_synchronously ([&] () { if (!DebugActiveProcessStop (windows_process.current_event.dwProcessId)) @@ -2533,7 +2533,7 @@ windows_nat_target::create_inferior (const char *exec_file, #endif /* !__CYGWIN__ */ const char *allargs = origallargs.c_str (); PROCESS_INFORMATION pi; - gdb::optional ret; + std::optional ret; DWORD flags = 0; const std::string &inferior_tty = current_inferior ()->tty (); diff --git a/gdb/xml-support.c b/gdb/xml-support.c index 0c98dc7e6b4..2d231b6f4bb 100644 --- a/gdb/xml-support.c +++ b/gdb/xml-support.c @@ -785,7 +785,7 @@ xinclude_start_include (struct gdb_xml_parser *parser, gdb_xml_error (parser, _("Maximum XInclude depth (%d) exceeded"), MAX_XINCLUDE_DEPTH); - gdb::optional text = data->fetcher (href); + std::optional text = data->fetcher (href); if (!text) gdb_xml_error (parser, _("Could not load XML document \"%s\""), href); @@ -960,7 +960,7 @@ show_debug_xml (struct ui_file *file, int from_tty, gdb_printf (file, _("XML debugging is %s.\n"), value); } -gdb::optional +std::optional xml_fetch_content_from_file (const char *filename, const char *dirname) { gdb_file_up file; diff --git a/gdb/xml-support.h b/gdb/xml-support.h index 1f9ac68b745..8388276df25 100644 --- a/gdb/xml-support.h +++ b/gdb/xml-support.h @@ -24,7 +24,7 @@ #include "gdbsupport/gdb_obstack.h" #include "gdbsupport/xml-utils.h" #include "gdbsupport/byte-vector.h" -#include "gdbsupport/gdb_optional.h" +#include #include "gdbsupport/function-view.h" struct gdb_xml_parser; @@ -49,7 +49,7 @@ LONGEST xml_builtin_xfer_partial (const char *filename, /* Callback to fetch a new XML file, based on the provided HREF. */ -using xml_fetch_another = gdb::function_view +using xml_fetch_another = gdb::function_view (const char * /* href */)>; /* Append the expansion of TEXT after processing tags in @@ -230,7 +230,7 @@ ULONGEST gdb_xml_parse_ulongest (struct gdb_xml_parser *parser, the text. If something goes wrong, return an uninstantiated optional and warn. */ -extern gdb::optional xml_fetch_content_from_file +extern std::optional xml_fetch_content_from_file (const char *filename, const char *dirname); #endif diff --git a/gdb/xml-syscall.c b/gdb/xml-syscall.c index da1211ef8e9..cfb54347431 100644 --- a/gdb/xml-syscall.c +++ b/gdb/xml-syscall.c @@ -314,7 +314,7 @@ syscall_parse_xml (const char *document, xml_fetch_another fetcher) static struct syscalls_info * xml_init_syscalls_info (const char *filename) { - gdb::optional full_file + std::optional full_file = xml_fetch_content_from_file (filename, const_cast(gdb_datadir.c_str ())); if (!full_file) diff --git a/gdb/xml-tdesc.c b/gdb/xml-tdesc.c index a8b0b0566c7..daf123af69d 100644 --- a/gdb/xml-tdesc.c +++ b/gdb/xml-tdesc.c @@ -663,7 +663,7 @@ tdesc_parse_xml (const char *document, xml_fetch_another fetcher) const struct target_desc * file_read_description_xml (const char *filename) { - gdb::optional tdesc_str + std::optional tdesc_str = xml_fetch_content_from_file (filename, NULL); if (!tdesc_str) { @@ -687,7 +687,7 @@ file_read_description_xml (const char *filename) is "target.xml". Other calls may be performed for the DTD or for . */ -static gdb::optional +static std::optional fetch_available_features_from_target (const char *name, target_ops *ops) { /* Read this object as a string. This ensures that a NUL @@ -704,7 +704,7 @@ fetch_available_features_from_target (const char *name, target_ops *ops) const struct target_desc * target_read_description_xml (struct target_ops *ops) { - gdb::optional tdesc_str + std::optional tdesc_str = fetch_available_features_from_target ("target.xml", ops); if (!tdesc_str) return NULL; @@ -721,7 +721,7 @@ target_read_description_xml (struct target_ops *ops) includes, but not parsing it. Used to dump whole tdesc as a single XML file. */ -gdb::optional +std::optional target_fetch_description_xml (struct target_ops *ops) { #if !defined(HAVE_LIBEXPAT) @@ -736,7 +736,7 @@ target_fetch_description_xml (struct target_ops *ops) return {}; #else - gdb::optional + std::optional tdesc_str = fetch_available_features_from_target ("target.xml", ops); if (!tdesc_str) return {}; @@ -765,6 +765,6 @@ string_read_description_xml (const char *xml) return tdesc_parse_xml (xml, [] (const char *href) { error (_("xincludes are unsupported with this method")); - return gdb::optional (); + return std::optional (); }); } diff --git a/gdb/xml-tdesc.h b/gdb/xml-tdesc.h index 0fbfc7e043e..0ffca92ed7a 100644 --- a/gdb/xml-tdesc.h +++ b/gdb/xml-tdesc.h @@ -22,7 +22,7 @@ #ifndef XML_TDESC_H #define XML_TDESC_H -#include "gdbsupport/gdb_optional.h" +#include #include struct target_ops; @@ -42,7 +42,7 @@ const struct target_desc *target_read_description_xml (struct target_ops *); but not parsing it. Used to dump whole tdesc as a single XML file. Returns the description on success, and a disengaged optional otherwise. */ -gdb::optional target_fetch_description_xml (target_ops *ops); +std::optional target_fetch_description_xml (target_ops *ops); /* Take an xml string, parse it, and return the parsed description. Does not handle a string containing includes. */ diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc index fcbe7bb64d7..70454652720 100644 --- a/gdbserver/linux-aarch64-low.cc +++ b/gdbserver/linux-aarch64-low.cc @@ -299,7 +299,7 @@ aarch64_fill_tlsregset (struct regcache *regcache, void *buf) collect_register (regcache, tls_regnum, tls_buf); /* Read TPIDR2, if it exists. */ - gdb::optional regnum = find_regno_no_throw (regcache->tdesc, "tpidr2"); + std::optional regnum = find_regno_no_throw (regcache->tdesc, "tpidr2"); if (regnum.has_value ()) collect_register (regcache, *regnum, tls_buf + sizeof (uint64_t)); @@ -316,7 +316,7 @@ aarch64_store_tlsregset (struct regcache *regcache, const void *buf) supply_register (regcache, tls_regnum, tls_buf); /* Write TPIDR2, if it exists. */ - gdb::optional regnum = find_regno_no_throw (regcache->tdesc, "tpidr2"); + std::optional regnum = find_regno_no_throw (regcache->tdesc, "tpidr2"); if (regnum.has_value ()) supply_register (regcache, *regnum, tls_buf + sizeof (uint64_t)); diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc index 0b1141662ac..2e75a948a19 100644 --- a/gdbserver/regcache.cc +++ b/gdbserver/regcache.cc @@ -249,7 +249,7 @@ registers_from_string (struct regcache *regcache, char *buf) /* See regcache.h */ -gdb::optional +std::optional find_regno_no_throw (const struct target_desc *tdesc, const char *name) { for (int i = 0; i < tdesc->reg_defs.size (); ++i) @@ -263,7 +263,7 @@ find_regno_no_throw (const struct target_desc *tdesc, const char *name) int find_regno (const struct target_desc *tdesc, const char *name) { - gdb::optional regnum = find_regno_no_throw (tdesc, name); + std::optional regnum = find_regno_no_throw (tdesc, name); if (regnum.has_value ()) return *regnum; diff --git a/gdbserver/regcache.h b/gdbserver/regcache.h index 7248bcf5808..4700c03f104 100644 --- a/gdbserver/regcache.h +++ b/gdbserver/regcache.h @@ -112,7 +112,7 @@ int register_size (const struct target_desc *tdesc, int n); /* No throw version of find_regno. If NAME is not a known register, return an empty value. */ -gdb::optional find_regno_no_throw (const struct target_desc *tdesc, +std::optional find_regno_no_throw (const struct target_desc *tdesc, const char *name); int find_regno (const struct target_desc *tdesc, const char *name); diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc index 3246957ec44..3842c80daff 100644 --- a/gdbserver/win32-low.cc +++ b/gdbserver/win32-low.cc @@ -1019,7 +1019,7 @@ get_child_debug_event (DWORD *continue_status, windows_process.attaching = 0; { - gdb::optional stop + std::optional stop = windows_process.fetch_pending_stop (debug_threads); if (stop.has_value ()) { diff --git a/gdbsupport/common-debug.h b/gdbsupport/common-debug.h index 33b15a005f1..8908669696c 100644 --- a/gdbsupport/common-debug.h +++ b/gdbsupport/common-debug.h @@ -20,7 +20,7 @@ #ifndef COMMON_COMMON_DEBUG_H #define COMMON_COMMON_DEBUG_H -#include "gdbsupport/gdb_optional.h" +#include #include "gdbsupport/preprocessor.h" #include @@ -200,7 +200,7 @@ struct scoped_debug_start_end const char *m_end_prefix; /* The result of formatting the format string in the constructor. */ - gdb::optional m_msg; + std::optional m_msg; /* True is a non-nullptr format was passed to the constructor. */ bool m_with_format; diff --git a/gdbsupport/event-loop.cc b/gdbsupport/event-loop.cc index 52e7fd2223f..031c2ff500f 100644 --- a/gdbsupport/event-loop.cc +++ b/gdbsupport/event-loop.cc @@ -33,7 +33,7 @@ #include #include "gdbsupport/gdb_sys_time.h" #include "gdbsupport/gdb_select.h" -#include "gdbsupport/gdb_optional.h" +#include #include "gdbsupport/scope-exit.h" /* See event-loop.h. */ @@ -246,7 +246,7 @@ gdb_do_one_event (int mstimeout) When the timeout is reached, events are not monitored again: they already have been checked in the loop above. */ - gdb::optional timer_id; + std::optional timer_id; SCOPE_EXIT { @@ -258,7 +258,7 @@ gdb_do_one_event (int mstimeout) timer_id = create_timer (mstimeout, [] (gdb_client_data arg) { - ((gdb::optional *) arg)->reset (); + ((std::optional *) arg)->reset (); }, &timer_id); return gdb_wait_for_event (1); diff --git a/gdbsupport/filestuff.cc b/gdbsupport/filestuff.cc index 9e61fea1195..334bae88dce 100644 --- a/gdbsupport/filestuff.cc +++ b/gdbsupport/filestuff.cc @@ -504,7 +504,7 @@ mkdir_recursive (const char *dir) /* See gdbsupport/filestuff.h. */ -gdb::optional +std::optional read_text_file_to_string (const char *path) { gdb_file_up file = gdb_fopen_cloexec (path, "r"); diff --git a/gdbsupport/filestuff.h b/gdbsupport/filestuff.h index 48bef51f259..206b51e50e9 100644 --- a/gdbsupport/filestuff.h +++ b/gdbsupport/filestuff.h @@ -131,6 +131,6 @@ extern bool mkdir_recursive (const char *dir); /* Read the entire content of file PATH into an std::string. */ -extern gdb::optional read_text_file_to_string (const char *path); +extern std::optional read_text_file_to_string (const char *path); #endif /* COMMON_FILESTUFF_H */ diff --git a/gdbsupport/forward-scope-exit.h b/gdbsupport/forward-scope-exit.h index bf591ddf170..0552e1132f0 100644 --- a/gdbsupport/forward-scope-exit.h +++ b/gdbsupport/forward-scope-exit.h @@ -52,9 +52,9 @@ obj.release (); // Optional cancel if needed. forward_scope_exit is also handy when you would need to wrap a - scope_exit in a gdb::optional: + scope_exit in a std::optional: - gdb::optional cleanup; + std::optional cleanup; if (some condition) cleanup.emplace (thread); ... @@ -62,7 +62,7 @@ cleanup->release (); since with scope exit, you would have to know the scope_exit's - callable template type when you create the gdb::optional: + callable template type when you create the std::optional: gdb:optional> diff --git a/gdbsupport/range-chain.h b/gdbsupport/range-chain.h index 01d6cf0e4fc..3cebce014ad 100644 --- a/gdbsupport/range-chain.h +++ b/gdbsupport/range-chain.h @@ -90,7 +90,7 @@ struct range_chain /* The current iterator into one of the vector ranges. If no value then this (outer) iterator is at the end of the overall range. */ - gdb::optional m_current; + std::optional m_current; /* Vector of ranges. */ const std::vector &m_ranges; }; diff --git a/gdbsupport/scoped_ignore_sigttou.h b/gdbsupport/scoped_ignore_sigttou.h index a3f8361512a..558fb7f0a29 100644 --- a/gdbsupport/scoped_ignore_sigttou.h +++ b/gdbsupport/scoped_ignore_sigttou.h @@ -26,7 +26,7 @@ #ifdef SIGTTOU /* Simple wrapper that allows lazy initialization / destruction of T. - Slightly more efficient than gdb::optional, because it doesn't + Slightly more efficient than std::optional, because it doesn't carry storage to track whether the object has been initialized. */ template class lazy_init diff --git a/gdbsupport/thread-pool.cc b/gdbsupport/thread-pool.cc index 1c871ed378f..bbe043dc0a3 100644 --- a/gdbsupport/thread-pool.cc +++ b/gdbsupport/thread-pool.cc @@ -225,7 +225,7 @@ thread_pool::thread_function () while (true) { - optional t; + std::optional t; { /* We want to hold the lock while examining the task list, but diff --git a/gdbsupport/thread-pool.h b/gdbsupport/thread-pool.h index cb8696e1fa4..d5e1dc7fce1 100644 --- a/gdbsupport/thread-pool.h +++ b/gdbsupport/thread-pool.h @@ -30,7 +30,7 @@ #include #include #endif -#include "gdbsupport/gdb_optional.h" +#include namespace gdb { @@ -198,7 +198,7 @@ class thread_pool to represent a task. If the optional is empty, then this means that the receiving thread should terminate. If the optional is non-empty, then it is an actual task to evaluate. */ - std::queue> m_tasks; + std::queue> m_tasks; /* A condition variable and mutex that are used for communication between the main thread and the worker threads. */ From patchwork Tue Nov 21 12:04:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lancelot SIX X-Patchwork-Id: 80464 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 05A463858414 for ; Tue, 21 Nov 2023 12:07:02 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2074.outbound.protection.outlook.com [40.107.93.74]) by sourceware.org (Postfix) with ESMTPS id E94433858282 for ; Tue, 21 Nov 2023 12:05:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E94433858282 Authentication-Results: sourceware.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=amd.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E94433858282 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.93.74 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1700568361; cv=pass; b=ETTQzMCblaClzwPznvxdakRt7FJ0yRGqfPaNFflFtYYFL4CPYfChCQhvweQx792ohzqA+pIA6TEBkiAscSTOFDyDQSgvP81/fKb970YlNRn0ahFm5xqoQo5n0dGy5pgeuGamJuMMutRuTeu1IS8OoLmLrrOc8F+w+2uNfJbK2LM= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1700568361; c=relaxed/simple; bh=vv0Z/7CVKxR6/fDDNO77EpGlcg2MpF2LC7nGmiPFV+c=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=RkxU1J5G7u4VFhaUP2T4daqWxgHkW50s61NHzJ/Kl9+qcwV+DgLrSdWU4/xvE8Y91h3+2CWdF6/cfjxx8qBpZ7vZBfbPtkevylPJ0OdTDe5KTU+JwaXmomrgmNL51oGfmM8VHaCXUJeLD88W2aMKIl5ll9X4RBTjOgc+IspWqw0= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q1da7otRg3QKhAjEGqSFmDUiaOQDsXo4heYH4YxF5Zhh9UPyF5oAOrWP0rL2Ot6S1fJiztmvo2fQ+Qg0nMWhoUPJhlUwbI3I/YqmSPUnNtNkzlec0cRqizhUX5mbvtnwrkMEgywiAA4syoNSA/NWDbdAiKX1HYQ4+NKhV2kL2XosAO2thFjOlP+AkK/CIbjo6G00/DsWfDGjIVyatEgPYlBF6Ew5ZOJrHVwVV7aN/SZjt265F4uSQr+/n1j+PY+NWtNxbEqhYWIdSnsmE0H6NxvKe2DMvi9XoLEMwRo5UrzqALv1DBLnhMzQ79ePWW1yfNdU6hr7XkIalNaFz7Ir4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uaf+OmSL0nsE7a9WVB7+POeS80rwqml9buBtOxcfgjU=; b=XhTpPBUIlChogQHLSYnWz5qcGCX1Cj3yIOV+ToKZ2G06N6VrH7nR7bjDdfLudxy7uqTr5dA2LC6E0kYO7sMXpB4aPsm29rwOVj2s+doeT5R3i7eCz2EvysSskKJ4160Qboo870IRjqmPNbNsNT4LPw6/VqH3IvY5DjdmFLRiblQEYp6xe1wCfAbUm+foyP11YjpIU3EpNt7brcvhVLG901wsbf6i6pg9aLdAEbe0WLTSPv/tfoi1dtlJ+padP49BHBl/tZ8DZMfev9WlB0zdSEaya4ghNxpAPOiEkV1U15SMMTruiYdb57dadqMhzoZQP2kTdzJVG4TxaYtw+Ip3gQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=sourceware.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uaf+OmSL0nsE7a9WVB7+POeS80rwqml9buBtOxcfgjU=; b=1DReUBOwfXPBU8n9UQOqMj8MAthhWO0OxzRf7XMzx/EPojPQkDCNXuNlEzvBw+X7l9unBwOFcUolkYBxurAGnt091+dUMpkcIHznFGVEkdlUs2TFOi79SZ39+T7CHekqEUjFbf+IRrvH7mPUXiwz49JpmPRTX7KdVvtLYAMXtZU= Received: from BL1PR13CA0097.namprd13.prod.outlook.com (2603:10b6:208:2b9::12) by DM4PR12MB6134.namprd12.prod.outlook.com (2603:10b6:8:ad::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.27; Tue, 21 Nov 2023 12:05:51 +0000 Received: from MN1PEPF0000F0E3.namprd04.prod.outlook.com (2603:10b6:208:2b9:cafe::42) by BL1PR13CA0097.outlook.office365.com (2603:10b6:208:2b9::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.17 via Frontend Transport; Tue, 21 Nov 2023 12:05:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MN1PEPF0000F0E3.mail.protection.outlook.com (10.167.242.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7025.12 via Frontend Transport; Tue, 21 Nov 2023 12:05:51 +0000 Received: from hpe6u-23.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Tue, 21 Nov 2023 06:05:50 -0600 From: Lancelot Six To: CC: , , Lancelot Six Subject: [COMMITTED PATCH v2 3/9] gdbsupport: remove gdb::optional Date: Tue, 21 Nov 2023 12:04:54 +0000 Message-ID: <20231121120500.1394523-4-lancelot.six@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028204821.fp5hh7bahrmrnpjl@hpe6u-23> References: <20231028204821.fp5hh7bahrmrnpjl@hpe6u-23> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000F0E3:EE_|DM4PR12MB6134:EE_ X-MS-Office365-Filtering-Correlation-Id: 3c05317f-641f-48eb-ce2b-08dbea8a34b0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hqZRQU60YNJSkdoOIjZzlnzUKI6yqxZQBqBiDGirDOp23rcZxX0W1AcrB1ApYRexUJNl+wAb+B/ijgQcWZxdJMGH7l/Xnn/HSRKcleAs7Ddl20S4xfSaDmPWaHu+0AHyQlhXGX1zO/KlxvHyiq2Bwj+IYJCydphnwuSZUTX8/ml/0YLyF9Zby0pzKGzDNJOH3WqbzjksbKf6t1sd+3F0SnGbNhdQ729EBygIey03ZlPLZc4B4OnAP6YaCnCqzWn35bNgtmqSAjboWeCsBubRNXSJtj3G05nGytnfBVD8nzTqJ8HdfKhnX2JZM6RUxeChWHfATb82jVcZzerFg3P0M+WLaqHhJgil0NzshKjJ7pwEVDgtR7XmO+d1fLJ6+9CCpDbptMvK+OOv+SQAlEX32Sdlqg7I1E0OKwT+sI/lwsmPvGjpNAlMcrzc7rCjrmTRdjK6iscK45wfij6Jw2TqXjiIoE+lUh/XlrCaRisC2+SqCnpF6cPMTr0fBHPA7fiwksF2+T23d03wFsXGhAmIQiuFk2dAzmqbZDJqWXrvQqi6rTYbBDwlJMZdPID5y9MN+I24oh1/T+zN0RgEifcbYk3AcdAeVVuIgs0SIwIIi3afpyaxu528oVYGsHaXXfz+5Q2IIYKaxeS9jyrcQlY2fLnry4nO1Amq5GKQOvpqYXoinSNF6fUKiX+x4BGxe+nYQ9477j8lrPukdbV2AHNlpUBLTJp9mEeUp9AdXXjFK3yAIZkv92mL3Yz1WkvNNVOwRI7ZnNYuIxXAQs2tg9fmhCihNHebwnx4ITozlQLnhXMYdLkY5c52Ck+OGdoI8r9cBDv4G13/mfNgDXjSY38nQA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(346002)(396003)(39860400002)(376002)(136003)(230273577357003)(230173577357003)(230922051799003)(451199024)(186009)(1800799012)(64100799003)(82310400011)(46966006)(40470700004)(36840700001)(356005)(41300700001)(81166007)(30864003)(36860700001)(2906002)(7696005)(82740400003)(5660300002)(86362001)(44832011)(47076005)(36756003)(478600001)(8936002)(4326008)(8676002)(2616005)(40480700001)(6916009)(54906003)(70586007)(316002)(70206006)(1076003)(83380400001)(26005)(16526019)(40460700003)(336012)(426003)(2004002)(36900700001)(559001)(579004); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 12:05:51.3133 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3c05317f-641f-48eb-ce2b-08dbea8a34b0 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MN1PEPF0000F0E3.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6134 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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: 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+patchwork=sourceware.org@sourceware.org The previous patch migrated all the uses of gdb::optional to use std::optional instead, so gdb::optional can be removed entirely as well as the self-tests which came with it. Change-Id: I96ecd67b850b01be10ef00eb85a78ac647d5adc7 Approved-By: Tom Tromey Approved-By: Pedro Alves --- gdb/Makefile.in | 1 - gdb/unittests/optional-selftests.c | 95 -------- gdb/unittests/optional/assignment/1.cc | 196 ---------------- gdb/unittests/optional/assignment/2.cc | 194 ---------------- gdb/unittests/optional/assignment/3.cc | 157 ------------- gdb/unittests/optional/assignment/4.cc | 157 ------------- gdb/unittests/optional/assignment/5.cc | 81 ------- gdb/unittests/optional/assignment/6.cc | 91 -------- gdb/unittests/optional/assignment/7.cc | 30 --- gdb/unittests/optional/cons/copy.cc | 127 ----------- gdb/unittests/optional/cons/default.cc | 59 ----- gdb/unittests/optional/cons/move.cc | 125 ----------- gdb/unittests/optional/cons/value.cc | 295 ------------------------- gdb/unittests/optional/in_place.cc | 66 ------ gdb/unittests/optional/observers/1.cc | 32 --- gdb/unittests/optional/observers/2.cc | 36 --- gdbsupport/gdb_optional.h | 233 ------------------- 17 files changed, 1975 deletions(-) delete mode 100644 gdb/unittests/optional-selftests.c delete mode 100644 gdb/unittests/optional/assignment/1.cc delete mode 100644 gdb/unittests/optional/assignment/2.cc delete mode 100644 gdb/unittests/optional/assignment/3.cc delete mode 100644 gdb/unittests/optional/assignment/4.cc delete mode 100644 gdb/unittests/optional/assignment/5.cc delete mode 100644 gdb/unittests/optional/assignment/6.cc delete mode 100644 gdb/unittests/optional/assignment/7.cc delete mode 100644 gdb/unittests/optional/cons/copy.cc delete mode 100644 gdb/unittests/optional/cons/default.cc delete mode 100644 gdb/unittests/optional/cons/move.cc delete mode 100644 gdb/unittests/optional/cons/value.cc delete mode 100644 gdb/unittests/optional/in_place.cc delete mode 100644 gdb/unittests/optional/observers/1.cc delete mode 100644 gdb/unittests/optional/observers/2.cc delete mode 100644 gdbsupport/gdb_optional.h diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 52b08692b52..714564f27b4 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -469,7 +469,6 @@ SELFTESTS_SRCS = \ unittests/memrange-selftests.c \ unittests/offset-type-selftests.c \ unittests/observable-selftests.c \ - unittests/optional-selftests.c \ unittests/packed-selftests.c \ unittests/parallel-for-selftests.c \ unittests/parse-connection-spec-selftests.c \ diff --git a/gdb/unittests/optional-selftests.c b/gdb/unittests/optional-selftests.c deleted file mode 100644 index 51135b8b98c..00000000000 --- a/gdb/unittests/optional-selftests.c +++ /dev/null @@ -1,95 +0,0 @@ -/* Self tests for optional for GDB, the GNU debugger. - - Copyright (C) 2017-2023 Free Software Foundation, Inc. - - This file is part of GDB. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include "defs.h" -#include "gdbsupport/selftest.h" -#include "gdbsupport/gdb_optional.h" - -/* Used by the included .cc files below. Included here because the - included test files are wrapped in a namespace. */ -#include -#include -#include - -/* libstdc++'s testsuite uses VERIFY. */ -#define VERIFY SELF_CHECK - -/* Used to disable testing features not supported by - std::optional. */ -#define GDB_OPTIONAL - -namespace selftests { -namespace optional { - -/* The actual tests live in separate files, which were originally - copied over from libstdc++'s testsuite. To preserve the structure - and help with comparison with the original tests, the file names - have been preserved, and only minimal modification was done to have - them compile against std::optional instead of std::optional: - - - std::optional->gdb:optional, etc. - - ATTRIBUTE_UNUSED in a few places - - wrap each file in a namespace so they can all be compiled as a - single unit. - - libstdc++'s license and formatting style was preserved. -*/ - -#include "optional/assignment/1.cc" -#include "optional/assignment/2.cc" -#include "optional/assignment/3.cc" -#include "optional/assignment/4.cc" -#include "optional/assignment/5.cc" -#include "optional/assignment/6.cc" -#include "optional/assignment/7.cc" -#include "optional/cons/copy.cc" -#include "optional/cons/default.cc" -#include "optional/cons/move.cc" -#include "optional/cons/value.cc" -#include "optional/in_place.cc" -#include "optional/observers/1.cc" -#include "optional/observers/2.cc" - -static void -run_tests () -{ - assign_1::test (); - assign_2::test (); - assign_3::test (); - assign_4::test (); - assign_5::test (); - assign_6::test (); - assign_7::test (); - cons_copy::test (); - cons_default::test (); - cons_move::test (); - cons_value::test (); - in_place::test (); - observers_1::test (); - observers_2::test (); -} - -} /* namespace optional */ -} /* namespace selftests */ - -void _initialize_optional_selftests (); -void -_initialize_optional_selftests () -{ - selftests::register_test ("optional", selftests::optional::run_tests); -} diff --git a/gdb/unittests/optional/assignment/1.cc b/gdb/unittests/optional/assignment/1.cc deleted file mode 100644 index 6a68f7d4002..00000000000 --- a/gdb/unittests/optional/assignment/1.cc +++ /dev/null @@ -1,196 +0,0 @@ -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -namespace assign_1 { - -struct exception {}; - -static int counter = 0; - -struct mixin_counter -{ - mixin_counter() { ++counter; } - mixin_counter(mixin_counter const&) { ++counter; } - ~mixin_counter() { --counter; } -}; - -struct value_type : private mixin_counter -{ - enum state_type - { - zero, - moved_from, - throwing_construction, - throwing_copy, - throwing_copy_assignment, - throwing_move, - throwing_move_assignment, - threw, - }; - - value_type() = default; - - explicit value_type(state_type state_) - : state(state_) - { - throw_if(throwing_construction); - } - - value_type(value_type const& other) - : state(other.state) - { - throw_if(throwing_copy); - } - - value_type& - operator=(value_type const& other) - { - state = other.state; - throw_if(throwing_copy_assignment); - return *this; - } - - value_type(value_type&& other) - : state(other.state) - { - other.state = moved_from; - throw_if(throwing_move); - } - - value_type& - operator=(value_type&& other) - { - state = other.state; - other.state = moved_from; - throw_if(throwing_move_assignment); - return *this; - } - - void throw_if(state_type match) - { - if(state == match) - { - state = threw; - throw exception {}; - } - } - - state_type state = zero; -}; - -static void -test () -{ - using O = gdb::optional; - using S = value_type::state_type; - auto const make = [](S s = S::zero) { return O { gdb::in_place, s }; }; - - enum outcome_type { nothrow, caught, bad_catch }; - - // Check copy/move assignment for disengaged optional - - // From disengaged optional - { - O o; - VERIFY( !o ); - O p; - o = p; - VERIFY( !o ); - VERIFY( !p ); - } - - { - O o; - VERIFY( !o ); - O p; - o = std::move(p); - VERIFY( !o ); - VERIFY( !p ); - } - -#ifndef GDB_OPTIONAL - { - O o; - VERIFY( !o ); - o = {}; - VERIFY( !o ); - } -#endif - - // From engaged optional - { - O o; - VERIFY( !o ); - O p = make(S::throwing_copy_assignment); - o = p; - VERIFY( o && o->state == S::throwing_copy_assignment ); - VERIFY( p && p->state == S::throwing_copy_assignment ); - } - - { - O o; - VERIFY( !o ); - O p = make(S::throwing_move_assignment); - o = std::move(p); - VERIFY( o && o->state == S::throwing_move_assignment ); - VERIFY( p && p->state == S::moved_from ); - } - - { - outcome_type outcome {}; - O o; - VERIFY( !o ); - O p = make(S::throwing_copy); - - try - { - o = p; - } - catch(exception const&) - { outcome = caught; } - catch(...) - { outcome = bad_catch; } - - VERIFY( outcome == caught ); - VERIFY( !o ); - VERIFY( p && p->state == S::throwing_copy ); - } - - { - outcome_type outcome {}; - O o; - VERIFY( !o ); - O p = make(S::throwing_move); - - try - { - o = std::move(p); - } - catch(exception const&) - { outcome = caught; } - catch(...) - { outcome = bad_catch; } - - VERIFY( outcome == caught ); - VERIFY( !o ); - VERIFY( p && p->state == S::moved_from ); - } - - VERIFY( counter == 0 ); -} - -} // namespace assign_1 diff --git a/gdb/unittests/optional/assignment/2.cc b/gdb/unittests/optional/assignment/2.cc deleted file mode 100644 index 2e63a491920..00000000000 --- a/gdb/unittests/optional/assignment/2.cc +++ /dev/null @@ -1,194 +0,0 @@ -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -namespace assign_2 { - -struct exception {}; - -static int counter = 0; - -struct mixin_counter -{ - mixin_counter() { ++counter; } - mixin_counter(mixin_counter const&) { ++counter; } - ~mixin_counter() { --counter; } -}; - -struct value_type : private mixin_counter -{ - enum state_type - { - zero, - moved_from, - throwing_construction, - throwing_copy, - throwing_copy_assignment, - throwing_move, - throwing_move_assignment, - threw, - }; - - value_type() = default; - - explicit value_type(state_type state_) - : state(state_) - { - throw_if(throwing_construction); - } - - value_type(value_type const& other) - : state(other.state) - { - throw_if(throwing_copy); - } - - value_type& - operator=(value_type const& other) - { - state = other.state; - throw_if(throwing_copy_assignment); - return *this; - } - - value_type(value_type&& other) - : state(other.state) - { - other.state = moved_from; - throw_if(throwing_move); - } - - value_type& - operator=(value_type&& other) - { - state = other.state; - other.state = moved_from; - throw_if(throwing_move_assignment); - return *this; - } - - void throw_if(state_type match) - { - if(state == match) - { - state = threw; - throw exception {}; - } - } - - state_type state = zero; -}; - -static void -test () -{ - using O = gdb::optional; - using S = value_type::state_type; - auto const make = [](S s = S::zero) { return O { gdb::in_place, s }; }; - - enum outcome_type { nothrow, caught, bad_catch }; - - // Check copy/move assignment for engaged optional - - // From disengaged optional - { - O o = make(S::zero); - VERIFY( o ); - O p; - o = p; - VERIFY( !o ); - VERIFY( !p ); - } - - { - O o = make(S::zero); - VERIFY( o ); - O p; - o = std::move(p); - VERIFY( !o ); - VERIFY( !p ); - } - -#ifndef GDB_OPTIONAL - { - O o = make(S::zero); - VERIFY( o ); - o = {}; - VERIFY( !o ); - } -#endif - - // From engaged optional - { - O o = make(S::zero); - VERIFY( o ); - O p = make(S::throwing_copy); - o = p; - VERIFY( o && o->state == S::throwing_copy); - VERIFY( p && p->state == S::throwing_copy); - } - - { - O o = make(S::zero); - VERIFY( o ); - O p = make(S::throwing_move); - o = std::move(p); - VERIFY( o && o->state == S::throwing_move); - VERIFY( p && p->state == S::moved_from); - } - - { - ATTRIBUTE_UNUSED outcome_type outcome {}; - O o = make(S::zero); - VERIFY( o ); - O p = make(S::throwing_copy_assignment); - - try - { - o = p; - } - catch(exception const&) - { outcome = caught; } - catch(...) - { outcome = bad_catch; } - - VERIFY( o && o->state == S::threw); - VERIFY( p && p->state == S::throwing_copy_assignment); - } - - { - ATTRIBUTE_UNUSED outcome_type outcome {}; - O o = make(S::zero); - VERIFY( o ); - O p = make(S::throwing_move_assignment); - - try - { - o = std::move(p); - } - catch(exception const&) - { outcome = caught; } - catch(...) - { outcome = bad_catch; } - - VERIFY( o && o->state == S::threw); - VERIFY( p && p->state == S::moved_from); - } - - VERIFY( counter == 0 ); -} - -} // namespace assign_2 diff --git a/gdb/unittests/optional/assignment/3.cc b/gdb/unittests/optional/assignment/3.cc deleted file mode 100644 index a1d0934fe79..00000000000 --- a/gdb/unittests/optional/assignment/3.cc +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -namespace assign_3 { - -struct exception {}; - -static int counter = 0; - -struct mixin_counter -{ - mixin_counter() { ++counter; } - mixin_counter(mixin_counter const&) { ++counter; } - ~mixin_counter() { --counter; } -}; - -struct value_type : private mixin_counter -{ - enum state_type - { - zero, - moved_from, - throwing_construction, - throwing_copy, - throwing_copy_assignment, - throwing_move, - throwing_move_assignment, - threw, - }; - - value_type() = default; - - explicit value_type(state_type state_) - : state(state_) - { - throw_if(throwing_construction); - } - - value_type(value_type const& other) - : state(other.state) - { - throw_if(throwing_copy); - } - - value_type& - operator=(value_type const& other) - { - state = other.state; - throw_if(throwing_copy_assignment); - return *this; - } - - value_type(value_type&& other) - : state(other.state) - { - other.state = moved_from; - throw_if(throwing_move); - } - - value_type& - operator=(value_type&& other) - { - state = other.state; - other.state = moved_from; - throw_if(throwing_move_assignment); - return *this; - } - - void throw_if(state_type match) - { - if(state == match) - { - state = threw; - throw exception {}; - } - } - - state_type state = zero; -}; - -static void -test () -{ - using O = gdb::optional; - using S = value_type::state_type; - auto const make = [](S s = S::zero) { return value_type { s }; }; - - enum outcome_type { nothrow, caught, bad_catch }; - - // Check value assignment for disengaged optional - - { - O o; - value_type v = make(S::throwing_copy_assignment); - o = v; - VERIFY( o && o->state == S::throwing_copy_assignment ); - } - - { - O o; - value_type v = make(S::throwing_move_assignment); - o = std::move(v); - VERIFY( o && o->state == S::throwing_move_assignment ); - } - - { - ATTRIBUTE_UNUSED outcome_type outcome {}; - O o; - value_type v = make(S::throwing_copy); - - try - { - o = v; - } - catch(exception const&) - { outcome = caught; } - catch(...) - { outcome = bad_catch; } - - VERIFY( !o ); - } - - { - ATTRIBUTE_UNUSED outcome_type outcome {}; - O o; - value_type v = make(S::throwing_move); - - try - { - o = std::move(v); - } - catch(exception const&) - { outcome = caught; } - catch(...) - { outcome = bad_catch; } - - VERIFY( !o ); - } - - VERIFY( counter == 0 ); -} - -} // namespace assign_3 diff --git a/gdb/unittests/optional/assignment/4.cc b/gdb/unittests/optional/assignment/4.cc deleted file mode 100644 index 2ad5978a5b4..00000000000 --- a/gdb/unittests/optional/assignment/4.cc +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -namespace assign_4 { - -struct exception {}; - -static int counter = 0; - -struct mixin_counter -{ - mixin_counter() { ++counter; } - mixin_counter(mixin_counter const&) { ++counter; } - ~mixin_counter() { --counter; } -}; - -struct value_type : private mixin_counter -{ - enum state_type - { - zero, - moved_from, - throwing_construction, - throwing_copy, - throwing_copy_assignment, - throwing_move, - throwing_move_assignment, - threw, - }; - - value_type() = default; - - explicit value_type(state_type state_) - : state(state_) - { - throw_if(throwing_construction); - } - - value_type(value_type const& other) - : state(other.state) - { - throw_if(throwing_copy); - } - - value_type& - operator=(value_type const& other) - { - state = other.state; - throw_if(throwing_copy_assignment); - return *this; - } - - value_type(value_type&& other) - : state(other.state) - { - other.state = moved_from; - throw_if(throwing_move); - } - - value_type& - operator=(value_type&& other) - { - state = other.state; - other.state = moved_from; - throw_if(throwing_move_assignment); - return *this; - } - - void throw_if(state_type match) - { - if(state == match) - { - state = threw; - throw exception {}; - } - } - - state_type state = zero; -}; - -static void -test () -{ - using O = gdb::optional; - using S = value_type::state_type; - auto const make = [](S s = S::zero) { return value_type { s }; }; - - enum outcome_type { nothrow, caught, bad_catch }; - - // Check value assignment for engaged optional - - { - O o = make(); - value_type v = make(S::throwing_copy); - o = v; - VERIFY( o && o->state == S::throwing_copy); - } - - { - O o = make(); - value_type v = make(S::throwing_move); - o = std::move(v); - VERIFY( o && o->state == S::throwing_move); - } - - { - ATTRIBUTE_UNUSED outcome_type outcome {}; - O o = make(); - value_type v = make(S::throwing_copy_assignment); - - try - { - o = v; - } - catch(exception const&) - { outcome = caught; } - catch(...) - { outcome = bad_catch; } - - VERIFY( o && o->state == S::threw ); - } - - { - ATTRIBUTE_UNUSED outcome_type outcome {}; - O o = make(); - value_type v = make(S::throwing_move_assignment); - - try - { - o = std::move(v); - } - catch(exception const&) - { outcome = caught; } - catch(...) - { outcome = bad_catch; } - - VERIFY( o && o->state == S::threw ); - } - - VERIFY( counter == 0 ); -} - -} // namespace assign_4 diff --git a/gdb/unittests/optional/assignment/5.cc b/gdb/unittests/optional/assignment/5.cc deleted file mode 100644 index 85016a27bfa..00000000000 --- a/gdb/unittests/optional/assignment/5.cc +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -namespace assign_5 { - -static int counter = 0; - -struct mixin_counter -{ - mixin_counter() { ++counter; } - mixin_counter(mixin_counter const&) { ++counter; } - ~mixin_counter() { --counter; } -}; - -struct value_type : private mixin_counter { }; - -static void -test () -{ - using O = gdb::optional; - - // Check std::nullopt_t and 'default' (= {}) assignment - -#ifndef GDB_OPTIONAL - { - O o; - o = std::nullopt; - VERIFY( !o ); - } -#endif - -#ifndef GDB_OPTIONAL - { - O o { gdb::in_place }; - o = std::nullopt; - VERIFY( !o ); - } -#endif - -#ifndef GDB_OPTIONAL - { - O o; - o = {}; - VERIFY( !o ); - } -#endif - -#ifndef GDB_OPTIONAL - { - O o { gdb::in_place }; - o = {}; - VERIFY( !o ); - } -#endif - { - gdb::optional> ovi{{1, 2, 3}}; - VERIFY(ovi->size() == 3); - VERIFY((*ovi)[0] == 1 && (*ovi)[1] == 2 && (*ovi)[2] == 3); - ovi = {4, 5, 6, 7}; - VERIFY(ovi->size() == 4); - VERIFY((*ovi)[0] == 4 && (*ovi)[1] == 5 && - (*ovi)[2] == 6 && (*ovi)[3] == 7); - } - VERIFY( counter == 0 ); -} - -} // namespace assign_5 diff --git a/gdb/unittests/optional/assignment/6.cc b/gdb/unittests/optional/assignment/6.cc deleted file mode 100644 index d0ea95fa556..00000000000 --- a/gdb/unittests/optional/assignment/6.cc +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -namespace assign_6 { - -static int counter = 0; - -struct mixin_counter -{ - mixin_counter() { ++counter; } - mixin_counter(mixin_counter const&) { ++counter; } - ~mixin_counter() { --counter; } -}; - -struct value_type : private mixin_counter -{ - value_type() = default; - value_type(int) : state(1) { } - value_type(std::initializer_list, const char*) : state(2) { } - int state = 0; -}; - -static void -test () -{ - using O = gdb::optional; - - // Check emplace - - { - O o; - o.emplace(); - VERIFY( o && o->state == 0 ); - } - { - O o { gdb::in_place, 0 }; - o.emplace(); - VERIFY( o && o->state == 0 ); - } - - { - O o; - o.emplace(0); - VERIFY( o && o->state == 1 ); - } - { - O o { gdb::in_place }; - o.emplace(0); - VERIFY( o && o->state == 1 ); - } - -#ifndef GDB_OPTIONAL - { - O o; - o.emplace({ 'a' }, ""); - VERIFY( o && o->state == 2 ); - } - { - O o { gdb::in_place }; - o.emplace({ 'a' }, ""); - VERIFY( o && o->state == 2 ); - } -#endif - { - O o; - VERIFY(&o.emplace(0) == &*o); -#ifndef GDB_OPTIONAL - VERIFY(&o.emplace({ 'a' }, "") == &*o); -#endif - } - - static_assert( !std::is_constructible, int>(), "" ); - - VERIFY( counter == 0 ); -} - -} // namespace assign_6 diff --git a/gdb/unittests/optional/assignment/7.cc b/gdb/unittests/optional/assignment/7.cc deleted file mode 100644 index a9bd181e317..00000000000 --- a/gdb/unittests/optional/assignment/7.cc +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2016-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -namespace assign_7 { - -static void -test () -{ - gdb::optional o{666}; - VERIFY(o && *o == 666); - o.reset(); - VERIFY(!o); - static_assert(noexcept(std::declval>().reset()), ""); -} - -} // namespace assign_7 diff --git a/gdb/unittests/optional/cons/copy.cc b/gdb/unittests/optional/cons/copy.cc deleted file mode 100644 index 87a08f9a52b..00000000000 --- a/gdb/unittests/optional/cons/copy.cc +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -namespace cons_copy { - -struct tracker -{ - tracker(int value) : value(value) { ++count; } - ~tracker() { --count; } - - tracker(tracker const& other) : value(other.value) { ++count; } - tracker(tracker&& other) : value(other.value) - { - other.value = -1; - ++count; - } - - tracker& operator=(tracker const&) = default; - tracker& operator=(tracker&&) = default; - - int value; - - static int count; -}; - -int tracker::count = 0; - -struct exception { }; - -struct throwing_copy -{ - throwing_copy() = default; - throwing_copy(throwing_copy const&) { throw exception {}; } -}; - -static void -test () -{ - // [20.5.4.1] Constructors - - { - gdb::optional o; - auto copy = o; - VERIFY( !copy ); - VERIFY( !o ); - } - - { - const long val = 0x1234ABCD; - gdb::optional o { gdb::in_place, val}; - auto copy = o; - VERIFY( copy ); - VERIFY( *copy == val ); -#ifndef GDB_OPTIONAL - VERIFY( o && o == val ); -#endif - } - - { - gdb::optional o; - auto copy = o; - VERIFY( !copy ); - VERIFY( tracker::count == 0 ); - VERIFY( !o ); - } - - { - gdb::optional o { gdb::in_place, 333 }; - auto copy = o; - VERIFY( copy ); - VERIFY( copy->value == 333 ); - VERIFY( tracker::count == 2 ); - VERIFY( o && o->value == 333 ); - } - - enum outcome { nothrow, caught, bad_catch }; - - { - outcome result = nothrow; - gdb::optional o; - - try - { - auto copy = o; - } - catch(exception const&) - { result = caught; } - catch(...) - { result = bad_catch; } - - VERIFY( result == nothrow ); - } - - { - outcome result = nothrow; - gdb::optional o { gdb::in_place }; - - try - { - auto copy = o; - } - catch(exception const&) - { result = caught; } - catch(...) - { result = bad_catch; } - - VERIFY( result == caught ); - } - - VERIFY( tracker::count == 0 ); -} - -} // namespace cons_copy diff --git a/gdb/unittests/optional/cons/default.cc b/gdb/unittests/optional/cons/default.cc deleted file mode 100644 index 6ed99c3b9e5..00000000000 --- a/gdb/unittests/optional/cons/default.cc +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -namespace cons_default { - -struct tracker -{ - tracker() { ++count; } - ~tracker() { --count; } - - tracker(tracker const&) { ++count; } - tracker(tracker&&) { ++count; } - - tracker& operator=(tracker const&) = default; - tracker& operator=(tracker&&) = default; - - static int count; -}; - -int tracker::count = 0; - -static void -test () -{ - // [20.5.4.1] Constructors - - { - gdb::optional o; - VERIFY( !o ); - } - - { - gdb::optional o {}; - VERIFY( !o ); - } - - { - gdb::optional o = {}; - VERIFY( !o ); - } - - VERIFY( tracker::count == 0 ); -} - -} // namespace cons_default diff --git a/gdb/unittests/optional/cons/move.cc b/gdb/unittests/optional/cons/move.cc deleted file mode 100644 index 398784ae7ec..00000000000 --- a/gdb/unittests/optional/cons/move.cc +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -namespace cons_move { - -struct tracker -{ - tracker(int value) : value(value) { ++count; } - ~tracker() { --count; } - - tracker(tracker const& other) : value(other.value) { ++count; } - tracker(tracker&& other) : value(other.value) - { - other.value = -1; - ++count; - } - - tracker& operator=(tracker const&) = default; - tracker& operator=(tracker&&) = default; - - int value; - - static int count; -}; - -int tracker::count = 0; - -struct exception { }; - -struct throwing_move -{ - throwing_move() = default; - throwing_move(throwing_move const&) { throw exception {}; } -}; - -static void -test () -{ - // [20.5.4.1] Constructors - - { - gdb::optional o; - auto moved_to = std::move(o); - VERIFY( !moved_to ); - VERIFY( !o ); - } - - { - const long val = 0x1234ABCD; - gdb::optional o { gdb::in_place, val}; - auto moved_to = std::move(o); - VERIFY( moved_to ); - VERIFY( *moved_to == val ); - VERIFY( o && *o == val ); - } - - { - gdb::optional o; - auto moved_to = std::move(o); - VERIFY( !moved_to ); - VERIFY( tracker::count == 0 ); - VERIFY( !o ); - } - - { - gdb::optional o { gdb::in_place, 333 }; - auto moved_to = std::move(o); - VERIFY( moved_to ); - VERIFY( moved_to->value == 333 ); - VERIFY( tracker::count == 2 ); - VERIFY( o && o->value == -1 ); - } - - enum outcome { nothrow, caught, bad_catch }; - - { - outcome result = nothrow; - gdb::optional o; - - try - { - auto moved_to = std::move(o); - } - catch(exception const&) - { result = caught; } - catch(...) - { result = bad_catch; } - - VERIFY( result == nothrow ); - } - - { - outcome result = nothrow; - gdb::optional o { gdb::in_place }; - - try - { - auto moved_to = std::move(o); - } - catch(exception const&) - { result = caught; } - catch(...) - { result = bad_catch; } - - VERIFY( result == caught ); - } - - VERIFY( tracker::count == 0 ); -} - -} // namespace cons_move diff --git a/gdb/unittests/optional/cons/value.cc b/gdb/unittests/optional/cons/value.cc deleted file mode 100644 index 7d4fd91cfe6..00000000000 --- a/gdb/unittests/optional/cons/value.cc +++ /dev/null @@ -1,295 +0,0 @@ -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -namespace cons_value { - -struct tracker -{ - tracker(int value) : value(value) { ++count; } - ~tracker() { --count; } - - tracker(tracker const& other) : value(other.value) { ++count; } - tracker(tracker&& other) : value(other.value) - { - other.value = -1; - ++count; - } - - tracker& operator=(tracker const&) = default; - tracker& operator=(tracker&&) = default; - - int value; - - static int count; -}; - -int tracker::count = 0; - -struct exception { }; - -struct throwing_construction -{ - explicit throwing_construction(bool propagate) : propagate(propagate) { } - - throwing_construction(throwing_construction const& other) - : propagate(other.propagate) - { - if(propagate) - throw exception {}; - } - - bool propagate; -}; - -static void -test () -{ - // [20.5.4.1] Constructors - - { - auto i = 0x1234ABCD; - gdb::optional o { i }; - VERIFY( o ); - VERIFY( *o == 0x1234ABCD ); - VERIFY( i == 0x1234ABCD ); - } - - { - auto i = 0x1234ABCD; - gdb::optional o = i; - VERIFY( o ); - VERIFY( *o == 0x1234ABCD ); - VERIFY( i == 0x1234ABCD ); - } - - { - auto i = 0x1234ABCD; - gdb::optional o = { i }; - VERIFY( o ); - VERIFY( *o == 0x1234ABCD ); - VERIFY( i == 0x1234ABCD ); - } - - { - auto i = 0x1234ABCD; - gdb::optional o { std::move(i) }; - VERIFY( o ); - VERIFY( *o == 0x1234ABCD ); - VERIFY( i == 0x1234ABCD ); - } - - { - auto i = 0x1234ABCD; - gdb::optional o = std::move(i); - VERIFY( o ); - VERIFY( *o == 0x1234ABCD ); - VERIFY( i == 0x1234ABCD ); - } - - { - auto i = 0x1234ABCD; - gdb::optional o = { std::move(i) }; - VERIFY( o ); - VERIFY( *o == 0x1234ABCD ); - VERIFY( i == 0x1234ABCD ); - } - -#ifndef GDB_OPTIONAL - { - std::vector v = { 0, 1, 2, 3, 4, 5 }; - gdb::optional> o { v }; - VERIFY( !v.empty() ); - VERIFY( o->size() == 6 ); - } -#endif - - { - std::vector v = { 0, 1, 2, 3, 4, 5 }; - gdb::optional> o = v; - VERIFY( !v.empty() ); - VERIFY( o->size() == 6 ); - } - - { - std::vector v = { 0, 1, 2, 3, 4, 5 }; - gdb::optional> o { v }; - VERIFY( !v.empty() ); - VERIFY( o->size() == 6 ); - } - - { - std::vector v = { 0, 1, 2, 3, 4, 5 }; - gdb::optional> o { std::move(v) }; - VERIFY( v.empty() ); - VERIFY( o->size() == 6 ); - } - - { - std::vector v = { 0, 1, 2, 3, 4, 5 }; - gdb::optional> o = std::move(v); - VERIFY( v.empty() ); - VERIFY( o->size() == 6 ); - } - - { - std::vector v = { 0, 1, 2, 3, 4, 5 }; - gdb::optional> o { std::move(v) }; - VERIFY( v.empty() ); - VERIFY( o->size() == 6 ); - } - - { - tracker t { 333 }; - gdb::optional o = t; - VERIFY( o->value == 333 ); - VERIFY( tracker::count == 2 ); - VERIFY( t.value == 333 ); - } - - { - tracker t { 333 }; - gdb::optional o = std::move(t); - VERIFY( o->value == 333 ); - VERIFY( tracker::count == 2 ); - VERIFY( t.value == -1 ); - } - - enum outcome { nothrow, caught, bad_catch }; - - { - outcome result = nothrow; - throwing_construction t { false }; - - try - { - gdb::optional o { t }; - } - catch(exception const&) - { result = caught; } - catch(...) - { result = bad_catch; } - - VERIFY( result == nothrow ); - } - - { - outcome result = nothrow; - throwing_construction t { true }; - - try - { - gdb::optional o { t }; - } - catch(exception const&) - { result = caught; } - catch(...) - { result = bad_catch; } - - VERIFY( result == caught ); - } - - { - outcome result = nothrow; - throwing_construction t { false }; - - try - { - gdb::optional o { std::move(t) }; - } - catch(exception const&) - { result = caught; } - catch(...) - { result = bad_catch; } - - VERIFY( result == nothrow ); - } - - { - outcome result = nothrow; - throwing_construction t { true }; - - try - { - gdb::optional o { std::move(t) }; - } - catch(exception const&) - { result = caught; } - catch(...) - { result = bad_catch; } - - VERIFY( result == caught ); - } - - { -#ifndef GDB_OPTIONAL - gdb::optional os = "foo"; -#endif - struct X - { - explicit X(int) {} - X& operator=(int) {return *this;} - }; -#ifndef GDB_OPTIONAL - gdb::optional ox{42}; -#endif - gdb::optional oi{42}; -#ifndef GDB_OPTIONAL - gdb::optional ox2{oi}; -#endif - gdb::optional os2; - os2 = "foo"; -#ifndef GDB_OPTIONAL - gdb::optional ox3; - ox3 = 42; - gdb::optional ox4; - ox4 = oi; -#endif - } - { - // no converting construction. -#ifndef GDB_OPTIONAL - gdb::optional oi = gdb::optional(); - VERIFY(!bool(oi)); - gdb::optional os = gdb::optional(); - VERIFY(!bool(os)); -#endif - gdb::optional> ooi = gdb::optional(); - VERIFY(bool(ooi)); - ooi = gdb::optional(); - VERIFY(bool(ooi)); - ooi = gdb::optional(42); - VERIFY(bool(ooi)); - VERIFY(bool(*ooi)); -#ifndef GDB_OPTIONAL - gdb::optional> ooi2 = gdb::optional(); - VERIFY(bool(ooi2)); - ooi2 = gdb::optional(); - VERIFY(bool(ooi2)); - ooi2 = gdb::optional(6); - VERIFY(bool(ooi2)); - VERIFY(bool(*ooi2)); - gdb::optional> ooi3 = gdb::optional(42); - VERIFY(bool(ooi3)); - VERIFY(bool(*ooi3)); - gdb::optional> ooi4 = gdb::optional(6); - VERIFY(bool(ooi4)); - VERIFY(bool(*ooi4)); -#endif - } -} - -} // namespace cons_value diff --git a/gdb/unittests/optional/in_place.cc b/gdb/unittests/optional/in_place.cc deleted file mode 100644 index 067f975a0d3..00000000000 --- a/gdb/unittests/optional/in_place.cc +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -namespace in_place { - -static void -test () -{ - // [20.5.5] In-place construction - { - gdb::optional o { gdb::in_place }; - VERIFY( o ); - VERIFY( *o == int() ); - -#ifndef GDB_OPTIONAL - static_assert( !std::is_convertible>(), "" ); -#endif - } - - { - gdb::optional o { gdb::in_place, 42 }; - VERIFY( o ); - VERIFY( *o == 42 ); - } - - { - gdb::optional> o { gdb::in_place, 18, 4 }; - VERIFY( o ); - VERIFY( o->size() == 18 ); - VERIFY( (*o)[17] == 4 ); - } - -#ifndef GDB_OPTIONAL - { - gdb::optional> o { gdb::in_place, { 18, 4 } }; - VERIFY( o ); - VERIFY( o->size() == 2 ); - VERIFY( (*o)[0] == 18 ); - } -#endif - -#ifndef GDB_OPTIONAL - { - gdb::optional> o { gdb::in_place, { 18, 4 }, std::allocator {} }; - VERIFY( o ); - VERIFY( o->size() == 2 ); - VERIFY( (*o)[0] == 18 ); - } -#endif -} - -} // namespace in_place diff --git a/gdb/unittests/optional/observers/1.cc b/gdb/unittests/optional/observers/1.cc deleted file mode 100644 index 20f4176adf1..00000000000 --- a/gdb/unittests/optional/observers/1.cc +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -namespace observers_1 { - -struct value_type -{ - int i; -}; - -static void -test () -{ - gdb::optional o { value_type { 51 } }; - VERIFY( (*o).i == 51 ); -} - -} // namespace observers_1 diff --git a/gdb/unittests/optional/observers/2.cc b/gdb/unittests/optional/observers/2.cc deleted file mode 100644 index 0ad09ab5011..00000000000 --- a/gdb/unittests/optional/observers/2.cc +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -namespace observers_2 { - -struct value_type -{ - int i; -}; - -void* operator&(const value_type&) = delete; - -static void -test () -{ - gdb::optional o { value_type { 51 } }; - VERIFY( o->i == 51 ); - VERIFY( o->i == (*o).i ); - VERIFY( &o->i == &(*o).i ); -} - -} // namespace observers_2 diff --git a/gdbsupport/gdb_optional.h b/gdbsupport/gdb_optional.h deleted file mode 100644 index 9b7b7b2f7f4..00000000000 --- a/gdbsupport/gdb_optional.h +++ /dev/null @@ -1,233 +0,0 @@ -/* An optional object. - - Copyright (C) 2017-2023 Free Software Foundation, Inc. - - This file is part of GDB. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifndef COMMON_GDB_OPTIONAL_H -#define COMMON_GDB_OPTIONAL_H - -#include "gdbsupport/traits.h" - -namespace gdb -{ - -struct in_place_t -{ - explicit in_place_t () = default; -}; - -constexpr gdb::in_place_t in_place {}; - -/* This class attempts to be a compatible subset of std::optional, - which is slated to be available in C++17. This class optionally - holds an object of some type -- by default it is constructed not - holding an object, but later the object can be "emplaced". This is - similar to using std::unique_ptr, but in-object allocation is - guaranteed. - - Unlike std::optional, we currently only support copy/move - construction/assignment of an optional from either exactly - optional or T. I.e., we don't support copy/move - construction/assignment from optional or U, when U is a type - convertible to T. Making that work depending on the definitions of - T and U is somewhat complicated, and currently the users of this - class don't need it. */ - -template -class optional -{ -public: - - constexpr optional () - : m_dummy () - {} - - template - constexpr optional (in_place_t, Args &&... args) - : m_item (std::forward (args)...), - m_instantiated (true) - {} - - ~optional () - { this->reset (); } - - /* Copy and move constructors. */ - - optional (const optional &other) - { - if (other.m_instantiated) - this->emplace (other.get ()); - } - - optional (optional &&other) - noexcept(std::is_nothrow_move_constructible ()) - { - if (other.m_instantiated) - this->emplace (std::move (other.get ())); - } - - constexpr optional (const T &other) - : m_item (other), - m_instantiated (true) - {} - - constexpr optional (T &&other) - noexcept (std::is_nothrow_move_constructible ()) - : m_item (std::move (other)), - m_instantiated (true) - {} - - /* Assignment operators. */ - - optional & - operator= (const optional &other) - { - if (m_instantiated && other.m_instantiated) - this->get () = other.get (); - else - { - if (other.m_instantiated) - this->emplace (other.get ()); - else - this->reset (); - } - - return *this; - } - - optional & - operator= (optional &&other) - noexcept (And, - std::is_nothrow_move_assignable> ()) - { - if (m_instantiated && other.m_instantiated) - this->get () = std::move (other.get ()); - else - { - if (other.m_instantiated) - this->emplace (std::move (other.get ())); - else - this->reset (); - } - return *this; - } - - optional & - operator= (const T &other) - { - if (m_instantiated) - this->get () = other; - else - this->emplace (other); - return *this; - } - - optional & - operator= (T &&other) - noexcept (And, - std::is_nothrow_move_assignable> ()) - { - if (m_instantiated) - this->get () = std::move (other); - else - this->emplace (std::move (other)); - return *this; - } - - template - T &emplace (Args &&... args) - { - this->reset (); - new (&m_item) T (std::forward(args)...); - m_instantiated = true; - return this->get (); - } - - /* Observers. */ - constexpr const T *operator-> () const - { return std::addressof (this->get ()); } - - T *operator-> () - { return std::addressof (this->get ()); } - - constexpr const T &operator* () const & - { return this->get (); } - - T &operator* () & - { return this->get (); } - - T &&operator* () && - { return std::move (this->get ()); } - - constexpr const T &&operator* () const && - { return std::move (this->get ()); } - - constexpr explicit operator bool () const noexcept - { return m_instantiated; } - - constexpr bool has_value () const noexcept - { return m_instantiated; } - - /* 'reset' is a 'safe' operation with no precondition. */ - void reset () noexcept - { - if (m_instantiated) - this->destroy (); - } - -private: - - /* Destroy the object. */ - void destroy () - { - gdb_assert (m_instantiated); - m_instantiated = false; - m_item.~T (); - } - - /* The get operations have m_instantiated as a precondition. */ - T &get () noexcept - { -#if defined(_GLIBCXX_DEBUG) && __cplusplus >= 201402L - gdb_assert (this->has_value ()); -#endif - return m_item; - } - constexpr const T &get () const noexcept - { -#if defined(_GLIBCXX_DEBUG) && __cplusplus >= 201402L - gdb_assert (this->has_value ()); -#endif - return m_item; - } - - /* The object. */ - union - { - struct { } m_dummy; - T m_item; - volatile char dont_use; /* Silences -Wmaybe-uninitialized warning, see - PR gcc/80635. */ - }; - - /* True if the object was ever emplaced. */ - bool m_instantiated = false; -}; - -} - -#endif /* COMMON_GDB_OPTIONAL_H */ From patchwork Tue Nov 21 12:04:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lancelot SIX X-Patchwork-Id: 80466 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5A55738582A5 for ; Tue, 21 Nov 2023 12:07:40 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2078.outbound.protection.outlook.com [40.107.212.78]) by sourceware.org (Postfix) with ESMTPS id 9770638582B8 for ; Tue, 21 Nov 2023 12:05:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9770638582B8 Authentication-Results: sourceware.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=amd.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9770638582B8 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.212.78 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1700568363; cv=pass; b=VIsbz4GLGpFNmNirBJyvbu/Gczv1MrEFmYSF6oWDmwpqmbmRC6q0XweOv+0ym4cCxPf955Ign6eJ7wsgEmGMV/mrW+Lq5khYEUWMp0UK1WS9zNZ30NzQHwS64sj2P3Fa74Ny9cCrDxgJrpdtATcRmu3wNdkrzAzbJQcIR2Qr/7Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1700568363; c=relaxed/simple; bh=aPKKAaoEJP/fcwdfW6tbuqQ4ei/ai52qr8Kg+eya/qA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Jb2ShogF1SFcuLAR1aXXJtZn/RmjhXQ12cggj9zs4ni7udxYI66yfma8rnL4lPegT5QaRD347JhAXie5VDdjS2Iq2VCN1jFlRaK6HAPqMMtSY5F274Uw8PbP7+DeWbl4O0iFhlY9vSleXkJZ2D5ZeiSFijpDQfhXAGKqx3HP6NE= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NDnIB66QtuNeSJyDC1Zz5OnspQVo90smdB/+reRTnRe4LzwhdnMtqqsJQANrrzfWPUNhfaVuUW6d0QFePzBYxMA4K5BZMKwRAABxxZsAfWgpBQqC6IhLM+29hOszlEy7x8J6xNtfoqLl9YWjC7smiuZF7UyUi2DBZQhOGT2xSRbOGnQow74sWrdXdhoiFDRh3dpINI7Nja+DN5NaQO9aVl/wef3iOaYuJosJkTcNhdYeMOTO1kmXE+eZjRowce2lJgf40VncCgU8WW2q9HKK+sr7f/kg3lEOG2tefTT1dl1GnQ9NyRp9vuWUpcGbMH9DfY11DlaCagx6RJuLXMhH7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7kyoiaPr92WchDe4uIX+SKpnW3GFpbggIBFHZu4JylA=; b=McimEFcndwm79/Y9HMwljbXCAL/+dEG2lN+iP1hDVUZnLzrSxP0MVzeK1UjjHLWZ93mWqq8HLIXTAfElzveEEtH9oHTPfY9dS7GoaBpg3NvUP7brjVNKMTmYhZHm+tpEL6FIYCweWQV7+tqjP96wdDVuMz1aKCYyY+NphIy+VouZT5jSOQu2UslNlm62xx04OXnvhSNT6K9/aGvU9noTLZv94QHU3Jww7Nz4I/TSOqsZwRfoWqkrEtUQQpNQ2CGbiB8047GZ2L8hgvFuXqLe4gILc24ssVUEkPuuYkFlShA7P6PAaauOqz2wvCJNO/yYq4/MU6LqURBz7ddIFwMvTQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=sourceware.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7kyoiaPr92WchDe4uIX+SKpnW3GFpbggIBFHZu4JylA=; b=HlmLZM79fZCSXmzWHD8ZDaHwq2WqjNCa69YW22ApWOGuG5QRX93ydbC4z3ToZS08s8rOHIRy3B0Zp2SIXG8CiPS6lNcdbFqQCCT/1gCqiBrs4fcvY5Sprms1mYn+9P3daNZKkzq17iWflWPDuz3DRMCaf6J5wXpv+e/DqyDzzNY= Received: from BL1PR13CA0091.namprd13.prod.outlook.com (2603:10b6:208:2b9::6) by LV8PR12MB9136.namprd12.prod.outlook.com (2603:10b6:408:18e::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.27; Tue, 21 Nov 2023 12:05:54 +0000 Received: from MN1PEPF0000F0E3.namprd04.prod.outlook.com (2603:10b6:208:2b9:cafe::b4) by BL1PR13CA0091.outlook.office365.com (2603:10b6:208:2b9::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.16 via Frontend Transport; Tue, 21 Nov 2023 12:05:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MN1PEPF0000F0E3.mail.protection.outlook.com (10.167.242.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7025.12 via Frontend Transport; Tue, 21 Nov 2023 12:05:54 +0000 Received: from hpe6u-23.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Tue, 21 Nov 2023 06:05:51 -0600 From: Lancelot Six To: CC: , , Lancelot Six Subject: [COMMITTED PATCH v2 4/9] gdb: Use std::string_view instead of gdb::string_view Date: Tue, 21 Nov 2023 12:04:55 +0000 Message-ID: <20231121120500.1394523-5-lancelot.six@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028204821.fp5hh7bahrmrnpjl@hpe6u-23> References: <20231028204821.fp5hh7bahrmrnpjl@hpe6u-23> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000F0E3:EE_|LV8PR12MB9136:EE_ X-MS-Office365-Filtering-Correlation-Id: 9de01d93-24be-42b4-1c65-08dbea8a3684 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dzsxIjz5PyfXOvEpjSBwNScOlNY1M2N7+qldOKULYNGBKtUVjY/LvanhQXJDfmNqPs8nGEr14s5hxpg1dP9Ys0UXOgR/oY3Oso0ZRt0s7CiW6SE15Nv3Va1XU535tMlK6aMkwSRksuGSQvLNDGhHyIfHU0Ar6BdoTfcgtGUAcJDLHMsQtOHsizBZWS7QMs2Yx//FEewdnSMGc5xmwM1gVrXtHvHZjjX5FwPElE4Eg7fsfLTNTfO8zQWTEPFfpk/8iuGvfENvSLKfuw2AqpNgpRf2MAmxpMQp8lRwGhX+sAgMMgFSYLjNxhuseh/4nI5FQLIe6XG6BNuY6+mnthxtXFH9+SgDtiDOWAva28M27jKIriO2xDbLCjGsbI8WwF8dCiXYB6hMeoF0EM22vkSZvaxUvvmOdn7Sqy3H/R4tvV8CYqcYub1ockBoXcTbGFGMP6tsJHomekSvw22ct4/cG2IRDH4CY9xZyinr6xlPh6W1L8AJdNTS4BwRpRnNwKbC0GOPnZwiIiYnCxVj+r4TglvYpg2VB+qJTkxe+7wLV0Xys+St0vmH9kf1A7Tnk/6rxmERXQ6JOF4ZXa8+iVUxDvqQE1s6P6RUBxAR7jwEuobb+zEILoJEMFVYnKfZglJdKpdaegx/58UfiYeszgUVXe5vIsxsAbw/immW/iXPCgClRhP4uwT/34UXnW2TK2TW3RHGAto2szMAQ4NqKsttekJiju94j+nEZ8a+IooaPJEW+CwUt/0LnWq+/xng8WPMDP5LHLitf3ADz2h3PwZjGRUutwf+EFsd6XGX5ic1xdgh+lgciZVapnl8g7T2htzzZaNXTCgRG5PT6X/cLjY/vQ== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(136003)(396003)(376002)(39860400002)(346002)(230922051799003)(230173577357003)(230273577357003)(1800799012)(64100799003)(186009)(82310400011)(451199024)(40470700004)(46966006)(36840700001)(40480700001)(44832011)(5660300002)(4326008)(8676002)(8936002)(30864003)(2906002)(41300700001)(6916009)(316002)(54906003)(70206006)(70586007)(40460700003)(47076005)(86362001)(478600001)(1076003)(26005)(966005)(36756003)(16799955002)(7696005)(2616005)(426003)(336012)(16526019)(15188155005)(36860700001)(83380400001)(356005)(81166007)(82740400003)(36900700001)(579004)(19623215001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 12:05:54.3602 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9de01d93-24be-42b4-1c65-08dbea8a3684 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MN1PEPF0000F0E3.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9136 X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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: 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+patchwork=sourceware.org@sourceware.org Given that GDB now requires a C++17, replace all uses of gdb::string_view with std::string_view. This change has mostly been done automatically: - gdb::string_view -> std::string_view - #include "gdbsupport/gdb_string_view.h" -> #include One things which got brought up during review is that gdb::stging_view does support being built from "nullptr" while std::sting_view does not. Two places are manually adjusted to account for this difference: gdb/tui/tui-io.c:tui_getc_1 and gdbsupport/format.h:format_piece::format_piece. The above automatic change transformed "gdb::to_string (const gdb::string_view &)" into "gdb::to_string (const std::string_view &)". The various direct users of this function are now explicitly including "gdbsupport/gdb_string_view.h". A later patch will remove the users of gdb::to_string. The implementation and tests of gdb::string_view are unchanged, they will be removed in a following patch. Change-Id: Ibb806a7e9c79eb16a55c87c6e41ad396fecf0207 Approved-By: Tom Tromey Approved-By: Pedro Alves --- gdb/ada-lang.c | 9 ++++--- gdb/amdgpu-tdep.c | 51 ++++++++++++++++++------------------ gdb/cli/cli-script.c | 4 +-- gdb/dbxread.c | 18 ++++++------- gdb/debuginfod-support.c | 7 ++--- gdb/dwarf2/cooked-index.c | 6 ++--- gdb/dwarf2/cooked-index.h | 2 +- gdb/dwarf2/index-common.c | 2 +- gdb/dwarf2/index-common.h | 2 +- gdb/dwarf2/read.c | 3 ++- gdb/elfread.c | 8 +++--- gdb/eval.c | 1 + gdb/language.c | 2 +- gdb/linux-tdep.c | 8 +++--- gdb/mdebugread.c | 18 ++++++------- gdb/minsyms.c | 4 +-- gdb/minsyms.h | 2 +- gdb/psymtab.c | 2 +- gdb/psymtab.h | 4 +-- gdb/solib-rocm.c | 21 ++++++++------- gdb/split-name.c | 4 +-- gdb/split-name.h | 4 +-- gdb/stabsread.c | 2 +- gdb/symtab.c | 14 +++++----- gdb/symtab.h | 14 +++++----- gdb/tui/tui-io.c | 5 +++- gdb/tui/tui-win.c | 6 ++--- gdb/xcoffread.c | 18 ++++++------- gdbsupport/common-utils.h | 8 +++--- gdbsupport/format.h | 5 ++-- gdbsupport/gdb_string_view.h | 2 +- 31 files changed, 133 insertions(+), 123 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 58c70160d31..843583ecb40 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -58,6 +58,7 @@ #include "gdbsupport/function-view.h" #include "gdbsupport/byte-vector.h" #include "gdbsupport/selftest.h" +#include "gdbsupport/gdb_string_view.h" #include #include "ada-exp.h" #include "charset.h" @@ -1035,7 +1036,7 @@ find_case_fold_entry (uint32_t c) rather than emitting a warning. Result good to next call. */ static const char * -ada_fold_name (gdb::string_view name, bool throw_on_error = false) +ada_fold_name (std::string_view name, bool throw_on_error = false) { static std::string fold_storage; @@ -13250,7 +13251,7 @@ do_exact_match (const char *symbol_search_name, ada_lookup_name_info::ada_lookup_name_info (const lookup_name_info &lookup_name) { - gdb::string_view user_name = lookup_name.name (); + std::string_view user_name = lookup_name.name (); if (!user_name.empty () && user_name[0] == '<') { @@ -13269,7 +13270,7 @@ ada_lookup_name_info::ada_lookup_name_info (const lookup_name_info &lookup_name) { m_verbatim_p = false; - m_encoded_p = user_name.find ("__") != gdb::string_view::npos; + m_encoded_p = user_name.find ("__") != std::string_view::npos; if (!m_encoded_p) { @@ -13326,7 +13327,7 @@ literal_symbol_name_matcher (const char *symbol_search_name, const lookup_name_info &lookup_name, completion_match_result *comp_match_res) { - gdb::string_view name_view = lookup_name.name (); + std::string_view name_view = lookup_name.name (); if (lookup_name.completion_mode () ? (strncmp (symbol_search_name, name_view.data (), diff --git a/gdb/amdgpu-tdep.c b/gdb/amdgpu-tdep.c index 3a521a43977..58d26fc0b6b 100644 --- a/gdb/amdgpu-tdep.c +++ b/gdb/amdgpu-tdep.c @@ -27,6 +27,7 @@ #include "frame-unwind.h" #include "gdbarch.h" #include "gdbsupport/selftest.h" +#include "gdbsupport/gdb_string_view.h" #include "gdbtypes.h" #include "inferior.h" #include "objfiles.h" @@ -237,7 +238,7 @@ struct amd_dbgapi_register_type_flags : public amd_dbgapi_register_type using container_type = std::vector; using const_iterator_type = container_type::const_iterator; - amd_dbgapi_register_type_flags (unsigned int bit_size, gdb::string_view name) + amd_dbgapi_register_type_flags (unsigned int bit_size, std::string_view name) : amd_dbgapi_register_type (kind::FLAGS, make_lookup_name (bit_size, name)), m_bit_size (bit_size), @@ -270,7 +271,7 @@ struct amd_dbgapi_register_type_flags : public amd_dbgapi_register_type const std::string &name () const { return m_name; } - static std::string make_lookup_name (int bits, gdb::string_view name) + static std::string make_lookup_name (int bits, std::string_view name) { std::string res = string_printf ("flags%d_t ", bits); res.append (name.data (), name.size ()); @@ -297,7 +298,7 @@ struct amd_dbgapi_register_type_enum : public amd_dbgapi_register_type using container_type = std::vector; using const_iterator_type = container_type::const_iterator; - amd_dbgapi_register_type_enum (gdb::string_view name) + amd_dbgapi_register_type_enum (std::string_view name) : amd_dbgapi_register_type (kind::ENUM, make_lookup_name (name)), m_name (name.data (), name.length ()) {} @@ -326,7 +327,7 @@ struct amd_dbgapi_register_type_enum : public amd_dbgapi_register_type const std::string &name () const { return m_name; } - static std::string make_lookup_name (gdb::string_view name) + static std::string make_lookup_name (std::string_view name) { std::string res = "enum "; res.append (name.data (), name.length ()); @@ -349,7 +350,7 @@ using amd_dbgapi_register_type_map /* Parse S as a ULONGEST, raise an error on overflow. */ static ULONGEST -try_strtoulst (gdb::string_view s) +try_strtoulst (std::string_view s) { errno = 0; ULONGEST value = strtoulst (s.data (), nullptr, 0); @@ -365,7 +366,7 @@ try_strtoulst (gdb::string_view s) #define WSOPT "[ \t]*" static const amd_dbgapi_register_type & -parse_amd_dbgapi_register_type (gdb::string_view type_name, +parse_amd_dbgapi_register_type (std::string_view type_name, amd_dbgapi_register_type_map &type_map); @@ -373,7 +374,7 @@ parse_amd_dbgapi_register_type (gdb::string_view type_name, static void parse_amd_dbgapi_register_type_enum_fields - (amd_dbgapi_register_type_enum &enum_type, gdb::string_view fields) + (amd_dbgapi_register_type_enum &enum_type, std::string_view fields) { compiled_regex regex (/* name */ "^(" IDENTIFIER ")" @@ -394,8 +395,8 @@ parse_amd_dbgapi_register_type_enum_fields auto sv_from_match = [fields] (const regmatch_t &m) { return fields.substr (m.rm_so, m.rm_eo - m.rm_so); }; - gdb::string_view name = sv_from_match (matches[1]); - gdb::string_view value_str = sv_from_match (matches[2]); + std::string_view name = sv_from_match (matches[1]); + std::string_view value_str = sv_from_match (matches[2]); ULONGEST value = try_strtoulst (value_str); if (value > std::numeric_limits::max ()) @@ -412,7 +413,7 @@ parse_amd_dbgapi_register_type_enum_fields static void parse_amd_dbgapi_register_type_flags_fields (amd_dbgapi_register_type_flags &flags_type, - int bits, gdb::string_view name, gdb::string_view fields, + int bits, std::string_view name, std::string_view fields, amd_dbgapi_register_type_map &type_map) { gdb_assert (bits == 32 || bits == 64); @@ -439,9 +440,9 @@ parse_amd_dbgapi_register_type_flags_fields auto sv_from_match = [fields] (const regmatch_t &m) { return fields.substr (m.rm_so, m.rm_eo - m.rm_so); }; - gdb::string_view field_type_str = sv_from_match (matches[1]); - gdb::string_view field_name = sv_from_match (matches[3]); - gdb::string_view pos_begin_str = sv_from_match (matches[4]); + std::string_view field_type_str = sv_from_match (matches[1]); + std::string_view field_name = sv_from_match (matches[3]); + std::string_view pos_begin_str = sv_from_match (matches[4]); ULONGEST pos_begin = try_strtoulst (pos_begin_str); if (field_type_str == "bool") @@ -452,7 +453,7 @@ parse_amd_dbgapi_register_type_flags_fields if (matches[5].rm_so == -1) error (_("Missing end bit position")); - gdb::string_view pos_end_str = sv_from_match (matches[5]); + std::string_view pos_end_str = sv_from_match (matches[5]); ULONGEST pos_end = try_strtoulst (pos_end_str.substr (1)); const amd_dbgapi_register_type &field_type = parse_amd_dbgapi_register_type (field_type_str, type_map); @@ -467,7 +468,7 @@ parse_amd_dbgapi_register_type_flags_fields /* parse_amd_dbgapi_register_type helper for scalars. */ static const amd_dbgapi_register_type & -parse_amd_dbgapi_register_type_scalar (gdb::string_view name, +parse_amd_dbgapi_register_type_scalar (std::string_view name, amd_dbgapi_register_type_map &type_map) { std::string name_str = gdb::to_string (name); @@ -513,24 +514,24 @@ parse_amd_dbgapi_register_type_scalar (gdb::string_view name, details about the format. */ static const amd_dbgapi_register_type & -parse_amd_dbgapi_register_type (gdb::string_view type_str, +parse_amd_dbgapi_register_type (std::string_view type_str, amd_dbgapi_register_type_map &type_map) { size_t pos_open_bracket = type_str.find_last_of ('['); auto sv_from_match = [type_str] (const regmatch_t &m) { return type_str.substr (m.rm_so, m.rm_eo - m.rm_so); }; - if (pos_open_bracket != gdb::string_view::npos) + if (pos_open_bracket != std::string_view::npos) { /* Vector types. */ - gdb::string_view element_type_str + std::string_view element_type_str = type_str.substr (0, pos_open_bracket); const amd_dbgapi_register_type &element_type = parse_amd_dbgapi_register_type (element_type_str, type_map); size_t pos_close_bracket = type_str.find_last_of (']'); - gdb_assert (pos_close_bracket != gdb::string_view::npos); - gdb::string_view count_str_view + gdb_assert (pos_close_bracket != std::string_view::npos); + std::string_view count_str_view = type_str.substr (pos_open_bracket + 1, pos_close_bracket - pos_open_bracket); std::string count_str = gdb::to_string (count_str_view); @@ -567,9 +568,9 @@ parse_amd_dbgapi_register_type (gdb::string_view type_str, if (res == REG_NOMATCH) error (_("Failed to parse flags type string")); - gdb::string_view flags_keyword = sv_from_match (matches[1]); + std::string_view flags_keyword = sv_from_match (matches[1]); unsigned int bit_size = flags_keyword == "flags32_t" ? 32 : 64; - gdb::string_view name = sv_from_match (matches[2]); + std::string_view name = sv_from_match (matches[2]); std::string lookup_name = amd_dbgapi_register_type_flags::make_lookup_name (bit_size, name); auto existing_type_it = type_map.find (lookup_name); @@ -596,7 +597,7 @@ parse_amd_dbgapi_register_type (gdb::string_view type_str, amd_dbgapi_register_type_flags_up flags_type (new amd_dbgapi_register_type_flags (bit_size, name)); - gdb::string_view fields_without_braces = sv_from_match (matches[4]); + std::string_view fields_without_braces = sv_from_match (matches[4]); parse_amd_dbgapi_register_type_flags_fields (*flags_type, bit_size, name, fields_without_braces, type_map); @@ -620,7 +621,7 @@ parse_amd_dbgapi_register_type (gdb::string_view type_str, if (res == REG_NOMATCH) error (_("Failed to parse flags type string")); - gdb::string_view name = sv_from_match (matches[1]); + std::string_view name = sv_from_match (matches[1]); std::string lookup_name = amd_dbgapi_register_type_enum::make_lookup_name (name); @@ -648,7 +649,7 @@ parse_amd_dbgapi_register_type (gdb::string_view type_str, amd_dbgapi_register_type_enum_up enum_type (new amd_dbgapi_register_type_enum (name)); - gdb::string_view fields_without_braces = sv_from_match (matches[3]); + std::string_view fields_without_braces = sv_from_match (matches[3]); parse_amd_dbgapi_register_type_enum_fields (*enum_type, fields_without_braces); diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c index 8ec5689ebcf..b355a6dc81e 100644 --- a/gdb/cli/cli-script.c +++ b/gdb/cli/cli-script.c @@ -35,7 +35,7 @@ #include "extension.h" #include "interps.h" #include "compile/compile.h" -#include "gdbsupport/gdb_string_view.h" +#include #include "python/python.h" #include "guile/guile.h" @@ -103,7 +103,7 @@ class user_args std::string m_command_line; /* The arguments. Each element points inside M_COMMAND_LINE. */ - std::vector m_args; + std::vector m_args; }; /* The stack of arguments passed to user defined functions. We need a diff --git a/gdb/dbxread.c b/gdb/dbxread.c index 3afafa77fb4..b92193bdadd 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -1483,7 +1483,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, { case 'S': if (pst != nullptr) - pst->add_psymbol (gdb::string_view (sym_name, sym_len), true, + pst->add_psymbol (std::string_view (sym_name, sym_len), true, VAR_DOMAIN, LOC_STATIC, data_sect_index, psymbol_placement::STATIC, @@ -1500,7 +1500,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, /* The addresses in these entries are reported to be wrong. See the code that reads 'G's for symtabs. */ if (pst != nullptr) - pst->add_psymbol (gdb::string_view (sym_name, sym_len), true, + pst->add_psymbol (std::string_view (sym_name, sym_len), true, VAR_DOMAIN, LOC_STATIC, data_sect_index, psymbol_placement::GLOBAL, @@ -1525,7 +1525,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, && namestring[0] != ' ')) { if (pst != nullptr) - pst->add_psymbol (gdb::string_view (sym_name, sym_len), + pst->add_psymbol (std::string_view (sym_name, sym_len), true, STRUCT_DOMAIN, LOC_TYPEDEF, -1, psymbol_placement::STATIC, unrelocated_addr (0), @@ -1540,7 +1540,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, { /* Also a typedef with the same name. */ if (pst != nullptr) - pst->add_psymbol (gdb::string_view (sym_name, sym_len), + pst->add_psymbol (std::string_view (sym_name, sym_len), true, VAR_DOMAIN, LOC_TYPEDEF, -1, psymbol_placement::STATIC, unrelocated_addr (0), @@ -1559,7 +1559,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, if (p != namestring) /* a name is there, not just :T... */ { if (pst != nullptr) - pst->add_psymbol (gdb::string_view (sym_name, sym_len), + pst->add_psymbol (std::string_view (sym_name, sym_len), true, VAR_DOMAIN, LOC_TYPEDEF, -1, psymbol_placement::STATIC, unrelocated_addr (0), @@ -1627,7 +1627,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, /* Note that the value doesn't matter for enum constants in psymtabs, just in symtabs. */ if (pst != nullptr) - pst->add_psymbol (gdb::string_view (p, q - p), true, + pst->add_psymbol (std::string_view (p, q - p), true, VAR_DOMAIN, LOC_CONST, -1, psymbol_placement::STATIC, unrelocated_addr (0), @@ -1652,7 +1652,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, case 'c': /* Constant, e.g. from "const" in Pascal. */ if (pst != nullptr) - pst->add_psymbol (gdb::string_view (sym_name, sym_len), true, + pst->add_psymbol (std::string_view (sym_name, sym_len), true, VAR_DOMAIN, LOC_CONST, -1, psymbol_placement::STATIC, unrelocated_addr (0), @@ -1712,7 +1712,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, textlow_not_set = 0; } if (pst != nullptr) - pst->add_psymbol (gdb::string_view (sym_name, sym_len), true, + pst->add_psymbol (std::string_view (sym_name, sym_len), true, VAR_DOMAIN, LOC_BLOCK, SECT_OFF_TEXT (objfile), psymbol_placement::STATIC, @@ -1771,7 +1771,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, textlow_not_set = 0; } if (pst != nullptr) - pst->add_psymbol (gdb::string_view (sym_name, sym_len), true, + pst->add_psymbol (std::string_view (sym_name, sym_len), true, VAR_DOMAIN, LOC_BLOCK, SECT_OFF_TEXT (objfile), psymbol_placement::GLOBAL, diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c index 1ebd98ca705..a989eb9cb97 100644 --- a/gdb/debuginfod-support.c +++ b/gdb/debuginfod-support.c @@ -20,6 +20,7 @@ #include "diagnostics.h" #include #include "gdbsupport/scoped_fd.h" +#include "gdbsupport/gdb_string_view.h" #include "debuginfod-support.h" #include #include "cli/cli-cmds.h" @@ -246,11 +247,11 @@ debuginfod_is_enabled () gdb_printf (_("\nThis GDB supports auto-downloading debuginfo " \ "from the following URLs:\n")); - gdb::string_view url_view (urls); + std::string_view url_view (urls); while (true) { size_t off = url_view.find_first_not_of (' '); - if (off == gdb::string_view::npos) + if (off == std::string_view::npos) break; url_view = url_view.substr (off); /* g++ 11.2.1 on s390x, g++ 11.3.1 on ppc64le and g++ 11 on @@ -266,7 +267,7 @@ debuginfod_is_enabled () styled_string (file_name_style.style (), gdb::to_string (url_view.substr (0, off)).c_str ())); - if (off == gdb::string_view::npos) + if (off == std::string_view::npos) break; url_view = url_view.substr (off); } diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c index 58ea541a5c9..7c4af3a1681 100644 --- a/gdb/dwarf2/cooked-index.c +++ b/gdb/dwarf2/cooked-index.c @@ -266,9 +266,9 @@ cooked_index_shard::handle_gnat_encoded_entry (cooked_index_entry *entry, std::string canonical = ada_decode (entry->name, false, false); if (canonical.empty ()) return {}; - std::vector names = split_name (canonical.c_str (), + std::vector names = split_name (canonical.c_str (), split_style::DOT_STYLE); - gdb::string_view tail = names.back (); + std::string_view tail = names.back (); names.pop_back (); const cooked_index_entry *parent = nullptr; @@ -333,7 +333,7 @@ cooked_index_shard::do_finalize () auto eq_entry = [] (const void *a, const void *b) -> int { const cooked_index_entry *ae = (const cooked_index_entry *) a; - const gdb::string_view *sv = (const gdb::string_view *) b; + const std::string_view *sv = (const std::string_view *) b; return (strlen (ae->canonical) == sv->length () && strncasecmp (ae->canonical, sv->data (), sv->length ()) == 0); }; diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h index 5aacb321c91..5675ea68bb8 100644 --- a/gdb/dwarf2/cooked-index.h +++ b/gdb/dwarf2/cooked-index.h @@ -25,7 +25,7 @@ #include "symtab.h" #include "hashtab.h" #include "dwarf2/index-common.h" -#include "gdbsupport/gdb_string_view.h" +#include #include "quick-symbol.h" #include "gdbsupport/gdb_obstack.h" #include "addrmap.h" diff --git a/gdb/dwarf2/index-common.c b/gdb/dwarf2/index-common.c index 07330a86da1..04b04f93a61 100644 --- a/gdb/dwarf2/index-common.c +++ b/gdb/dwarf2/index-common.c @@ -58,7 +58,7 @@ dwarf5_djb_hash (const char *str_) /* See dwarf-index-common.h. */ uint32_t -dwarf5_djb_hash (gdb::string_view str) +dwarf5_djb_hash (std::string_view str) { /* Note: tolower here ignores UTF-8, which isn't fully compliant. See http://dwarfstd.org/ShowIssue.php?issue=161027.1. */ diff --git a/gdb/dwarf2/index-common.h b/gdb/dwarf2/index-common.h index 23e814a240b..79d3a59220e 100644 --- a/gdb/dwarf2/index-common.h +++ b/gdb/dwarf2/index-common.h @@ -54,6 +54,6 @@ uint32_t dwarf5_djb_hash (const char *str_); /* Symbol name hashing function as specified by DWARF-5. */ -uint32_t dwarf5_djb_hash (gdb::string_view str_); +uint32_t dwarf5_djb_hash (std::string_view str_); #endif /* DWARF_INDEX_COMMON_H */ diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 6d86d28d8c0..a16139dad1e 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -96,6 +96,7 @@ #include "split-name.h" #include "gdbsupport/parallel-for.h" #include "gdbsupport/thread-pool.h" +#include "gdbsupport/gdb_string_view.h" /* When == 1, print basic high level tracing messages. When > 1, be more verbose. @@ -16767,7 +16768,7 @@ cooked_index_functions::expand_symtabs_matching for (enum language lang : unique_styles) { - std::vector name_vec + std::vector name_vec = lookup_name_without_params.split_name (lang); std::string last_name = gdb::to_string (name_vec.back ()); diff --git a/gdb/elfread.c b/gdb/elfread.c index 86e7f61586e..5dc8f21d7c7 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -45,7 +45,7 @@ #include "auxv.h" #include "mdebugread.h" #include "ctfread.h" -#include "gdbsupport/gdb_string_view.h" +#include #include "gdbsupport/scoped_fd.h" #include "dwarf2/public.h" #include "cli/cli-cmds.h" @@ -195,7 +195,7 @@ elf_locate_sections (asection *sectp, struct elfinfo *ei) static struct minimal_symbol * record_minimal_symbol (minimal_symbol_reader &reader, - gdb::string_view name, bool copy_name, + std::string_view name, bool copy_name, unrelocated_addr address, enum minimal_symbol_type ms_type, asection *bfd_section, struct objfile *objfile) @@ -503,7 +503,7 @@ elf_symtab_read (minimal_symbol_reader &reader, && !is_plt && (elf_sym->version & VERSYM_HIDDEN) == 0) record_minimal_symbol (reader, - gdb::string_view (sym->name, len), + std::string_view (sym->name, len), true, unrelocated_addr (symaddr), ms_type, sym->section, objfile); else if (is_plt) @@ -517,7 +517,7 @@ elf_symtab_read (minimal_symbol_reader &reader, struct minimal_symbol *mtramp; mtramp = record_minimal_symbol - (reader, gdb::string_view (sym->name, len), true, + (reader, std::string_view (sym->name, len), true, unrelocated_addr (symaddr), mst_solib_trampoline, sym->section, objfile); if (mtramp) diff --git a/gdb/eval.c b/gdb/eval.c index 3358b0d8d32..8664d4980b7 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -37,6 +37,7 @@ #include "user-regs.h" #include "valprint.h" #include "gdbsupport/gdb_obstack.h" +#include "gdbsupport/gdb_string_view.h" #include "objfiles.h" #include "typeprint.h" #include diff --git a/gdb/language.c b/gdb/language.c index c768971be42..cfd4a621e6b 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -641,7 +641,7 @@ default_symbol_name_matcher (const char *symbol_search_name, const lookup_name_info &lookup_name, completion_match_result *comp_match_res) { - gdb::string_view name = lookup_name.name (); + std::string_view name = lookup_name.name (); completion_match_for_lcd *match_for_lcd = (comp_match_res != NULL ? &comp_match_res->match_for_lcd : NULL); strncmp_iw_mode mode = (lookup_name.completion_mode () diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index db29b032018..26cf483b04a 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -457,13 +457,13 @@ struct mapping { ULONGEST addr; ULONGEST endaddr; - gdb::string_view permissions; + std::string_view permissions; ULONGEST offset; - gdb::string_view device; + std::string_view device; ULONGEST inode; /* This field is guaranteed to be NULL-terminated, hence it is not a - gdb::string_view. */ + std::string_view. */ const char *filename; }; @@ -1384,7 +1384,7 @@ parse_smaps_data (const char *data, /* Decode permissions. */ auto has_perm = [&m] (char c) - { return m.permissions.find (c) != gdb::string_view::npos; }; + { return m.permissions.find (c) != std::string_view::npos; }; read = has_perm ('r'); write = has_perm ('w'); exec = has_perm ('x'); diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index cd6638224e7..fc731605991 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -3050,7 +3050,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, switch (p[1]) { case 'S': - pst->add_psymbol (gdb::string_view (namestring, + pst->add_psymbol (std::string_view (namestring, p - namestring), true, VAR_DOMAIN, LOC_STATIC, SECT_OFF_DATA (objfile), @@ -3063,7 +3063,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, /* The addresses in these entries are reported to be wrong. See the code that reads 'G's for symtabs. */ - pst->add_psymbol (gdb::string_view (namestring, + pst->add_psymbol (std::string_view (namestring, p - namestring), true, VAR_DOMAIN, LOC_STATIC, SECT_OFF_DATA (objfile), @@ -3085,7 +3085,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, && namestring[0] != ' ')) { pst->add_psymbol - (gdb::string_view (namestring, p - namestring), + (std::string_view (namestring, p - namestring), true, STRUCT_DOMAIN, LOC_TYPEDEF, -1, psymbol_placement::STATIC, unrelocated_addr (0), @@ -3095,7 +3095,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, { /* Also a typedef with the same name. */ pst->add_psymbol - (gdb::string_view (namestring, + (std::string_view (namestring, p - namestring), true, VAR_DOMAIN, LOC_TYPEDEF, -1, psymbol_placement::STATIC, @@ -3111,7 +3111,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, just :T... */ { pst->add_psymbol - (gdb::string_view (namestring, + (std::string_view (namestring, p - namestring), true, VAR_DOMAIN, LOC_TYPEDEF, -1, psymbol_placement::STATIC, @@ -3178,7 +3178,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, /* Note that the value doesn't matter for enum constants in psymtabs, just in symtabs. */ - pst->add_psymbol (gdb::string_view (p, + pst->add_psymbol (std::string_view (p, q - p), true, VAR_DOMAIN, LOC_CONST, -1, @@ -3199,7 +3199,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, continue; case 'c': /* Constant, e.g. from "const" in Pascal. */ - pst->add_psymbol (gdb::string_view (namestring, + pst->add_psymbol (std::string_view (namestring, p - namestring), true, VAR_DOMAIN, LOC_CONST, -1, psymbol_placement::STATIC, @@ -3215,7 +3215,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, function_outside_compilation_unit_complaint (copy.c_str ()); } - pst->add_psymbol (gdb::string_view (namestring, + pst->add_psymbol (std::string_view (namestring, p - namestring), true, VAR_DOMAIN, LOC_BLOCK, SECT_OFF_TEXT (objfile), @@ -3236,7 +3236,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, function_outside_compilation_unit_complaint (copy.c_str ()); } - pst->add_psymbol (gdb::string_view (namestring, + pst->add_psymbol (std::string_view (namestring, p - namestring), true, VAR_DOMAIN, LOC_BLOCK, SECT_OFF_TEXT (objfile), diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 1d778822858..72e500be959 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -1170,7 +1170,7 @@ mst_str (minimal_symbol_type t) /* See minsyms.h. */ struct minimal_symbol * -minimal_symbol_reader::record_full (gdb::string_view name, +minimal_symbol_reader::record_full (std::string_view name, bool copy_name, unrelocated_addr address, enum minimal_symbol_type ms_type, int section) @@ -1510,7 +1510,7 @@ minimal_symbol_reader::install () { size_t idx = msym - msymbols; msym->compute_and_set_names - (gdb::string_view (msym->linkage_name (), + (std::string_view (msym->linkage_name (), hash_values[idx].name_length), false, m_objfile->per_bfd, diff --git a/gdb/minsyms.h b/gdb/minsyms.h index f3a2474c796..ee415c4db41 100644 --- a/gdb/minsyms.h +++ b/gdb/minsyms.h @@ -118,7 +118,7 @@ class minimal_symbol_reader SECTION - the symbol's section */ - struct minimal_symbol *record_full (gdb::string_view name, + struct minimal_symbol *record_full (std::string_view name, bool copy_name, unrelocated_addr address, enum minimal_symbol_type ms_type, diff --git a/gdb/psymtab.c b/gdb/psymtab.c index 484d4eaa651..d4cd5810c20 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -1208,7 +1208,7 @@ partial_symtab::add_psymbol (const partial_symbol &psymbol, /* See psymtab.h. */ void -partial_symtab::add_psymbol (gdb::string_view name, bool copy_name, +partial_symtab::add_psymbol (std::string_view name, bool copy_name, domain_enum domain, enum address_class theclass, short section, diff --git a/gdb/psymtab.h b/gdb/psymtab.h index 4bafc6e998e..005a63cbba8 100644 --- a/gdb/psymtab.h +++ b/gdb/psymtab.h @@ -21,7 +21,7 @@ #define PSYMTAB_H #include "objfiles.h" -#include "gdbsupport/gdb_string_view.h" +#include #include "gdbsupport/gdb_obstack.h" #include "symfile.h" #include "gdbsupport/next-iterator.h" @@ -346,7 +346,7 @@ struct partial_symtab LANGUAGE is the language from which the symbol originates. This will influence, amongst other things, how the symbol name is demangled. */ - void add_psymbol (gdb::string_view name, + void add_psymbol (std::string_view name, bool copy_name, domain_enum domain, enum address_class theclass, short section, diff --git a/gdb/solib-rocm.c b/gdb/solib-rocm.c index cf56a81a2ee..9ceb7a922e3 100644 --- a/gdb/solib-rocm.c +++ b/gdb/solib-rocm.c @@ -31,6 +31,7 @@ #include "solib-svr4.h" #include "solist.h" #include "symfile.h" +#include "gdbsupport/gdb_string_view.h" #include @@ -436,8 +437,8 @@ rocm_code_object_stream_memory::read (bfd *, void *buf, file_ptr size, static gdb_bfd_iovec_base * rocm_bfd_iovec_open (bfd *abfd, inferior *inferior) { - gdb::string_view uri (bfd_get_filename (abfd)); - gdb::string_view protocol_delim = "://"; + std::string_view uri (bfd_get_filename (abfd)); + std::string_view protocol_delim = "://"; size_t protocol_end = uri.find (protocol_delim); std::string protocol = gdb::to_string (uri.substr (0, protocol_end)); protocol_end += protocol_delim.length (); @@ -445,7 +446,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior) std::transform (protocol.begin (), protocol.end (), protocol.begin (), [] (unsigned char c) { return std::tolower (c); }); - gdb::string_view path; + std::string_view path; size_t path_end = uri.find_first_of ("#?", protocol_end); if (path_end != std::string::npos) path = uri.substr (protocol_end, path_end++ - protocol_end); @@ -461,7 +462,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior) && std::isxdigit (path[i + 1]) && std::isxdigit (path[i + 2])) { - gdb::string_view hex_digits = path.substr (i + 1, 2); + std::string_view hex_digits = path.substr (i + 1, 2); decoded_path += std::stoi (gdb::to_string (hex_digits), 0, 16); i += 2; } @@ -469,7 +470,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior) decoded_path += path[i]; /* Tokenize the query/fragment. */ - std::vector tokens; + std::vector tokens; size_t pos, last = path_end; while ((pos = uri.find ('&', last)) != std::string::npos) { @@ -481,15 +482,15 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior) tokens.emplace_back (uri.substr (last)); /* Create a tag-value map from the tokenized query/fragment. */ - std::unordered_map params; - for (gdb::string_view token : tokens) + for (std::string_view token : tokens) { size_t delim = token.find ('='); if (delim != std::string::npos) { - gdb::string_view tag = token.substr (0, delim); - gdb::string_view val = token.substr (delim + 1); + std::string_view tag = token.substr (0, delim); + std::string_view val = token.substr (delim + 1); params.emplace (tag, val); } } @@ -499,7 +500,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior) ULONGEST offset = 0; ULONGEST size = 0; - auto try_strtoulst = [] (gdb::string_view v) + auto try_strtoulst = [] (std::string_view v) { errno = 0; ULONGEST value = strtoulst (v.data (), nullptr, 0); diff --git a/gdb/split-name.c b/gdb/split-name.c index 0253b3cf675..0805cb82700 100644 --- a/gdb/split-name.c +++ b/gdb/split-name.c @@ -23,10 +23,10 @@ /* See split-name.h. */ -std::vector +std::vector split_name (const char *name, split_style style) { - std::vector result; + std::vector result; unsigned int previous_len = 0; switch (style) diff --git a/gdb/split-name.h b/gdb/split-name.h index 7648cf9b900..ad2862e222d 100644 --- a/gdb/split-name.h +++ b/gdb/split-name.h @@ -20,7 +20,7 @@ #ifndef GDB_SPLIT_NAME_H #define GDB_SPLIT_NAME_H -#include "gdbsupport/gdb_string_view.h" +#include /* The available styles of name splitting. */ @@ -40,7 +40,7 @@ enum class split_style /* Split NAME into components at module boundaries. STYLE indicates which style of splitting to use. */ -extern std::vector split_name (const char *name, +extern std::vector split_name (const char *name, split_style style); #endif /* GDB_SPLIT_NAME_H */ diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 7402a26a401..4011475f7ac 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -748,7 +748,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, if (new_name != nullptr) sym->compute_and_set_names (new_name.get (), true, objfile->per_bfd); else - sym->compute_and_set_names (gdb::string_view (string, p - string), true, + sym->compute_and_set_names (std::string_view (string, p - string), true, objfile->per_bfd); if (sym->language () == language_cplus) diff --git a/gdb/symtab.c b/gdb/symtab.c index 17d1987608f..15471554f32 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -70,7 +70,7 @@ #include "filename-seen-cache.h" #include "arch-utils.h" #include -#include "gdbsupport/gdb_string_view.h" +#include #include "gdbsupport/pathstuff.h" #include "gdbsupport/common-utils.h" @@ -828,10 +828,10 @@ general_symbol_info::set_language (enum language language, /* Objects of this type are stored in the demangled name hash table. */ struct demangled_name_entry { - demangled_name_entry (gdb::string_view mangled_name) + demangled_name_entry (std::string_view mangled_name) : mangled (mangled_name) {} - gdb::string_view mangled; + std::string_view mangled; enum language language; gdb::unique_xmalloc_ptr demangled; }; @@ -940,7 +940,7 @@ symbol_find_demangled_name (struct general_symbol_info *gsymbol, so the pointer can be discarded after calling this function. */ void -general_symbol_info::compute_and_set_names (gdb::string_view linkage_name, +general_symbol_info::compute_and_set_names (std::string_view linkage_name, bool copy_name, objfile_per_bfd_storage *per_bfd, std::optional hash) @@ -991,14 +991,14 @@ general_symbol_info::compute_and_set_names (gdb::string_view linkage_name, /* A 0-terminated copy of the linkage name. Callers must set COPY_NAME to true if the string might not be nullterminated. We have to make this copy because demangling needs a nullterminated string. */ - gdb::string_view linkage_name_copy; + std::string_view linkage_name_copy; if (copy_name) { char *alloc_name = (char *) alloca (linkage_name.length () + 1); memcpy (alloc_name, linkage_name.data (), linkage_name.length ()); alloc_name[linkage_name.length ()] = '\0'; - linkage_name_copy = gdb::string_view (alloc_name, + linkage_name_copy = std::string_view (alloc_name, linkage_name.length ()); } else @@ -1038,7 +1038,7 @@ general_symbol_info::compute_and_set_names (gdb::string_view linkage_name, memcpy (mangled_ptr, linkage_name.data (), linkage_name.length ()); mangled_ptr [linkage_name.length ()] = '\0'; new (*slot) demangled_name_entry - (gdb::string_view (mangled_ptr, linkage_name.length ())); + (std::string_view (mangled_ptr, linkage_name.length ())); } (*slot)->demangled = std::move (demangled_name); (*slot)->language = language (); diff --git a/gdb/symtab.h b/gdb/symtab.h index 0fb0c8683cb..ec2ac4942d3 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -31,7 +31,7 @@ #include "gdbsupport/enum-flags.h" #include "gdbsupport/function-view.h" #include -#include "gdbsupport/gdb_string_view.h" +#include #include "gdbsupport/next-iterator.h" #include "gdbsupport/iterator-range.h" #include "completer.h" @@ -126,11 +126,11 @@ class ada_lookup_name_info final /* A wrapper for ::split_name that handles some Ada-specific peculiarities. */ - std::vector split_name () const + std::vector split_name () const { if (m_verbatim_p || m_standard_p) { - std::vector result; + std::vector result; if (m_standard_p) result.emplace_back ("standard"); result.emplace_back (m_encoded_name); @@ -238,7 +238,7 @@ class lookup_name_info final /* Getters. See description of each corresponding field. */ symbol_name_match_type match_type () const { return m_match_type; } bool completion_mode () const { return m_completion_mode; } - gdb::string_view name () const { return m_name; } + std::string_view name () const { return m_name; } const bool ignore_parameters () const { return m_ignore_parameters; } /* Like the "name" method but guarantees that the returned string is @@ -292,7 +292,7 @@ class lookup_name_info final /* A wrapper for ::split_name (see split-name.h) that splits this name, and that handles any language-specific peculiarities. */ - std::vector split_name (language lang) const + std::vector split_name (language lang) const { if (lang == language_ada) return ada ().split_name (); @@ -356,7 +356,7 @@ class lookup_name_info final symbol_name_match_type m_match_type; bool m_completion_mode; bool m_ignore_parameters; - gdb::string_view m_name; + std::string_view m_name; /* Language-specific info. These fields are filled lazily the first time a lookup is done in the corresponding language. They're @@ -509,7 +509,7 @@ struct general_symbol_info /* Set the linkage and natural names of a symbol, by demangling the linkage name. If linkage_name may not be nullterminated, copy_name must be set to true. */ - void compute_and_set_names (gdb::string_view linkage_name, bool copy_name, + void compute_and_set_names (std::string_view linkage_name, bool copy_name, struct objfile_per_bfd_storage *per_bfd, std::optional hash = std::optional ()); diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c index b8954af36e2..84724643fd5 100644 --- a/gdb/tui/tui-io.c +++ b/gdb/tui/tui-io.c @@ -1197,7 +1197,10 @@ tui_getc_1 (FILE *fp) Compare keyname instead. */ if (ch >= KEY_MAX) { - auto name = gdb::string_view (keyname (ch)); + std::string_view name; + const char *name_str = keyname (ch); + if (name_str != nullptr) + name = std::string_view (name_str); /* The following sequences are hardcoded in readline as well. */ diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index a0a123340e3..9219c1f0184 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -54,7 +54,7 @@ #include "gdb_curses.h" #include #include "readline/readline.h" -#include "gdbsupport/gdb_string_view.h" +#include #include @@ -663,7 +663,7 @@ tui_scroll_right_command (const char *arg, int from_tty) /* Answer the window represented by name. */ static struct tui_win_info * -tui_partial_win_by_name (gdb::string_view name) +tui_partial_win_by_name (std::string_view name) { struct tui_win_info *best = nullptr; @@ -935,7 +935,7 @@ tui_set_win_size (const char *arg, bool set_width_p) buf_ptr = skip_to_space (buf_ptr); /* Validate the window name. */ - gdb::string_view wname (buf, buf_ptr - buf); + std::string_view wname (buf, buf_ptr - buf); win_info = tui_partial_win_by_name (wname); if (win_info == NULL) diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index e6ecf2a6de5..829fc1f09c7 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -2500,7 +2500,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, switch (p[1]) { case 'S': - pst->add_psymbol (gdb::string_view (namestring, + pst->add_psymbol (std::string_view (namestring, p - namestring), true, VAR_DOMAIN, LOC_STATIC, SECT_OFF_DATA (objfile), @@ -2513,7 +2513,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, case 'G': /* The addresses in these entries are reported to be wrong. See the code that reads 'G's for symtabs. */ - pst->add_psymbol (gdb::string_view (namestring, + pst->add_psymbol (std::string_view (namestring, p - namestring), true, VAR_DOMAIN, LOC_STATIC, SECT_OFF_DATA (objfile), @@ -2534,7 +2534,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, || (p == namestring + 1 && namestring[0] != ' ')) { - pst->add_psymbol (gdb::string_view (namestring, + pst->add_psymbol (std::string_view (namestring, p - namestring), true, STRUCT_DOMAIN, LOC_TYPEDEF, -1, psymbol_placement::STATIC, @@ -2544,7 +2544,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, if (p[2] == 't') { /* Also a typedef with the same name. */ - pst->add_psymbol (gdb::string_view (namestring, + pst->add_psymbol (std::string_view (namestring, p - namestring), true, VAR_DOMAIN, LOC_TYPEDEF, -1, psymbol_placement::STATIC, @@ -2559,7 +2559,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, case 't': if (p != namestring) /* a name is there, not just :T... */ { - pst->add_psymbol (gdb::string_view (namestring, + pst->add_psymbol (std::string_view (namestring, p - namestring), true, VAR_DOMAIN, LOC_TYPEDEF, -1, psymbol_placement::STATIC, @@ -2624,7 +2624,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, ; /* Note that the value doesn't matter for enum constants in psymtabs, just in symtabs. */ - pst->add_psymbol (gdb::string_view (p, q - p), true, + pst->add_psymbol (std::string_view (p, q - p), true, VAR_DOMAIN, LOC_CONST, -1, psymbol_placement::STATIC, unrelocated_addr (0), @@ -2644,7 +2644,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, case 'c': /* Constant, e.g. from "const" in Pascal. */ - pst->add_psymbol (gdb::string_view (namestring, + pst->add_psymbol (std::string_view (namestring, p - namestring), true, VAR_DOMAIN, LOC_CONST, -1, psymbol_placement::STATIC, @@ -2659,7 +2659,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, std::string name (namestring, (p - namestring)); function_outside_compilation_unit_complaint (name.c_str ()); } - pst->add_psymbol (gdb::string_view (namestring, + pst->add_psymbol (std::string_view (namestring, p - namestring), true, VAR_DOMAIN, LOC_BLOCK, SECT_OFF_TEXT (objfile), @@ -2686,7 +2686,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, if (startswith (namestring, "@FIX")) continue; - pst->add_psymbol (gdb::string_view (namestring, + pst->add_psymbol (std::string_view (namestring, p - namestring), true, VAR_DOMAIN, LOC_BLOCK, SECT_OFF_TEXT (objfile), diff --git a/gdbsupport/common-utils.h b/gdbsupport/common-utils.h index 4ceb44d88b8..1efc5bbf459 100644 --- a/gdbsupport/common-utils.h +++ b/gdbsupport/common-utils.h @@ -26,7 +26,7 @@ #include "gdbsupport/gdb_unique_ptr.h" #include "gdbsupport/array-view.h" #include "poison.h" -#include "gdb_string_view.h" +#include #if defined HAVE_LIBXXHASH # include @@ -94,7 +94,7 @@ extern const char *safe_strerror (int); true if the start of STRING matches PATTERN, false otherwise. */ static inline bool -startswith (gdb::string_view string, gdb::string_view pattern) +startswith (std::string_view string, std::string_view pattern) { return (string.length () >= pattern.length () && strncmp (string.data (), pattern.data (), pattern.length ()) == 0); @@ -228,7 +228,7 @@ fast_hash (const void *ptr, size_t len, unsigned int start_value = 0) namespace gdb { -/* Hash type for gdb::string_view. +/* Hash type for std::string_view. Even after we switch to C++17 and dump our string_view implementation, we might want to keep this hash implementation if it's faster than std::hash @@ -236,7 +236,7 @@ namespace gdb struct string_view_hash { - std::size_t operator() (gdb::string_view view) const + std::size_t operator() (std::string_view view) const { return fast_hash (view.data (), view.length ()); } }; diff --git a/gdbsupport/format.h b/gdbsupport/format.h index 2af34ab9450..26e327a60e8 100644 --- a/gdbsupport/format.h +++ b/gdbsupport/format.h @@ -20,7 +20,7 @@ #ifndef COMMON_FORMAT_H #define COMMON_FORMAT_H -#include "gdbsupport/gdb_string_view.h" +#include #if defined(__MINGW32__) && !defined(PRINTF_HAS_LONG_LONG) # define USE_PRINTF_I64 1 @@ -56,12 +56,13 @@ struct format_piece argclass (argc), n_int_args (n) { + gdb_assert (str != nullptr); } bool operator== (const format_piece &other) const { return (this->argclass == other.argclass - && gdb::string_view (this->string) == other.string); + && std::string_view (this->string) == other.string); } const char *string; diff --git a/gdbsupport/gdb_string_view.h b/gdbsupport/gdb_string_view.h index 26a3a9f0910..cf7af623327 100644 --- a/gdbsupport/gdb_string_view.h +++ b/gdbsupport/gdb_string_view.h @@ -556,7 +556,7 @@ namespace gdb { namespace gdb { static inline std::string -to_string(const gdb::string_view &view) +to_string(const std::string_view &view) { return { view.data (), view.size () }; } From patchwork Tue Nov 21 12:04:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lancelot SIX X-Patchwork-Id: 80463 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0E2F93858029 for ; Tue, 21 Nov 2023 12:07:00 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2056.outbound.protection.outlook.com [40.107.223.56]) by sourceware.org (Postfix) with ESMTPS id EFD53385828C for ; Tue, 21 Nov 2023 12:05:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EFD53385828C Authentication-Results: sourceware.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=amd.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EFD53385828C Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.223.56 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1700568361; cv=pass; b=ryLbSwpEYl+uoM1mkAlC8scmuEltEHq+8ieQSTuEUPdrjFacWHHYdH+O++zAaIVGs66IMgvp1qidS+gkaCikjYUwL+jv2/4srTJh7vX9eUiQeNOc/HWcGQ9hA/9gV2Yt6fhNNDicIwgGPX/mEbwa0QZYmSoorL47GmhCx8ucxgA= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1700568361; c=relaxed/simple; bh=IJ3sopvqL9ITvwl0PSiMXwVI3M5dkW9YFDDl18UI+rY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=BVnhWIsXdhMe8DsKDfzpYTpaLFBqx/RIHd6Pqf81IvKC4POul6CLJ+NqgaSEasLmJLrpfqHX6F2FtE2a0AANLzVWiOVYX/Cphu/ygBwqQSnecqw0RoHcNuCyx+Hqnx2PXfPthG8bXrv/07C/GVkkYQ+44DwlWntOcRQYknwKJD8= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PMudinFVkdnuApT46MIcpqH0KHDklg8Phns8RRJEHalsIIlANE6uWSnSzyQWi+kNpG2DP6qzqQ2RAH8quuguZfNHfFfS8PJGFV4OxgynSHlNRulQVKJbAIkplW+2edCBICxoTmp9PhZM3YQkjT/8RwckroFP44oAjoedWXYM0nzt4SwR1acAg9Vas6zG7qi9rprz2ij4cHTqapJW0/U3ox61O/ZiXGHEejcmtp4NUhHxtp6cssoq8wU2gM0vbtEAVOe57Thwql/lI1g9gocL3mXPsZEtQ9IKydxZZonmfouu7tppkQpD7+toxjUvVLIunf6XWEH6C9a46wNR4fevig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=iF0AlYRLx7oUncqxsxcHgI6IgNf51ZJPVc2PTLEQkZI=; b=ZnFa6OPMXSDMk8byUA6cY2e4b3rXWSucggPgralutOh2Uliru/7bwg7mHa7CyyOgs5VgFDXJkCV9+8MQ+olOmNVLPZvspzIqr9XuhpJgI5G236oLaa3XNzHec/ar+hTa7qsMX8SZhRls2WtVBcb765/Wo4cHGJ8jKnsFCdeNtnlAR54B/Ze2a3XN8vWncYoFy5b4fKCjca8vQACsXMbo6pITmZeNHo7L8cIkn4ADWdTe3ID+5DT1mgAmMah2uEiBmXbjFhn7fke7fztSOE2BKPXoguBYyiEo1J7mGaNbYyxm1VjAAoqZqUJzvgWpxGLolkPvafpn9pV+1fA1bjwxcA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=sourceware.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iF0AlYRLx7oUncqxsxcHgI6IgNf51ZJPVc2PTLEQkZI=; b=cQizg46LMB2QcspXke/GlNVzChUJ3nlQkZ/63JbzpZcIBdKWKNkCfvQ/Ay2Ot54Bor/TSUb+M9PO3eXXqB+9sNCrc8YnsqGN+tM+LtnT5ytfpNlLUqdYXt7Bs1fNZVZVLkIL+xUiApiXzw4CJtu87xWHa9S6lFlt66yY3RO72Rs= Received: from MN2PR12CA0034.namprd12.prod.outlook.com (2603:10b6:208:a8::47) by DM6PR12MB4499.namprd12.prod.outlook.com (2603:10b6:5:2ab::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.28; Tue, 21 Nov 2023 12:05:54 +0000 Received: from MN1PEPF0000F0E4.namprd04.prod.outlook.com (2603:10b6:208:a8:cafe::59) by MN2PR12CA0034.outlook.office365.com (2603:10b6:208:a8::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.27 via Frontend Transport; Tue, 21 Nov 2023 12:05:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MN1PEPF0000F0E4.mail.protection.outlook.com (10.167.242.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7025.12 via Frontend Transport; Tue, 21 Nov 2023 12:05:54 +0000 Received: from hpe6u-23.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Tue, 21 Nov 2023 06:05:51 -0600 From: Lancelot Six To: CC: , , Lancelot Six Subject: [COMMITTED PATCH v2 5/9] gdb: Remove uses of gdb::to_string (const std::string_view &) Date: Tue, 21 Nov 2023 12:04:56 +0000 Message-ID: <20231121120500.1394523-6-lancelot.six@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028204821.fp5hh7bahrmrnpjl@hpe6u-23> References: <20231028204821.fp5hh7bahrmrnpjl@hpe6u-23> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000F0E4:EE_|DM6PR12MB4499:EE_ X-MS-Office365-Filtering-Correlation-Id: 1509ab23-0159-4719-b467-08dbea8a3650 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vxVFtl4pgKtI9S0QupzpJ7WackJQv/7Fi2eFM9uf3Q7PxhlwThpq2VsrU8ziDs/pABv5DPpdA+ESfhBvI9GjJMYxc7Uvd6OwoFprWn4K5F4eGbfWxEwdhwjyl11GFHvu1oJghitVR5PpTLTFx/CCpmeN+Lss+QbisvI6fnNK4GKQXdQirciJCQNj9cPNgaAUcvaz32MSLvuM91M7k3+kk4V3r0fF6dh7QB6edjWFOrdb3kwojrKV7uV5ve1qun0WkZG9J7HnX42mxwWi0fj/e20rtBDeqfPnfKWDmcNvhSwGdXS/Alp5S3k7WFvh9rWfuxsmGreuaPAvQpvLs76zwjb8MlpJt2zPAa1TYZ/fhwkaMNkN7sTYS1QKQvg7mYRv1ghfejVW9FSyOU9DQH5jxsHm8sgCRFIVkzkpIiJty1DUVqFIQxDGCqcsl9DQ4QYmywhMR4cUVN9wzJJR6FoCqAg0oEzwd/hrBqb5N7Wb9cbsrRqKj7pcLzVMVuiB+7W3aXulG3WwL/4mPxWfDRbHH7xyvJecpwQqtUk1nc+tlm5Mk31a68c9TOzPMhpEe6Cm7yNOv0YI2jW/m4waw9pnT5O55CWstUfKQh6Du27WxvzeGiu9+rpa5WgUk0IJ+MfQXVAXyTJqWTTlkLThrk37ma1zvTKqMpDjPyzkS1PAdj8w/4KWNmt5JPm1JhvzAQihuWF4QbzU1JrNOV6vdCaAzXvzE4/24s5mMocYm6FILYSs8MlgZR216c0mU/fjq3nSaAVCi07Mj8S6QaP8Jy6haan4UXzPZeTKmYqEpzzliS1fcRmUyW5Ccw3DYpJIx2Dl X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(376002)(346002)(396003)(136003)(39860400002)(230273577357003)(230173577357003)(230922051799003)(451199024)(64100799003)(186009)(82310400011)(1800799012)(36840700001)(46966006)(40470700004)(40460700003)(83380400001)(426003)(336012)(26005)(16526019)(1076003)(47076005)(36860700001)(8676002)(4326008)(8936002)(44832011)(2906002)(30864003)(5660300002)(41300700001)(478600001)(70586007)(7696005)(70206006)(6916009)(54906003)(316002)(36756003)(81166007)(86362001)(82740400003)(356005)(2616005)(40480700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 12:05:54.0233 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1509ab23-0159-4719-b467-08dbea8a3650 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MN1PEPF0000F0E4.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4499 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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: 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+patchwork=sourceware.org@sourceware.org This patch removes all uses of to_string(const std::string_view&) and use the std::string ctor or implicit conversion from std::string_view to std::string instead. A later patch will remove this gdb::to_string while removing gdbsupport/gdb_string_view.h. Change-Id: I877cde557a0727be7b0435107e3c7a2aac165895 Approved-By: Tom Tromey Approved-By: Pedro Alves --- gdb/ada-lang.c | 21 +++++++++------------ gdb/amdgpu-tdep.c | 19 +++++++++---------- gdb/debuginfod-support.c | 4 +--- gdb/dwarf2/read.c | 3 +-- gdb/eval.c | 1 - gdb/solib-rocm.c | 9 ++++----- 6 files changed, 24 insertions(+), 33 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 843583ecb40..ff7222c7eed 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -58,7 +58,6 @@ #include "gdbsupport/function-view.h" #include "gdbsupport/byte-vector.h" #include "gdbsupport/selftest.h" -#include "gdbsupport/gdb_string_view.h" #include #include "ada-exp.h" #include "charset.h" @@ -1041,7 +1040,7 @@ ada_fold_name (std::string_view name, bool throw_on_error = false) static std::string fold_storage; if (!name.empty () && name[0] == '\'') - fold_storage = gdb::to_string (name.substr (1, name.size () - 2)); + fold_storage = name.substr (1, name.size () - 2); else { /* Why convert to UTF-32 and implement our own case-folding, @@ -1082,12 +1081,12 @@ ada_fold_name (std::string_view name, bool throw_on_error = false) warned = true; warning (_("could not convert '%s' from the host encoding (%s) to UTF-32.\n" "This normally should not happen, please file a bug report."), - gdb::to_string (name).c_str (), host_charset ()); + std::string (name).c_str (), host_charset ()); } /* We don't try to recover from errors; just return the original string. */ - fold_storage = gdb::to_string (name); + fold_storage = name; return fold_storage.c_str (); } @@ -1136,12 +1135,12 @@ ada_fold_name (std::string_view name, bool throw_on_error = false) warned = true; warning (_("could not convert the lower-cased variant of '%s'\n" "from UTF-32 to the host encoding (%s)."), - gdb::to_string (name).c_str (), host_charset ()); + std::string (name).c_str (), host_charset ()); } /* We don't try to recover from errors; just return the original string. */ - fold_storage = gdb::to_string (name); + fold_storage = name; } } @@ -13256,11 +13255,9 @@ ada_lookup_name_info::ada_lookup_name_info (const lookup_name_info &lookup_name) if (!user_name.empty () && user_name[0] == '<') { if (user_name.back () == '>') - m_encoded_name - = gdb::to_string (user_name.substr (1, user_name.size () - 2)); + m_encoded_name = user_name.substr (1, user_name.size () - 2); else - m_encoded_name - = gdb::to_string (user_name.substr (1, user_name.size () - 1)); + m_encoded_name = user_name.substr (1, user_name.size () - 1); m_encoded_p = true; m_verbatim_p = true; m_wild_match_p = false; @@ -13277,10 +13274,10 @@ ada_lookup_name_info::ada_lookup_name_info (const lookup_name_info &lookup_name) const char *folded = ada_fold_name (user_name); m_encoded_name = ada_encode_1 (folded, false); if (m_encoded_name.empty ()) - m_encoded_name = gdb::to_string (user_name); + m_encoded_name = user_name; } else - m_encoded_name = gdb::to_string (user_name); + m_encoded_name = user_name; /* Handle the 'package Standard' special case. See description of m_standard_p. */ diff --git a/gdb/amdgpu-tdep.c b/gdb/amdgpu-tdep.c index 58d26fc0b6b..15f32885b07 100644 --- a/gdb/amdgpu-tdep.c +++ b/gdb/amdgpu-tdep.c @@ -27,7 +27,6 @@ #include "frame-unwind.h" #include "gdbarch.h" #include "gdbsupport/selftest.h" -#include "gdbsupport/gdb_string_view.h" #include "gdbtypes.h" #include "inferior.h" #include "objfiles.h" @@ -402,7 +401,7 @@ parse_amd_dbgapi_register_type_enum_fields if (value > std::numeric_limits::max ()) enum_type.set_bit_size (64); - enum_type.add_enumerator (gdb::to_string (name), value); + enum_type.add_enumerator (std::string (name), value); fields = fields.substr (matches[0].rm_eo); } @@ -446,7 +445,7 @@ parse_amd_dbgapi_register_type_flags_fields ULONGEST pos_begin = try_strtoulst (pos_begin_str); if (field_type_str == "bool") - flags_type.add_field (gdb::to_string (field_name), pos_begin, pos_begin, + flags_type.add_field (std::string (field_name), pos_begin, pos_begin, nullptr); else { @@ -457,7 +456,7 @@ parse_amd_dbgapi_register_type_flags_fields ULONGEST pos_end = try_strtoulst (pos_end_str.substr (1)); const amd_dbgapi_register_type &field_type = parse_amd_dbgapi_register_type (field_type_str, type_map); - flags_type.add_field (gdb::to_string (field_name), pos_begin, pos_end, + flags_type.add_field (std::string (field_name), pos_begin, pos_end, &field_type); } @@ -471,7 +470,7 @@ static const amd_dbgapi_register_type & parse_amd_dbgapi_register_type_scalar (std::string_view name, amd_dbgapi_register_type_map &type_map) { - std::string name_str = gdb::to_string (name); + std::string name_str (name); auto it = type_map.find (name_str); if (it != type_map.end ()) { @@ -534,7 +533,7 @@ parse_amd_dbgapi_register_type (std::string_view type_str, std::string_view count_str_view = type_str.substr (pos_open_bracket + 1, pos_close_bracket - pos_open_bracket); - std::string count_str = gdb::to_string (count_str_view); + std::string count_str (count_str_view); unsigned int count = std::stoul (count_str); std::string lookup_name @@ -580,7 +579,7 @@ parse_amd_dbgapi_register_type (std::string_view type_str, /* No braces, lookup existing type. */ if (existing_type_it == type_map.end ()) error (_("reference to unknown type %s."), - gdb::to_string (name).c_str ()); + std::string (name).c_str ()); if (existing_type_it->second->kind () != amd_dbgapi_register_type::kind::FLAGS) @@ -593,7 +592,7 @@ parse_amd_dbgapi_register_type (std::string_view type_str, /* With braces, it's a definition. */ if (existing_type_it != type_map.end ()) error (_("re-definition of type %s."), - gdb::to_string (name).c_str ()); + std::string (name).c_str ()); amd_dbgapi_register_type_flags_up flags_type (new amd_dbgapi_register_type_flags (bit_size, name)); @@ -632,7 +631,7 @@ parse_amd_dbgapi_register_type (std::string_view type_str, /* No braces, lookup existing type. */ if (existing_type_it == type_map.end ()) error (_("reference to unknown type %s"), - gdb::to_string (name).c_str ()); + std::string (name).c_str ()); if (existing_type_it->second->kind () != amd_dbgapi_register_type::kind::ENUM) @@ -645,7 +644,7 @@ parse_amd_dbgapi_register_type (std::string_view type_str, /* With braces, it's a definition. */ if (existing_type_it != type_map.end ()) error (_("re-definition of type %s"), - gdb::to_string (name).c_str ()); + std::string (name).c_str ()); amd_dbgapi_register_type_enum_up enum_type (new amd_dbgapi_register_type_enum (name)); diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c index a989eb9cb97..eb88c406ad6 100644 --- a/gdb/debuginfod-support.c +++ b/gdb/debuginfod-support.c @@ -20,7 +20,6 @@ #include "diagnostics.h" #include #include "gdbsupport/scoped_fd.h" -#include "gdbsupport/gdb_string_view.h" #include "debuginfod-support.h" #include #include "cli/cli-cmds.h" @@ -265,8 +264,7 @@ debuginfod_is_enabled () gdb_printf (_(" <%ps>\n"), styled_string (file_name_style.style (), - gdb::to_string (url_view.substr (0, - off)).c_str ())); + std::string (url_view.substr (0, off)).c_str ())); if (off == std::string_view::npos) break; url_view = url_view.substr (off); diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index a16139dad1e..ccf9f18b31b 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -96,7 +96,6 @@ #include "split-name.h" #include "gdbsupport/parallel-for.h" #include "gdbsupport/thread-pool.h" -#include "gdbsupport/gdb_string_view.h" /* When == 1, print basic high level tracing messages. When > 1, be more verbose. @@ -16770,7 +16769,7 @@ cooked_index_functions::expand_symtabs_matching { std::vector name_vec = lookup_name_without_params.split_name (lang); - std::string last_name = gdb::to_string (name_vec.back ()); + std::string last_name (name_vec.back ()); for (const cooked_index_entry *entry : table->find (last_name, completing)) diff --git a/gdb/eval.c b/gdb/eval.c index 8664d4980b7..3358b0d8d32 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -37,7 +37,6 @@ #include "user-regs.h" #include "valprint.h" #include "gdbsupport/gdb_obstack.h" -#include "gdbsupport/gdb_string_view.h" #include "objfiles.h" #include "typeprint.h" #include diff --git a/gdb/solib-rocm.c b/gdb/solib-rocm.c index 9ceb7a922e3..0384e52d58a 100644 --- a/gdb/solib-rocm.c +++ b/gdb/solib-rocm.c @@ -31,7 +31,6 @@ #include "solib-svr4.h" #include "solist.h" #include "symfile.h" -#include "gdbsupport/gdb_string_view.h" #include @@ -440,7 +439,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior) std::string_view uri (bfd_get_filename (abfd)); std::string_view protocol_delim = "://"; size_t protocol_end = uri.find (protocol_delim); - std::string protocol = gdb::to_string (uri.substr (0, protocol_end)); + std::string protocol (uri.substr (0, protocol_end)); protocol_end += protocol_delim.length (); std::transform (protocol.begin (), protocol.end (), protocol.begin (), @@ -463,7 +462,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior) && std::isxdigit (path[i + 2])) { std::string_view hex_digits = path.substr (i + 1, 2); - decoded_path += std::stoi (gdb::to_string (hex_digits), 0, 16); + decoded_path += std::stoi (std::string (hex_digits), 0, 16); i += 2; } else @@ -549,7 +548,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior) if (pid != inferior->pid) { warning (_("`%s': code object is from another inferior"), - gdb::to_string (uri).c_str ()); + std::string (uri).c_str ()); bfd_set_error (bfd_error_bad_value); return nullptr; } @@ -566,7 +565,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior) } warning (_("`%s': protocol not supported: %s"), - gdb::to_string (uri).c_str (), protocol.c_str ()); + std::string (uri).c_str (), protocol.c_str ()); bfd_set_error (bfd_error_bad_value); return nullptr; } From patchwork Tue Nov 21 12:04:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lancelot SIX X-Patchwork-Id: 80468 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4F3763858C29 for ; Tue, 21 Nov 2023 12:08:31 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2076.outbound.protection.outlook.com [40.107.92.76]) by sourceware.org (Postfix) with ESMTPS id 2D1DA3858037 for ; Tue, 21 Nov 2023 12:06:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2D1DA3858037 Authentication-Results: sourceware.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=amd.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2D1DA3858037 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.92.76 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1700568369; cv=pass; b=qNZF0kxJRyH19hIe3NAoyg8xC0jMU5T59EsUuCLJzpTtV18Z9h070aJ3kSp/stUooG7VOxd4t9okQPFT1ghpBPNfzYpSgPMvELhw7y9djC9TZIe09iaIFKQIbqvld1ltbBqTOHA9CAIfDrxV6suxt6gIDKube9W298oQxzXNhUQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1700568369; c=relaxed/simple; bh=1l0oPZkq4ahe7zwVi/6QVIRyDr0osE9F3W9Sal6xLQI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=nq+UFhFjTCQ80/Nr7jllowOePPNc/GJFlY0pj3LjcSAQnIMW3kk0aXjSDUpUsMdP7Zc/LeSKn8qXFy/k/D8czVswqD0b09mk5ES37CQmyrvgyoLIhRuBJbkEH3KZ+o11L4vQwmhDEVXo/OGK8yjPr8k1TSZ1lLmCrexdszT8txA= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D2KhWYQ23pjMGp+Z+VMUvSqHUpydNLJ7mepzqWuOJb9gVHNS7I/dpr/EPwbGNq3cm+UyPjP1sWvIPu44yItLiv8RTWjl7TXpPy2Kzv4BK75UDUZ+Lgz7nd6vOyVbRL/IM3jYfIpfQQBzYd/BVeBzirQUJDzMSFeEwTVVg/1F6/ulYmfZjmqS6Xw3TjuX0tD67BKWFSBdTERLcxpdYUfUUUOE4VdLxUJDk3eMbPU3hsrsbVvoSsScj/oMtwD+5Tt5IZseE4us4N5k9TcHl7PH/mh16RE3rU7LNY655uL6C3dQOBTi3iBqNrNAMeoCSTa5+sRo8kA3+W77pwhbx6bqJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bB0sgpescX3Ea8zfgwjilJc/9RfiRNcsyxvFv4dyRv8=; b=PevYjbWk7E7kZK1mMh3nQn9GUzb4XpntXUeHalqFs418QUEU9DvxT/MNEFDXJ9P7h3za0bPiA+AI+6kb2enytHDHGZVXM0QpdPBRT52W6i5nkvtRQWNvo67/DJWSU5E4MjPrnzmlEXW9g7joofBltFWfr/D1b5cwgjKvZpxhlmWTiUk748jfiuj8BxInmw7bQbM8WteR3yQyEKqup+alt+kRosQdom+GibBYrE32HyAxfi8lle1Fv/gb1helCq/Oxpw8GyNXUCmZF0EKUkuZfbFJwjPZlwaHRu3GIeuQi9/dIsLF3mFLBpjA0ZtwYNxD0d0oid5uvyM2gG4X3563qQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=sourceware.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bB0sgpescX3Ea8zfgwjilJc/9RfiRNcsyxvFv4dyRv8=; b=gzF14b8nczPGKUS8i9wcuDYSpQ4dPgt3CvpF2KzANIsx6QrgFfkeWDkrpnzDkalejqlOtbV5SiK0OJKILsEOJ8jtfi1Z08+jX0aiVxNIyA8LWoMgyAkDvAIJWmKUO+VTJJFEsHKUQvqMDAz4dX/JziVxaEvzJe6kWeNuNkhkhvM= Received: from BL1PR13CA0349.namprd13.prod.outlook.com (2603:10b6:208:2c6::24) by CY5PR12MB6036.namprd12.prod.outlook.com (2603:10b6:930:2c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.28; Tue, 21 Nov 2023 12:05:54 +0000 Received: from MN1PEPF0000F0E1.namprd04.prod.outlook.com (2603:10b6:208:2c6:cafe::92) by BL1PR13CA0349.outlook.office365.com (2603:10b6:208:2c6::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.16 via Frontend Transport; Tue, 21 Nov 2023 12:05:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MN1PEPF0000F0E1.mail.protection.outlook.com (10.167.242.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7025.12 via Frontend Transport; Tue, 21 Nov 2023 12:05:54 +0000 Received: from hpe6u-23.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Tue, 21 Nov 2023 06:05:52 -0600 From: Lancelot Six To: CC: , , Lancelot Six Subject: [COMMITTED PATCH v2 6/9] gdbsupport: Remove gdb::string_view Date: Tue, 21 Nov 2023 12:04:57 +0000 Message-ID: <20231121120500.1394523-7-lancelot.six@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028204821.fp5hh7bahrmrnpjl@hpe6u-23> References: <20231028204821.fp5hh7bahrmrnpjl@hpe6u-23> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000F0E1:EE_|CY5PR12MB6036:EE_ X-MS-Office365-Filtering-Correlation-Id: 8a597e05-5662-46eb-841e-08dbea8a3680 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Kkg8KMyCIyAfG5dYgUVxoyBNQV3xY8vnZMDEYoTkmn7m93NpHDL19Fc0C8nb2YSrjMRv9WO2rwSWOgl+tBgubqebhKUudOHcultNh1oj/rVY48WqY+ZOTNEbrWCg+tsHmqgQztSsE0aFI1/Y+LEHr/qnGG3ElKvkj2xQQ5weiwD9p3CBkNKOaf+R8Q3/M9NySP++nFFWj1M0XIcRjDSghRIDK24CxEqXI/ntQlcunlzwT/h70CYquAKLt7fht/ftBpwvLpjnLUPDGHr2laykURsyvkl0bYCGbon94wL2UirCoqR2f+127ooRGStEz3zzGjJQaSZYyHD5KEnI4asCTzCN6GI/W9392+/wPFxgZPB4ngfVO+ynzc/VondPXBaUvB6QhtmW68nKw0XyLcs+EcPETj5hPFOSWUIusxZWnxJh9+WTEEkAhwt3qfk2PiVhuuxQAOyzZx8KI+RnNZvenit+2bD1HmYPO+6e6unIryBgAEKhuCsT8gAV9hL2qht7dZJpQroRWPbaS75oGx3CTg6pLzwWyC1yVD/+CO1JI+kxqBriqWhWamaqFyxPF4XK6wXZ61veL0w59q2YgGpbqWSdfXm7dQo0X3YALE86KKAeVxKe8XtNG+7iOFQPt8pdhF72fykGSGO7o+r36PmvDE1bbr2O8ELY4lfP2JAZaAWK2IBh0HgjX5kiVlx5FkdUyDEMfeVhGy1GN7jJY3NDcr340NVZ5a5hbxWT08bYzHNPdOAMUQjY+3lISB1rT7yhELHzeRq9PKR6kSnNmFA5sPlc13Q6XoOL7+SjXgWTNxM767r/GGsEpXr33p1aFI1/giKEJeHVSFv1GZXAQDPSF/WaSj0gjUBZ8smpDTivYKE= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(39860400002)(136003)(376002)(396003)(346002)(230273577357003)(230173577357003)(230922051799003)(64100799003)(186009)(1800799012)(82310400011)(451199024)(40470700004)(46966006)(36840700001)(40480700001)(40460700003)(54906003)(70586007)(70206006)(36756003)(82740400003)(356005)(81166007)(86362001)(36860700001)(336012)(26005)(83380400001)(16526019)(1076003)(7696005)(2616005)(966005)(2906002)(426003)(6916009)(316002)(478600001)(41300700001)(8676002)(4326008)(5660300002)(47076005)(44832011)(8936002)(30864003)(2004002)(36900700001)(579004)(559001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 12:05:54.3366 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8a597e05-5662-46eb-841e-08dbea8a3680 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MN1PEPF0000F0E1.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6036 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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: 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+patchwork=sourceware.org@sourceware.org Now that all places using gdb::string_view have been updated to use std::string_view, this patch drops the gdb::string_view implementation and the tests which came with it. As this drops the unittests/string_view-selftests.c, this also implicitly solves PR build/23676, as pointed-out by Tom Tromey. Change-Id: Idf5479b09e0ac536917b3f0e13aca48424b90df0 Approved-By: Tom Tromey Approved-By: Pedro Alves Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=23676 --- gdb/Makefile.in | 1 - gdb/unittests/basic_string_view/capacity/1.cc | 172 ------ .../basic_string_view/capacity/empty_neg.cc | 28 - .../basic_string_view/cons/char/1.cc | 67 --- .../basic_string_view/cons/char/2.cc | 46 -- .../basic_string_view/cons/char/3.cc | 39 -- .../basic_string_view/cons/wchar_t/1.cc | 68 --- .../basic_string_view/cons/wchar_t/2.cc | 45 -- .../basic_string_view/cons/wchar_t/3.cc | 38 -- .../element_access/char/1.cc | 70 --- .../element_access/char/2.cc | 30 - .../element_access/char/empty.cc | 39 -- .../element_access/char/front_back.cc | 43 -- .../element_access/wchar_t/1.cc | 71 --- .../element_access/wchar_t/2.cc | 32 - .../element_access/wchar_t/empty.cc | 38 -- .../element_access/wchar_t/front_back.cc | 42 -- gdb/unittests/basic_string_view/include.cc | 25 - .../basic_string_view/inserters/char/1.cc | 65 -- .../basic_string_view/inserters/char/2.cc | 91 --- .../basic_string_view/inserters/char/3.cc | 54 -- .../inserters/pod/10081-out.cc | 75 --- .../basic_string_view/inserters/wchar_t/1.cc | 70 --- .../basic_string_view/inserters/wchar_t/2.cc | 91 --- .../basic_string_view/inserters/wchar_t/3.cc | 53 -- .../basic_string_view/literals/types.cc | 45 -- .../basic_string_view/literals/values.cc | 72 --- .../modifiers/remove_prefix/char/1.cc | 66 -- .../modifiers/remove_prefix/wchar_t/1.cc | 61 -- .../modifiers/remove_suffix/char/1.cc | 66 -- .../modifiers/remove_suffix/wchar_t/1.cc | 61 -- .../modifiers/swap/char/1.cc | 36 -- .../modifiers/swap/wchar_t/1.cc | 35 -- .../operations/compare/char/1.cc | 132 ---- .../operations/compare/char/13650.cc | 50 -- .../operations/compare/char/2.cc | 30 - .../operations/compare/char/70483.cc | 89 --- .../operations/compare/wchar_t/1.cc | 133 ---- .../operations/compare/wchar_t/13650.cc | 49 -- .../operations/compare/wchar_t/2.cc | 30 - .../operations/copy/char/1.cc | 46 -- .../operations/copy/wchar_t/1.cc | 46 -- .../operations/data/char/1.cc | 44 -- .../operations/data/wchar_t/1.cc | 43 -- .../operations/find/char/1.cc | 168 ------ .../operations/find/char/2.cc | 166 ----- .../operations/find/char/3.cc | 166 ----- .../operations/find/char/4.cc | 45 -- .../operations/find/wchar_t/1.cc | 163 ----- .../operations/find/wchar_t/2.cc | 161 ----- .../operations/find/wchar_t/3.cc | 161 ----- .../operations/find/wchar_t/4.cc | 44 -- .../operations/rfind/char/1.cc | 95 --- .../operations/rfind/char/2.cc | 53 -- .../operations/rfind/char/3.cc | 68 --- .../operations/rfind/wchar_t/1.cc | 94 --- .../operations/rfind/wchar_t/2.cc | 52 -- .../operations/rfind/wchar_t/3.cc | 66 -- .../operations/string_conversion/1.cc | 51 -- .../operations/substr/char/1.cc | 79 --- .../operations/substr/wchar_t/1.cc | 79 --- .../basic_string_view/operators/char/2.cc | 373 ------------ .../basic_string_view/operators/wchar_t/2.cc | 367 ------------ .../basic_string_view/range_access/char/1.cc | 47 -- .../range_access/wchar_t/1.cc | 47 -- .../requirements/explicit_instantiation/1.cc | 26 - .../explicit_instantiation/char/1.cc | 23 - .../explicit_instantiation/char16_t/1.cc | 24 - .../explicit_instantiation/char32_t/1.cc | 24 - .../explicit_instantiation/wchar_t/1.cc | 23 - .../requirements/typedefs.cc | 47 -- gdb/unittests/basic_string_view/typedefs.cc | 36 -- gdb/unittests/basic_string_view/types/1.cc | 43 -- gdb/unittests/string_view-selftests.c | 193 ------ gdbsupport/gdb_string_view.h | 566 ------------------ gdbsupport/gdb_string_view.tcc | 219 ------- 76 files changed, 6296 deletions(-) delete mode 100644 gdb/unittests/basic_string_view/capacity/1.cc delete mode 100644 gdb/unittests/basic_string_view/capacity/empty_neg.cc delete mode 100644 gdb/unittests/basic_string_view/cons/char/1.cc delete mode 100644 gdb/unittests/basic_string_view/cons/char/2.cc delete mode 100644 gdb/unittests/basic_string_view/cons/char/3.cc delete mode 100644 gdb/unittests/basic_string_view/cons/wchar_t/1.cc delete mode 100644 gdb/unittests/basic_string_view/cons/wchar_t/2.cc delete mode 100644 gdb/unittests/basic_string_view/cons/wchar_t/3.cc delete mode 100644 gdb/unittests/basic_string_view/element_access/char/1.cc delete mode 100644 gdb/unittests/basic_string_view/element_access/char/2.cc delete mode 100644 gdb/unittests/basic_string_view/element_access/char/empty.cc delete mode 100644 gdb/unittests/basic_string_view/element_access/char/front_back.cc delete mode 100644 gdb/unittests/basic_string_view/element_access/wchar_t/1.cc delete mode 100644 gdb/unittests/basic_string_view/element_access/wchar_t/2.cc delete mode 100644 gdb/unittests/basic_string_view/element_access/wchar_t/empty.cc delete mode 100644 gdb/unittests/basic_string_view/element_access/wchar_t/front_back.cc delete mode 100644 gdb/unittests/basic_string_view/include.cc delete mode 100644 gdb/unittests/basic_string_view/inserters/char/1.cc delete mode 100644 gdb/unittests/basic_string_view/inserters/char/2.cc delete mode 100644 gdb/unittests/basic_string_view/inserters/char/3.cc delete mode 100644 gdb/unittests/basic_string_view/inserters/pod/10081-out.cc delete mode 100644 gdb/unittests/basic_string_view/inserters/wchar_t/1.cc delete mode 100644 gdb/unittests/basic_string_view/inserters/wchar_t/2.cc delete mode 100644 gdb/unittests/basic_string_view/inserters/wchar_t/3.cc delete mode 100644 gdb/unittests/basic_string_view/literals/types.cc delete mode 100644 gdb/unittests/basic_string_view/literals/values.cc delete mode 100644 gdb/unittests/basic_string_view/modifiers/remove_prefix/char/1.cc delete mode 100644 gdb/unittests/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc delete mode 100644 gdb/unittests/basic_string_view/modifiers/remove_suffix/char/1.cc delete mode 100644 gdb/unittests/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc delete mode 100644 gdb/unittests/basic_string_view/modifiers/swap/char/1.cc delete mode 100644 gdb/unittests/basic_string_view/modifiers/swap/wchar_t/1.cc delete mode 100644 gdb/unittests/basic_string_view/operations/compare/char/1.cc delete mode 100644 gdb/unittests/basic_string_view/operations/compare/char/13650.cc delete mode 100644 gdb/unittests/basic_string_view/operations/compare/char/2.cc delete mode 100644 gdb/unittests/basic_string_view/operations/compare/char/70483.cc delete mode 100644 gdb/unittests/basic_string_view/operations/compare/wchar_t/1.cc delete mode 100644 gdb/unittests/basic_string_view/operations/compare/wchar_t/13650.cc delete mode 100644 gdb/unittests/basic_string_view/operations/compare/wchar_t/2.cc delete mode 100644 gdb/unittests/basic_string_view/operations/copy/char/1.cc delete mode 100644 gdb/unittests/basic_string_view/operations/copy/wchar_t/1.cc delete mode 100644 gdb/unittests/basic_string_view/operations/data/char/1.cc delete mode 100644 gdb/unittests/basic_string_view/operations/data/wchar_t/1.cc delete mode 100644 gdb/unittests/basic_string_view/operations/find/char/1.cc delete mode 100644 gdb/unittests/basic_string_view/operations/find/char/2.cc delete mode 100644 gdb/unittests/basic_string_view/operations/find/char/3.cc delete mode 100644 gdb/unittests/basic_string_view/operations/find/char/4.cc delete mode 100644 gdb/unittests/basic_string_view/operations/find/wchar_t/1.cc delete mode 100644 gdb/unittests/basic_string_view/operations/find/wchar_t/2.cc delete mode 100644 gdb/unittests/basic_string_view/operations/find/wchar_t/3.cc delete mode 100644 gdb/unittests/basic_string_view/operations/find/wchar_t/4.cc delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/char/1.cc delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/char/2.cc delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/char/3.cc delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/wchar_t/1.cc delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/wchar_t/2.cc delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/wchar_t/3.cc delete mode 100644 gdb/unittests/basic_string_view/operations/string_conversion/1.cc delete mode 100644 gdb/unittests/basic_string_view/operations/substr/char/1.cc delete mode 100644 gdb/unittests/basic_string_view/operations/substr/wchar_t/1.cc delete mode 100644 gdb/unittests/basic_string_view/operators/char/2.cc delete mode 100644 gdb/unittests/basic_string_view/operators/wchar_t/2.cc delete mode 100644 gdb/unittests/basic_string_view/range_access/char/1.cc delete mode 100644 gdb/unittests/basic_string_view/range_access/wchar_t/1.cc delete mode 100644 gdb/unittests/basic_string_view/requirements/explicit_instantiation/1.cc delete mode 100644 gdb/unittests/basic_string_view/requirements/explicit_instantiation/char/1.cc delete mode 100644 gdb/unittests/basic_string_view/requirements/explicit_instantiation/char16_t/1.cc delete mode 100644 gdb/unittests/basic_string_view/requirements/explicit_instantiation/char32_t/1.cc delete mode 100644 gdb/unittests/basic_string_view/requirements/explicit_instantiation/wchar_t/1.cc delete mode 100644 gdb/unittests/basic_string_view/requirements/typedefs.cc delete mode 100644 gdb/unittests/basic_string_view/typedefs.cc delete mode 100644 gdb/unittests/basic_string_view/types/1.cc delete mode 100644 gdb/unittests/string_view-selftests.c delete mode 100644 gdbsupport/gdb_string_view.h delete mode 100644 gdbsupport/gdb_string_view.tcc diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 714564f27b4..a50628e8ed0 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -482,7 +482,6 @@ SELFTESTS_SRCS = \ unittests/scoped_mmap-selftests.c \ unittests/scoped_restore-selftests.c \ unittests/search-memory-selftests.c \ - unittests/string_view-selftests.c \ unittests/style-selftests.c \ unittests/tracepoint-selftests.c \ unittests/tui-selftests.c \ diff --git a/gdb/unittests/basic_string_view/capacity/1.cc b/gdb/unittests/basic_string_view/capacity/1.cc deleted file mode 100644 index 12470a98279..00000000000 --- a/gdb/unittests/basic_string_view/capacity/1.cc +++ /dev/null @@ -1,172 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// string_view size, length - -namespace capacity_1 { - -template - struct A { }; - -template - bool - operator==(const A&, const A&) { return true; } - -template - bool - operator<(const A&, const A&) { return true; } - -struct B { }; - -} // namespace capacity_1 -} // namespace string_view -} // namespace selftests - -// char_traits specialization -namespace std -{ - template<> - struct char_traits > - { - typedef selftests::string_view::capacity_1::A< - selftests::string_view::capacity_1::B> char_type; - // Unsigned as wint_t in unsigned. - typedef unsigned long int_type; - typedef streampos pos_type; - typedef streamoff off_type; - typedef mbstate_t state_type; - - static void - assign(char_type& __c1, const char_type& __c2) - { __c1 = __c2; } - - static bool - eq(const char_type& __c1, const char_type& __c2) - { return __c1 == __c2; } - - static bool - lt(const char_type& __c1, const char_type& __c2) - { return __c1 < __c2; } - - static int - compare(const char_type* __s1, const char_type* __s2, size_t __n) - { - for (size_t __i = 0; __i < __n; ++__i) - if (!eq(__s1[__i], __s2[__i])) - return lt(__s1[__i], __s2[__i]) ? -1 : 1; - return 0; - } - - static size_t - length(const char_type* __s) - { - const char_type* __p = __s; - while (__p) - ++__p; - return (__p - __s); - } - - static const char_type* - find(const char_type* __s, size_t __n, const char_type& __a) - { - for (const char_type* __p = __s; size_t(__p - __s) < __n; ++__p) - if (*__p == __a) return __p; - return 0; - } - - static char_type* - move(char_type* __s1, const char_type* __s2, size_t __n) - { return (char_type*) memmove(__s1, __s2, __n * sizeof(char_type)); } - - static char_type* - copy(char_type* __s1, const char_type* __s2, size_t __n) - { return (char_type*) memcpy(__s1, __s2, __n * sizeof(char_type)); } - - static char_type* - assign(char_type* __s, size_t __n, char_type __a) - { - for (char_type* __p = __s; __p < __s + __n; ++__p) - assign(*__p, __a); - return __s; - } - - static char_type - to_char_type(const int_type&) - { return char_type(); } - - static int_type - to_int_type(const char_type&) { return int_type(); } - - static bool - eq_int_type(const int_type& __c1, const int_type& __c2) - { return __c1 == __c2; } - - static int_type - eof() { return static_cast(-1); } - - static int_type - not_eof(const int_type& __c) - { return eq_int_type(__c, eof()) ? int_type(0) : __c; } - }; -} // namespace std - -namespace selftests { -namespace string_view { -namespace capacity_1 { - -static void -test01 () -{ - gdb::basic_string_view> str02; - typedef gdb::basic_string_view< A >::size_type size_type_o; - size_type_o sz03; - size_type_o sz04; - - // non-POD types: size, length, max_size, empty() - bool b01 = str02.empty(); - VERIFY( b01 == true ); - sz03 = str02.size(); - sz04 = str02.length(); - VERIFY( sz03 == sz04 ); - str02.data(); - sz03 = str02.size(); - sz04 = str02.length(); - VERIFY( sz03 == sz04 ); - - sz03 = str02.max_size(); - VERIFY( sz03 >= sz04 ); - - sz03 = str02.size(); - str02 = {}; - b01 = str02.empty(); - VERIFY( b01 == true ); - sz04 = str02.size(); - VERIFY( sz03 >= sz04 ); -} - -static int -main() -{ - test01(); - - return 0; -} - -} // namespace capacity_1 diff --git a/gdb/unittests/basic_string_view/capacity/empty_neg.cc b/gdb/unittests/basic_string_view/capacity/empty_neg.cc deleted file mode 100644 index 4cb1beac5a6..00000000000 --- a/gdb/unittests/basic_string_view/capacity/empty_neg.cc +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2017-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// { dg-options "-std=gnu++17" } -// { dg-do compile { target c++17 } } - -#include - -void -test01() -{ - std::string_view s; - s.empty(); // { dg-warning "ignoring return value" } -} diff --git a/gdb/unittests/basic_string_view/cons/char/1.cc b/gdb/unittests/basic_string_view/cons/char/1.cc deleted file mode 100644 index b27f999e429..00000000000 --- a/gdb/unittests/basic_string_view/cons/char/1.cc +++ /dev/null @@ -1,67 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view constructors. - -namespace cons_1 { - -static void -test01 () -{ - typedef gdb::string_view::size_type csize_type; - - // basic_string_view() - const gdb::string_view str00{}; - VERIFY( str00.length() == 0 ); - VERIFY( str00.data() == nullptr ); - - // basic_string_view(const char*) - const char str_lit01[] = "rodeo beach, marin"; - const gdb::string_view str01{str_lit01}; - VERIFY( str01.length() == 18 ); - VERIFY( str01.data() == str_lit01 ); - const gdb::string_view str02{"baker beach, san francisco"}; - VERIFY( str02.length() == 26 ); - - // basic_string_view(const string_view&) - gdb::string_view str04{str01}; - VERIFY( str04.length() == str01.length() ); - VERIFY( str04.data() == str01.data() ); - - // basic_string_view(const char* s) - csize_type len_lit01 = strlen(str_lit01); - gdb::string_view str05{str_lit01, len_lit01}; - VERIFY( str05.length() == len_lit01 ); - VERIFY( str05.data() == str_lit01 ); - - // basic_string_view(basic_string& s) - std::string istr07(10, 'z'); - gdb::string_view str07{istr07}; - VERIFY( str07.length() == 10 ); -} - -static int -main () -{ - test01(); - - return 0; -} - -} // namespace cons_1 diff --git a/gdb/unittests/basic_string_view/cons/char/2.cc b/gdb/unittests/basic_string_view/cons/char/2.cc deleted file mode 100644 index 22a7916c9e3..00000000000 --- a/gdb/unittests/basic_string_view/cons/char/2.cc +++ /dev/null @@ -1,46 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view constructors. - -namespace cons_2 { - -static void -test03 () -{ - const char* with_nulls = "This contains \0 a zero byte."; - - // These are tests to see how basic_string_view handles data with NUL - // bytes. Obviously basic_string_view(char*) will halt at the first one, but - // nothing else should. - gdb::string_view s1(with_nulls, 28); - VERIFY( s1.size() == 28 ); - gdb::string_view s2(s1); - VERIFY( s2.size() == 28 ); -} - -static int -main () -{ - test03(); - - return 0; -} - -} // namespace cons_2 diff --git a/gdb/unittests/basic_string_view/cons/char/3.cc b/gdb/unittests/basic_string_view/cons/char/3.cc deleted file mode 100644 index ab98b0b70a4..00000000000 --- a/gdb/unittests/basic_string_view/cons/char/3.cc +++ /dev/null @@ -1,39 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view constructors. - -namespace cons_3 { - -static void -test05 () -{ - char const * s = 0; - gdb::string_view zero_length_built_with_NULL(s, 0); -} - -static int -main () -{ - test05(); - - return 0; -} - -} // namespace cons_3 diff --git a/gdb/unittests/basic_string_view/cons/wchar_t/1.cc b/gdb/unittests/basic_string_view/cons/wchar_t/1.cc deleted file mode 100644 index 8a1599c5b81..00000000000 --- a/gdb/unittests/basic_string_view/cons/wchar_t/1.cc +++ /dev/null @@ -1,68 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view constructors. - -#include -#include -#include -#include - -void -test01() -{ - typedef std::wstring_view::size_type csize_type; - - // basic_string_view() - const std::wstring_view str00{}; - VERIFY( str00.length() == 0 ); - VERIFY( str00.data() == nullptr ); - - // basic_string_view(const char*) - const wchar_t str_lit01[] = L"rodeo beach, marin"; - const std::wstring_view str01{str_lit01}; - VERIFY( str01.length() == 18 ); - VERIFY( str01.data() == str_lit01 ); - const std::wstring_view str02{L"baker beach, san francisco"}; - VERIFY( str02.length() == 26 ); - - // basic_string_view(const string_view&) - std::wstring_view str04{str01}; - VERIFY( str04.length() == str01.length() ); - VERIFY( str04.data() == str01.data() ); - - // basic_string_view(const char* s) - csize_type len_lit01 = wcslen(str_lit01); - std::wstring_view str05{str_lit01, len_lit01}; - VERIFY( str05.length() == len_lit01 ); - VERIFY( str05.data() == str_lit01 ); - - // basic_string_view(basic_string& s) - std::wstring istr07(10, L'z'); - std::wstring_view str07{istr07}; - VERIFY( str07.length() == 10 ); -} - -int -main() -{ - test01(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/cons/wchar_t/2.cc b/gdb/unittests/basic_string_view/cons/wchar_t/2.cc deleted file mode 100644 index 54a7fe509bb..00000000000 --- a/gdb/unittests/basic_string_view/cons/wchar_t/2.cc +++ /dev/null @@ -1,45 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view constructors. - -#include -#include - -void -test03() -{ - const wchar_t* with_nulls = L"This contains \0 a zero byte."; - - // These are tests to see how basic_string_view handles data with NUL - // bytes. Obviously basic_string_view(char*) will halt at the first one, but - // nothing else should. - std::wstring_view s1 (with_nulls, 28); - VERIFY( s1.size() == 28 ); - std::wstring_view s2 (s1); - VERIFY( s2.size() == 28 ); -} - -int -main() -{ - test03(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/cons/wchar_t/3.cc b/gdb/unittests/basic_string_view/cons/wchar_t/3.cc deleted file mode 100644 index 540683f5421..00000000000 --- a/gdb/unittests/basic_string_view/cons/wchar_t/3.cc +++ /dev/null @@ -1,38 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view constructors. - -#include -#include - -void -test05() -{ - wchar_t const * s = 0; - std::wstring_view zero_length_built_with_NULL(s, 0); -} - -int -main() -{ - test05(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/element_access/char/1.cc b/gdb/unittests/basic_string_view/element_access/char/1.cc deleted file mode 100644 index 788d174d852..00000000000 --- a/gdb/unittests/basic_string_view/element_access/char/1.cc +++ /dev/null @@ -1,70 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string element access - -namespace element_access_1 { - -static void -test01 () -{ - typedef gdb::string_view::size_type csize_type; - typedef gdb::string_view::const_reference cref; - typedef gdb::string_view::reference ref; - csize_type csz01; - - const gdb::string_view str01("tamarindo, costa rica"); - gdb::string_view str02("41st street beach, capitola, california"); - gdb::string_view str03; - - // const_reference operator[] (size_type pos) const; - csz01 = str01.size(); - cref cref1 = str01[csz01 - 1]; - VERIFY( cref1 == 'a' ); - // Undefined behavior at size(). - //cref cref2 = str01[csz01]; - //VERIFY( cref2 == char() ); - - // const_reference at(size_type pos) const; - csz01 = str01.size(); - cref cref3 = str01.at(csz01 - 1); - VERIFY( cref3 == 'a' ); - try - { - str01.at(csz01); - VERIFY( false ); // Should not get here, as exception thrown. - } - catch (gdb_exception& fail) - { - VERIFY( true ); - } - catch (...) - { - VERIFY( false ); - } -} - -static int -main () -{ - test01(); - return 0; -} - -} // namespace element_access_1 diff --git a/gdb/unittests/basic_string_view/element_access/char/2.cc b/gdb/unittests/basic_string_view/element_access/char/2.cc deleted file mode 100644 index 938916e2924..00000000000 --- a/gdb/unittests/basic_string_view/element_access/char/2.cc +++ /dev/null @@ -1,30 +0,0 @@ -// { dg-do run { xfail *-*-* } } -// { dg-options "-std=gnu++17 -O0" } -// { dg-require-debug-mode "" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -#include - -int -main() -{ - typedef std::string_view string_view_type; - string_view_type s; - s[0]; // abort -} diff --git a/gdb/unittests/basic_string_view/element_access/char/empty.cc b/gdb/unittests/basic_string_view/element_access/char/empty.cc deleted file mode 100644 index 030c96aa073..00000000000 --- a/gdb/unittests/basic_string_view/element_access/char/empty.cc +++ /dev/null @@ -1,39 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . -// - -namespace element_access_empty { - -static int -main () -{ - { - gdb::string_view empty; - VERIFY( empty.empty() ); - } - - { - const gdb::string_view empty; - VERIFY( empty.empty() ); - } - - return 0; -} - -} // namespace element_access_empty diff --git a/gdb/unittests/basic_string_view/element_access/char/front_back.cc b/gdb/unittests/basic_string_view/element_access/char/front_back.cc deleted file mode 100644 index 7e767fc7910..00000000000 --- a/gdb/unittests/basic_string_view/element_access/char/front_back.cc +++ /dev/null @@ -1,43 +0,0 @@ -// { dg-options "-std=gnu++17" } -// { dg-require-string-conversions "" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -namespace element_access_front_back { - -static void -test01 () -{ - gdb::string_view str("ramifications"); - const gdb::string_view cstr("melodien"); - - VERIFY( str.front() == 'r' ); - VERIFY( str.back() == 's' ); - VERIFY( cstr.front() == 'm' ); - VERIFY( cstr.back() == 'n' ); -} - -static int -main () -{ - test01(); - - return 0; -} - -} // namespace element_access_front_back diff --git a/gdb/unittests/basic_string_view/element_access/wchar_t/1.cc b/gdb/unittests/basic_string_view/element_access/wchar_t/1.cc deleted file mode 100644 index 679772b4c57..00000000000 --- a/gdb/unittests/basic_string_view/element_access/wchar_t/1.cc +++ /dev/null @@ -1,71 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view element access - -#include -#include -#include - -void -test01() -{ - typedef std::wstring_view::size_type csize_type; - typedef std::wstring_view::const_reference cref; - typedef std::wstring_view::reference ref; - csize_type csz01, csz02; - - const std::wstring_view str01(L"tamarindo, costa rica"); - std::wstring_view str02(L"41st street beach, capitola, california"); - std::wstring_view str03; - - // const_reference operator[] (size_type pos) const; - csz01 = str01.size(); - cref cref1 = str01[csz01 - 1]; - VERIFY( cref1 == L'a' ); - // Undefined behavior at size(). - //cref cref2 = str01[csz01]; - //VERIFY( cref2 == wchar_t() ); - - // const_reference at(size_type pos) const; - csz01 = str01.size(); - cref cref3 = str01.at(csz01 - 1); - VERIFY( cref3 == L'a' ); - try - { - str01.at(csz01); - VERIFY( false ); // Should not get here, as exception thrown. - } - catch (std::out_of_range& fail) - { - VERIFY( true ); - } - catch (...) - { - VERIFY( false ); - } -} - -int -main() -{ - test01(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/element_access/wchar_t/2.cc b/gdb/unittests/basic_string_view/element_access/wchar_t/2.cc deleted file mode 100644 index cdbc6a5e5a8..00000000000 --- a/gdb/unittests/basic_string_view/element_access/wchar_t/2.cc +++ /dev/null @@ -1,32 +0,0 @@ -// { dg-do run { xfail *-*-* } } -// { dg-options "-std=gnu++17 -O0" } -// { dg-require-debug-mode "" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -#include - -// libstdc++/21674 -// NB: Should work without any inlining or optimizations (ie. -O0). -int -main() -{ - typedef std::wstring_view string_view_type; - string_view_type s; - s[0]; // abort -} diff --git a/gdb/unittests/basic_string_view/element_access/wchar_t/empty.cc b/gdb/unittests/basic_string_view/element_access/wchar_t/empty.cc deleted file mode 100644 index f31d34aa42b..00000000000 --- a/gdb/unittests/basic_string_view/element_access/wchar_t/empty.cc +++ /dev/null @@ -1,38 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . -// - -#include -#include - -int -main() -{ - { - std::wstring_view empty; - VERIFY( empty.empty() ); - } - - { - const std::wstring_view empty; - VERIFY( empty.empty() ); - } - - return 0; -} diff --git a/gdb/unittests/basic_string_view/element_access/wchar_t/front_back.cc b/gdb/unittests/basic_string_view/element_access/wchar_t/front_back.cc deleted file mode 100644 index c17a08a45c7..00000000000 --- a/gdb/unittests/basic_string_view/element_access/wchar_t/front_back.cc +++ /dev/null @@ -1,42 +0,0 @@ -// { dg-options "-std=gnu++17" } -// { dg-require-string-conversions "" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -#include -#include - -void -test01() -{ - std::wstring_view str(L"ramifications"); - const std::wstring_view cstr(L"melodien"); - - VERIFY( str.front() == L'r' ); - VERIFY( str.back() == L's' ); - VERIFY( cstr.front() == L'm' ); - VERIFY( cstr.back() == L'n' ); -} - -int -main() -{ - test01(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/include.cc b/gdb/unittests/basic_string_view/include.cc deleted file mode 100644 index ef01b7c478c..00000000000 --- a/gdb/unittests/basic_string_view/include.cc +++ /dev/null @@ -1,25 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// NB: This issue affected only debug-mode. - -// { dg-options "-std=gnu++17 -fno-rtti" } -// { dg-do compile } - -#include diff --git a/gdb/unittests/basic_string_view/inserters/char/1.cc b/gdb/unittests/basic_string_view/inserters/char/1.cc deleted file mode 100644 index e0a33bf13bd..00000000000 --- a/gdb/unittests/basic_string_view/inserters/char/1.cc +++ /dev/null @@ -1,65 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// inserters - -// NB: This file is predicated on sstreams, istreams, and ostreams -// working, not to mention other major details like char_traits, and -// all of the string_view class. - -#include -#include -#include -#include -#include -#include - -void -test01() -{ - typedef std::string_view::size_type csize_type; - typedef std::string_view::const_reference cref; - typedef std::string_view::reference ref; - - const std::string_view str01("sailing grand traverse bay\n" - "\t\t\t from Elk Rapids to the point reminds me of miles"); - - // ostream& operator<<(ostream&, const basic_string_view&) - std::ostringstream ostrs01; - try - { - ostrs01 << str01; - VERIFY( ostrs01.str() == str01 ); - } - catch(std::exception& fail) - { - VERIFY( false ); - } - - std::string_view hello_world; - std::cout << hello_world; -} - -int -main() -{ - test01(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/inserters/char/2.cc b/gdb/unittests/basic_string_view/inserters/char/2.cc deleted file mode 100644 index 840f52185df..00000000000 --- a/gdb/unittests/basic_string_view/inserters/char/2.cc +++ /dev/null @@ -1,91 +0,0 @@ - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// inserters - -// NB: This file is predicated on sstreams, ostreams -// working, not to mention other major details like char_traits, and -// all of the string_view class. - -// { dg-options "-std=gnu++17" } -// { dg-require-fileio "" } - -namespace inserters_2 { - -// testing basic_filebuf::xsputn via stress testing with large string_views -// based on a bug report libstdc++ 9 -// mode == out -static void -test05 (std::size_t size) -{ - bool test ATTRIBUTE_UNUSED = true; - - const char filename[] = "inserters_extractors-2.txt"; - const char fillc = 'f'; - std::ofstream ofs(filename); - std::string str(size, fillc); - gdb::string_view strv{str}; - - // sanity checks - VERIFY( str.size() == size ); - VERIFY( ofs.good() ); - - // stress test - ofs << str << std::endl; - if (!ofs.good()) - test = false; - - ofs << str << std::endl; - if (!ofs.good()) - test = false; - - VERIFY( str.size() == size ); - VERIFY( ofs.good() ); - - ofs.close(); - - // sanity check on the written file - std::ifstream ifs(filename); - std::size_t count = 0; - char c; - while (count <= (2 * size) + 4) - { - ifs >> c; - if (ifs.good() && c == fillc) - { - ++count; - c = '0'; - } - else - break; - } - - VERIFY( count == 2 * size ); -} - -static int -main () -{ - test05(1); - test05(1000); - test05(10000); - - return 0; -} - -} // namespace inserters_2 diff --git a/gdb/unittests/basic_string_view/inserters/char/3.cc b/gdb/unittests/basic_string_view/inserters/char/3.cc deleted file mode 100644 index 43e3ae05ba7..00000000000 --- a/gdb/unittests/basic_string_view/inserters/char/3.cc +++ /dev/null @@ -1,54 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// inserters - -// NB: This file is predicated on sstreams, and ostreams -// working, not to mention other major details like char_traits, and -// all of the string_view class. - -#include -#include -#include -#include - -// libstdc++/2830 -void -test09() -{ - std::string_view foo{"peace\0\0\0& love"}; - - std::ostringstream oss1; - oss1 << foo; - VERIFY( oss1.str() == foo ); - - std::ostringstream oss2; - oss2.width(20); - oss2 << foo; - VERIFY( oss2.str() != foo ); - VERIFY( oss2.str().size() == 20 ); -} - -int -main() -{ - test09(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/inserters/pod/10081-out.cc b/gdb/unittests/basic_string_view/inserters/pod/10081-out.cc deleted file mode 100644 index 4b5d81d33cf..00000000000 --- a/gdb/unittests/basic_string_view/inserters/pod/10081-out.cc +++ /dev/null @@ -1,75 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// class basic_istream::sentry - -#include -#include -#include -#include -#include -#include -#include - -void -test01() -{ - using namespace std; - - using __gnu_test::pod_ushort; - typedef basic_string_view string_type; - typedef basic_stringbuf stringbuf_type; - typedef basic_ostream ostream_type; - - string_type str; - stringbuf_type strbuf01; - ostream_type stream(&strbuf01); - - try - { - stream << str; - } - catch (std::bad_cast& obj) - { - // Ok, throws bad_cast because locale has no ctype facet. - } - catch (...) - { - VERIFY( false ); - } - - const std::locale loc(std::locale::classic(), new std::ctype); - stream.imbue(loc); - try - { - stream << str; - } - catch (...) - { - VERIFY( false ); - } -} - -int -main() -{ - test01(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/inserters/wchar_t/1.cc b/gdb/unittests/basic_string_view/inserters/wchar_t/1.cc deleted file mode 100644 index 69754254e4f..00000000000 --- a/gdb/unittests/basic_string_view/inserters/wchar_t/1.cc +++ /dev/null @@ -1,70 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// inserters - -// NB: This file is predicated on sstreams, and ostreams -// working, not to mention other major details like char_traits, and -// all of the string_view class. - -#include -#include -#include -#include -#include -#include - -void -test01() -{ - typedef std::wstring_view::size_type csize_type; - typedef std::wstring_view::const_reference cref; - typedef std::wstring_view::reference ref; - - const std::wstring_view str01(L"sailing grand traverse bay\n" - L"\t\t\t from Elk Rapids to the point reminds me of miles"); - const std::wstring_view str02(L"sailing"); - const std::wstring_view str03(L"grand"); - const std::wstring_view str04(L"traverse"); - const std::wstring_view str05; - std::wstring_view str10; - - // ostream& operator<<(ostream&, const basic_string_view&) - std::wostringstream ostrs01; - try - { - ostrs01 << str01; - VERIFY( ostrs01.str() == str01 ); - } - catch(std::exception& fail) - { - VERIFY( false ); - } - - std::wstring_view hello_world; - std::wcout << hello_world; -} - -int -main() -{ - test01(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/inserters/wchar_t/2.cc b/gdb/unittests/basic_string_view/inserters/wchar_t/2.cc deleted file mode 100644 index 5cc3e93e5b7..00000000000 --- a/gdb/unittests/basic_string_view/inserters/wchar_t/2.cc +++ /dev/null @@ -1,91 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// inserters - -// NB: This file is predicated on sstreams, istreams, and ostreams -// working, not to mention other major details like char_traits, and -// all of the string_view class. - -#include -#include -#include -#include -#include - -// testing basic_filebuf::xsputn via stress testing with large string_views -// based on a bug report libstdc++ 9 -// mode == out -void -test05(std::size_t size) -{ - bool test = true; - - const char filename[] = "inserters_extractors-2.txt"; - const wchar_t fillc = L'f'; - std::wofstream ofs(filename); - std::wstring str(size, fillc); - std::wstring_view strv(str); - - // sanity checks - VERIFY( str.size() == size ); - VERIFY( ofs.good() ); - - // stress test - ofs << str << std::endl; - if (!ofs.good()) - test = false; - - ofs << str << std::endl; - if (!ofs.good()) - test = false; - - VERIFY( str.size() == size ); - VERIFY( ofs.good() ); - - ofs.close(); - - // sanity check on the written file - std::wifstream ifs(filename); - std::size_t count = 0; - wchar_t c; - while (count <= (2 * size) + 4) - { - ifs >> c; - if (ifs.good() && c == fillc) - { - ++count; - c = '0'; - } - else - break; - } - - VERIFY( count == 2 * size ); -} - -int -main() -{ - test05(1); - test05(1000); - test05(10000); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/inserters/wchar_t/3.cc b/gdb/unittests/basic_string_view/inserters/wchar_t/3.cc deleted file mode 100644 index 5eabf46dd44..00000000000 --- a/gdb/unittests/basic_string_view/inserters/wchar_t/3.cc +++ /dev/null @@ -1,53 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// inserters - -// NB: This file is predicated on sstreams, istreams, and ostreams -// working, not to mention other major details like char_traits, and -// all of the string_view class. - -#include -#include -#include -#include - -void -test09() -{ - std::wstring_view foo{L"peace\0\0\0& love"}; - - std::wostringstream oss1; - oss1 << foo; - VERIFY( oss1.str() == foo ); - - std::wostringstream oss2; - oss2.width(20); - oss2 << foo; - VERIFY( oss2.str() != foo ); - VERIFY( oss2.str().size() == 20 ); -} - -int -main() -{ - test09(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/literals/types.cc b/gdb/unittests/basic_string_view/literals/types.cc deleted file mode 100644 index de0aa1e7569..00000000000 --- a/gdb/unittests/basic_string_view/literals/types.cc +++ /dev/null @@ -1,45 +0,0 @@ -// { dg-options "-std=gnu++17" } -// { dg-do compile } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -#include -#include - -void -test01() -{ - using namespace std::literals::string_view_literals; - - static_assert(std::is_same::value, - "\"Hello\"s is std::string_view"); - - static_assert(std::is_same::value, - "u8\"Hello\"s is std::string_view"); - -#ifdef _GLIBCXX_USE_WCHAR_T - static_assert(std::is_same::value, - "L\"Hello\"s is std::wstring_view"); -#endif - - static_assert(std::is_same::value, - "u\"Hello\"s is std::u16string_view"); - - static_assert(std::is_same::value, - "U\"Hello\"s is std::u32string_view"); -} diff --git a/gdb/unittests/basic_string_view/literals/values.cc b/gdb/unittests/basic_string_view/literals/values.cc deleted file mode 100644 index ebd69b84455..00000000000 --- a/gdb/unittests/basic_string_view/literals/values.cc +++ /dev/null @@ -1,72 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -#include -#include - -void -test01() -{ - using namespace std::literals::string_view_literals; - - std::string_view planet = "Mercury"sv; -#ifdef _GLIBCXX_USE_WCHAR_T - std::wstring_view wplanet = L"Venus"sv; -#endif - std::string_view u8planet = u8"Mars"sv; - std::u16string_view u16planet = u"Jupiter"sv; - std::u32string_view u32planet = U"Saturn"sv; - - VERIFY( planet == std::string_view("Mercury") ); -#ifdef _GLIBCXX_USE_WCHAR_T - VERIFY( wplanet == std::wstring_view(L"Venus") ); -#endif - VERIFY( u8planet == std::string_view(u8"Mars") ); - VERIFY( u16planet == std::u16string_view(u"Jupiter") ); - VERIFY( u32planet == std::u32string_view(U"Saturn") ); -} - -void -test02() -{ - using namespace std::literals::string_view_literals; - - std::string_view planet_cratered = "Mercury\0cratered"sv; -#ifdef _GLIBCXX_USE_WCHAR_T - std::wstring_view wplanet_cratered = L"Venus\0cratered"sv; -#endif - std::string_view u8planet_cratered = u8"Mars\0cratered"sv; - std::u16string_view u16planet_cratered = u"Jupiter\0cratered"sv; - std::u32string_view u32planet_cratered = U"Saturn\0cratered"sv; - - VERIFY( planet_cratered == std::string_view("Mercury\0cratered", 16) ); -#ifdef _GLIBCXX_USE_WCHAR_T - VERIFY( wplanet_cratered == std::wstring_view(L"Venus\0cratered", 14) ); -#endif - VERIFY( u8planet_cratered == std::string_view(u8"Mars\0cratered", 13) ); - VERIFY( u16planet_cratered == std::u16string_view(u"Jupiter\0cratered", 16) ); - VERIFY( u32planet_cratered == std::u32string_view(U"Saturn\0cratered", 15) ); -} - -int -main() -{ - test01(); - test02(); -} diff --git a/gdb/unittests/basic_string_view/modifiers/remove_prefix/char/1.cc b/gdb/unittests/basic_string_view/modifiers/remove_prefix/char/1.cc deleted file mode 100644 index 4ebf4c04ad2..00000000000 --- a/gdb/unittests/basic_string_view/modifiers/remove_prefix/char/1.cc +++ /dev/null @@ -1,66 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -namespace modifiers_remove_prefix { - -static void -test01 () -{ - using gdb::string_view; - - string_view str0{"olympus mons"}; - string_view::pointer p = str0.data(); - str0.remove_prefix(4); - VERIFY( str0.data() == p + 4); - VERIFY( str0.length() == 8 ); - VERIFY( str0 == string_view{"pus mons"} ); -} - -#ifndef GDB_STRING_VIEW -constexpr bool -test02() -{ - using std::string_view; - - string_view str0{"olympus mons"}; - string_view::pointer p = str0.data(); - str0.remove_prefix(4); - if ( str0.data() != p + 4) - return false; - if ( str0.length() != 8 ) - return false; - if ( str0 != string_view{"pus mons"} ) - return false; - - return true; -} -#endif - -static int -main () -{ - test01(); -#ifndef GDB_STRING_VIEW - static_assert( test02() ); -#endif - - return 0; -} - -} // namespace modifiers_remove_prefix diff --git a/gdb/unittests/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc b/gdb/unittests/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc deleted file mode 100644 index 3503dcbab53..00000000000 --- a/gdb/unittests/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc +++ /dev/null @@ -1,61 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -#include -#include - -void -test01() -{ - using std::wstring_view; - - wstring_view str0{L"olympus mons"}; - wstring_view::pointer p = str0.data(); - str0.remove_prefix(4); - VERIFY( str0.data() == p + 4); - VERIFY( str0.length() == 8 ); - VERIFY( str0 == wstring_view{L"pus mons"} ); -} - -constexpr bool -test02() -{ - using std::wstring_view; - - wstring_view str0{L"olympus mons"}; - wstring_view::pointer p = str0.data(); - str0.remove_prefix(4); - if ( str0.data() != p + 4) - return false; - if ( str0.length() != 8 ) - return false; - if ( str0 != wstring_view{L"pus mons"} ) - return false; - - return true; -} - -int -main() -{ - test01(); - static_assert( test02() ); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/modifiers/remove_suffix/char/1.cc b/gdb/unittests/basic_string_view/modifiers/remove_suffix/char/1.cc deleted file mode 100644 index 5e9259eecad..00000000000 --- a/gdb/unittests/basic_string_view/modifiers/remove_suffix/char/1.cc +++ /dev/null @@ -1,66 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -namespace modifiers_remove_suffix { - -static void -test01 () -{ - using gdb::string_view; - - string_view str0{"olympus mons"}; - string_view::pointer p = str0.data(); - str0.remove_suffix(2); - VERIFY( str0.data() == p); - VERIFY( str0.length() == 10 ); - VERIFY( str0 == string_view{"olympus mo"} ); -} - -#ifndef GDB_STRING_VIEW -constexpr bool -test02() -{ - using std::string_view; - - string_view str0{"olympus mons"}; - string_view::pointer p = str0.data(); - str0.remove_suffix(2); - if ( str0.data() != p) - return false; - if ( str0.length() != 10 ) - return false; - if ( str0 != string_view{"olympus mo"} ) - return false; - - return true; -} -#endif - -static int -main () -{ - test01(); -#ifndef GDB_STRING_VIEW - static_assert( test02() ); -#endif - - return 0; -} - -} // namespace modifiers_remove_suffix diff --git a/gdb/unittests/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc b/gdb/unittests/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc deleted file mode 100644 index 7f9e051d986..00000000000 --- a/gdb/unittests/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc +++ /dev/null @@ -1,61 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -#include -#include - -void -test01() -{ - using std::wstring_view; - - wstring_view str0{L"olympus mons"}; - wstring_view::pointer p = str0.data(); - str0.remove_suffix(2); - VERIFY( str0.data() == p); - VERIFY( str0.length() == 10 ); - VERIFY( str0 == wstring_view{L"olympus mo"} ); -} - -constexpr bool -test02() -{ - using std::wstring_view; - - wstring_view str0{L"olympus mons"}; - wstring_view::pointer p = str0.data(); - str0.remove_suffix(2); - if ( str0.data() != p) - return false; - if ( str0.length() != 10 ) - return false; - if ( str0 != wstring_view{L"olympus mo"} ) - return false; - - return true; -} - -int -main() -{ - test01(); - static_assert( test02() ); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/modifiers/swap/char/1.cc b/gdb/unittests/basic_string_view/modifiers/swap/char/1.cc deleted file mode 100644 index d583566c4bd..00000000000 --- a/gdb/unittests/basic_string_view/modifiers/swap/char/1.cc +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2017-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// { dg-options "-std=gnu++17" } -// { dg-do compile { target c++17 } } - -namespace modifiers_swap { - -static void -test01 () -{ - using gdb::string_view; - - string_view s1{"last"}; - string_view s2{"first"}; - - s1.swap(s2); - VERIFY( s1 == "first" ); - VERIFY( s2 == "last" ); -} - -} // namespace modifiers_swap diff --git a/gdb/unittests/basic_string_view/modifiers/swap/wchar_t/1.cc b/gdb/unittests/basic_string_view/modifiers/swap/wchar_t/1.cc deleted file mode 100644 index b986088f1e2..00000000000 --- a/gdb/unittests/basic_string_view/modifiers/swap/wchar_t/1.cc +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2017-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// { dg-options "-std=gnu++17" } -// { dg-do compile { target c++17 } } - -#include - -constexpr bool -test01() -{ - using std::wstring_view; - - wstring_view s1{L"last"}; - wstring_view s2{L"first"}; - - s1.swap(s2); - return s1 == L"first" && s2 == L"last"; -} - -static_assert( test01() ); diff --git a/gdb/unittests/basic_string_view/operations/compare/char/1.cc b/gdb/unittests/basic_string_view/operations/compare/char/1.cc deleted file mode 100644 index d824c8e2277..00000000000 --- a/gdb/unittests/basic_string_view/operations/compare/char/1.cc +++ /dev/null @@ -1,132 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view::compare -// int compare(const basic_string_view& str) const; -// int compare(size_type pos1, size_type n1, const basic_string_view& str) const; -// int compare(size_type pos1, size_type n1, const basic_string_view& str, -// size_type pos2, size_type n2) const; -// int compare(const charT* s) const; -// int compare(size_type pos1, size_type n1, -// const charT* s, size_type n2 = npos) const; - -// NB compare should be thought of as a lexographical compare, ie how -// things would be sorted in a dictionary. - -namespace operations_compare_1 { - -enum want_value {lt=0, z=1, gt=2}; - -int -test_value(int result, want_value expected); - -int -test_value(int result, want_value expected) -{ - bool pass = false; - - switch (expected) { - case lt: - if (result < 0) - pass = true; - break; - case z: - if (!result) - pass = true; - break; - case gt: - if (result > 0) - pass = true; - break; - default: - pass = false; //should not get here - } - VERIFY(pass); - return 0; -} - -static int -test01 () -{ - using gdb::string_view; - - string_view str_0("costa rica"); - string_view str_1("costa marbella"); - string_view str_2; - - //sanity check - test_value(strcmp("costa marbella", "costa rica"), lt); - test_value(strcmp("costa rica", "costa rica"), z); - test_value(strcmp(str_1.data(), str_0.data()), lt); - test_value(strcmp(str_0.data(), str_1.data()), gt); - test_value(strncmp(str_1.data(), str_0.data(), 6), z); - test_value(strncmp(str_1.data(), str_0.data(), 14), lt); - test_value(memcmp(str_1.data(), str_0.data(), 6), z); - test_value(memcmp(str_1.data(), str_0.data(), 10), lt); - test_value(memcmp("costa marbella", "costa rica", 10), lt); - - // int compare(const basic_string_view& str) const; - test_value(str_0.compare(str_1), gt); //because r>m - test_value(str_1.compare(str_0), lt); //because m. - -// basic_string_view::compare [lib.string_view::compare] - -namespace operations_compare_13650 { - -// libstdc++/13650 -static void -test01 () -{ - using gdb::string_view; - - const char lit_01[]{ 'w', 'e', '\0', 'r', 'd' }; - const char lit_02[]{ 'w', 'e', 'i', '\0', 'd' }; - - const char lit_ref_a[]{ 'w', 'e', '\0', 'q', 'd' }; - const string_view str_a(lit_ref_a, 5); - VERIFY( str_a.compare(0, 5, lit_01, 5) < 0 ); - - const char lit_ref_b[]{ 'w', 'e', 'i' }; - const string_view str_b(lit_ref_b, 3); - VERIFY( str_b.compare(0, 3, lit_02, 5) < 0 ); -} - -static int -main() -{ - test01(); - - return 0; -} - -} // namespace operations_compare_13650 diff --git a/gdb/unittests/basic_string_view/operations/compare/char/2.cc b/gdb/unittests/basic_string_view/operations/compare/char/2.cc deleted file mode 100644 index f0b76afb427..00000000000 --- a/gdb/unittests/basic_string_view/operations/compare/char/2.cc +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2017-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// { dg-options "-std=gnu++17" } -// { dg-do compile { target c++17 } } - -#include - -constexpr char c1[] = "one"; -constexpr char c2[] = "two"; - -constexpr std::string_view s1{c1}; -constexpr std::string_view s2{c2}; - -constexpr int n1 = s1.compare(s1); -constexpr int n2 = s1.compare(s2); diff --git a/gdb/unittests/basic_string_view/operations/compare/char/70483.cc b/gdb/unittests/basic_string_view/operations/compare/char/70483.cc deleted file mode 100644 index 259f95f5180..00000000000 --- a/gdb/unittests/basic_string_view/operations/compare/char/70483.cc +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (C) 2017-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// { dg-options "-std=gnu++17" } -// { dg-do compile { target c++17 } } - -#include - -struct constexpr_char_traits : std::char_traits -{ - static constexpr size_t - length(const char* val) - { - size_t res = 0; - for (; val[res] != '\0'; ++res) - ; - return res; - } - - static constexpr int - compare(const char* lhs, const char* rhs, std::size_t count) - { - for (size_t pos = 0; pos < count; ++pos) - { - if (lhs[pos] != rhs[pos]) - return lhs[pos] - rhs[pos]; - } - return 0; - } -}; - -using string_view = std::basic_string_view; - -constexpr -string_view get() -{ - string_view res = "x::"; - string_view start_pattern = "x"; - res = res.substr(res.find(start_pattern) + start_pattern.size()); - res = res.substr(0, res.find_first_of(";]")); - res = res.substr(res.rfind("::")); - return res; -} - -static_assert( get() == get() ); - -using std::u16string_view; - -constexpr -u16string_view get16() -{ - u16string_view res = u"x::"; - u16string_view start_pattern = u"x"; - res = res.substr(res.find(start_pattern) + start_pattern.size()); - res = res.substr(0, res.find_first_of(u";]")); - res = res.substr(res.rfind(u"::")); - return res; -} - -static_assert( get16() == get16() ); - -using std::u32string_view; - -constexpr -u32string_view get32() -{ - u32string_view res = U"x::"; - u32string_view start_pattern = U"x"; - res = res.substr(res.find(start_pattern) + start_pattern.size()); - res = res.substr(0, res.find_first_of(U";]")); - res = res.substr(res.rfind(U"::")); - return res; -} - -static_assert( get32() == get32() ); diff --git a/gdb/unittests/basic_string_view/operations/compare/wchar_t/1.cc b/gdb/unittests/basic_string_view/operations/compare/wchar_t/1.cc deleted file mode 100644 index 8a05a4053a1..00000000000 --- a/gdb/unittests/basic_string_view/operations/compare/wchar_t/1.cc +++ /dev/null @@ -1,133 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view::compare -// int compare(const basic_string_view& str) const; -// int compare(size_type pos1, size_type n1, const basic_string_view& str) const; -// int compare(size_type pos1, size_type n1, const basic_string_view& str, -// size_type pos2, size_type n2) const; -// int compare(const charT* s) const; -// int compare(size_type pos1, size_type n1, -// const charT* s, size_type n2 = npos) const; - -// NB compare should be thought of as a lexographical compare, ie how -// things would be sorted in a dictionary. - -#include -#include - -enum want_value {lt=0, z=1, gt=2}; - -int -test_value(int result, want_value expected); - -int -test_value(int result, want_value expected) -{ - bool pass = false; - - switch (expected) { - case lt: - if (result < 0) - pass = true; - break; - case z: - if (!result) - pass = true; - break; - case gt: - if (result > 0) - pass = true; - break; - default: - pass = false; //should not get here - } - - VERIFY(pass); - return 0; -} - - -int -test01() -{ - using std::wstring_view; - - wstring_view str_0(L"costa rica"); - wstring_view str_1(L"costa marbella"); - wstring_view str_2; - - //sanity check - test_value(wcscmp(L"costa marbella", L"costa rica"), lt); - test_value(wcscmp(L"costa rica", L"costa rica"), z); - test_value(wcscmp(str_1.data(), str_0.data()), lt); - test_value(wcscmp(str_0.data(), str_1.data()), gt); - test_value(wcsncmp(str_1.data(), str_0.data(), 6), z); - test_value(wcsncmp(str_1.data(), str_0.data(), 14), lt); - test_value(wmemcmp(str_1.data(), str_0.data(), 6), z); - test_value(wmemcmp(str_1.data(), str_0.data(), 14), lt); - test_value(wmemcmp(L"costa marbella", L"costa rica", 14), lt); - - // int compare(const basic_string_view& str) const; - test_value(str_0.compare(str_1), gt); //because r>m - test_value(str_1.compare(str_0), lt); //because m. - -// basic_string_view::compare [lib.string_view::compare] - -#include -#include - -// libstdc++/13650 -void -test01() -{ - using std::wstring_view; - - const wchar_t lit_01[] = { L'w', L'e', L'\0', L'r', L'd' }; - const wchar_t lit_02[] = { L'w', L'e', L'i', L'\0', L'd' }; - - const wchar_t lit_ref_a[] = { L'w', L'e', L'\0', L'q', L'd' }; - const wstring_view str_a(lit_ref_a, 5); - VERIFY( str_a.compare(0, 5, lit_01, 5) < 0 ); - - const wchar_t lit_ref_b[] = { L'w', L'e', L'i' }; - const wstring_view str_b(lit_ref_b, 3); - VERIFY( str_b.compare(0, 3, lit_02, 5) < 0 ); -} - -int -main() -{ - test01(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/operations/compare/wchar_t/2.cc b/gdb/unittests/basic_string_view/operations/compare/wchar_t/2.cc deleted file mode 100644 index c6b6eb91d42..00000000000 --- a/gdb/unittests/basic_string_view/operations/compare/wchar_t/2.cc +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2017-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// { dg-options "-std=gnu++17" } -// { dg-do compile { target c++17 } } - -#include - -constexpr wchar_t c1[] = L"one"; -constexpr wchar_t c2[] = L"two"; - -constexpr std::wstring_view s1{c1}; -constexpr std::wstring_view s2{c2}; - -constexpr int n1 = s1.compare(s1); -constexpr int n2 = s1.compare(s2); diff --git a/gdb/unittests/basic_string_view/operations/copy/char/1.cc b/gdb/unittests/basic_string_view/operations/copy/char/1.cc deleted file mode 100644 index f124f3aab46..00000000000 --- a/gdb/unittests/basic_string_view/operations/copy/char/1.cc +++ /dev/null @@ -1,46 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view::copy - -namespace operations_copy_1 { - -static void -test01 () -{ - typedef gdb::string_view::size_type csize_type; - - const char str_lit01[] = "123456789A"; - const gdb::string_view str01(str_lit01); - char buffer[4] = { 0 }; - - csize_type len = str01.copy(buffer, sizeof(buffer), 8); - VERIFY( 2 == len ); - VERIFY( '9' == buffer[0] ); -} - -static int -main () -{ - test01(); - - return 0; -} - -} // namespace operations_copy_1 diff --git a/gdb/unittests/basic_string_view/operations/copy/wchar_t/1.cc b/gdb/unittests/basic_string_view/operations/copy/wchar_t/1.cc deleted file mode 100644 index 56a48841ca7..00000000000 --- a/gdb/unittests/basic_string_view/operations/copy/wchar_t/1.cc +++ /dev/null @@ -1,46 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view::copy - -#include -#include - -void -test01() -{ - typedef std::wstring_view::size_type csize_type; - csize_type csz01; - - const wchar_t str_lit01[] = L"123456789A"; - const std::wstring_view str01(str_lit01); - wchar_t buffer[4] = { 0 }; - - csize_type len = str01.copy(buffer, sizeof(buffer), 8); - VERIFY( 2 == len ); - VERIFY( L'9' == buffer[0] ); -} - -int -main() -{ - test01(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/operations/data/char/1.cc b/gdb/unittests/basic_string_view/operations/data/char/1.cc deleted file mode 100644 index 0309f5f555d..00000000000 --- a/gdb/unittests/basic_string_view/operations/data/char/1.cc +++ /dev/null @@ -1,44 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// string_view operations - -namespace operations_data_1 { - -static int -test01 () -{ - gdb::string_view empty; - - VERIFY( empty.size() == 0 ); - const gdb::string_view::value_type* p = empty.data(); - VERIFY( p == nullptr ); - - return 0; -} - -static int -main () -{ - test01(); - - return 0; -} - -} // namespace operations_data_1 diff --git a/gdb/unittests/basic_string_view/operations/data/wchar_t/1.cc b/gdb/unittests/basic_string_view/operations/data/wchar_t/1.cc deleted file mode 100644 index 31c58b6a3c2..00000000000 --- a/gdb/unittests/basic_string_view/operations/data/wchar_t/1.cc +++ /dev/null @@ -1,43 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// string_view operations - -#include -#include - -int -test01() -{ - std::wstring_view empty; - - VERIFY( empty.size() == 0 ); - const std::wstring_view::value_type* p = empty.data(); - VERIFY( p == nullptr ); - - return 0; -} - -int -main() -{ - test01(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/operations/find/char/1.cc b/gdb/unittests/basic_string_view/operations/find/char/1.cc deleted file mode 100644 index 79706e05aca..00000000000 --- a/gdb/unittests/basic_string_view/operations/find/char/1.cc +++ /dev/null @@ -1,168 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view find - -namespace operations_find_1 { - -static void -test01 () -{ - typedef gdb::string_view::size_type csize_type; - typedef gdb::string_view::const_reference cref; - typedef gdb::string_view::reference ref; - csize_type npos = gdb::string_view::npos; - csize_type csz01, csz02; - - const char str_lit01[] = "mave"; - const gdb::string_view str01("mavericks, santa cruz"); - gdb::string_view str02(str_lit01); - gdb::string_view str03("s, s"); - gdb::string_view str04; - - // size_type find(const string_view&, size_type pos = 0) const; - csz01 = str01.find(str01); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str01, 4); - VERIFY( csz01 == npos ); - csz01 = str01.find(str02, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str02, 3); - VERIFY( csz01 == npos ); - csz01 = str01.find(str03, 0); - VERIFY( csz01 == 8 ); - csz01 = str01.find(str03, 3); - VERIFY( csz01 == 8 ); - csz01 = str01.find(str03, 12); - VERIFY( csz01 == npos ); - - // An empty string_view consists of no characters - // therefore it should be found at every point in a string_view, - // except beyond the end - csz01 = str01.find(str04, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str04, 5); - VERIFY( csz01 == 5 ); - csz01 = str01.find(str04, str01.size()); - VERIFY( csz01 == str01.size() ); - csz01 = str01.find(str04, str01.size()+1); - VERIFY( csz01 == npos ); - - // size_type find(const char* s, size_type pos, size_type n) const; - csz01 = str01.find(str_lit01, 0, 3); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str_lit01, 3, 0); - VERIFY( csz01 == 3 ); - - // size_type find(const char* s, size_type pos = 0) const; - csz01 = str01.find(str_lit01); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str_lit01, 3); - VERIFY( csz01 == npos ); - - // size_type find(char c, size_type pos = 0) const; - csz01 = str01.find('z'); - csz02 = str01.size() - 1; - VERIFY( csz01 == csz02 ); - csz01 = str01.find('/'); - VERIFY( csz01 == npos ); -} - -#ifndef GDB_STRING_VIEW -constexpr bool -test02() -{ - typedef std::string_view::size_type csize_type; - typedef std::string_view::const_reference cref; - typedef std::string_view::reference ref; - csize_type npos = std::string_view::npos; - csize_type csz01 = 0, csz02 = 0; - - const char str_lit01[] = "mave"; - const std::string_view str01("mavericks, santa cruz"); - std::string_view str02(str_lit01); - std::string_view str03("s, s"); - std::string_view str04; - -#undef VERIFY -#define VERIFY(x) if(!(x)) return false - - // size_type find(const string_view&, size_type pos = 0) const; - csz01 = str01.find(str01); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str01, 4); - VERIFY( csz01 == npos ); - csz01 = str01.find(str02, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str02, 3); - VERIFY( csz01 == npos ); - csz01 = str01.find(str03, 0); - VERIFY( csz01 == 8 ); - csz01 = str01.find(str03, 3); - VERIFY( csz01 == 8 ); - csz01 = str01.find(str03, 12); - VERIFY( csz01 == npos ); - - // An empty string_view consists of no characters - // therefore it should be found at every point in a string_view, - // except beyond the end - csz01 = str01.find(str04, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str04, 5); - VERIFY( csz01 == 5 ); - csz01 = str01.find(str04, str01.size()); - VERIFY( csz01 == str01.size() ); - csz01 = str01.find(str04, str01.size()+1); - VERIFY( csz01 == npos ); - - // size_type find(const char* s, size_type pos, size_type n) const; - csz01 = str01.find(str_lit01, 0, 3); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str_lit01, 3, 0); - VERIFY( csz01 == 3 ); - - // size_type find(const char* s, size_type pos = 0) const; - csz01 = str01.find(str_lit01); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str_lit01, 3); - VERIFY( csz01 == npos ); - - // size_type find(char c, size_type pos = 0) const; - csz01 = str01.find('z'); - csz02 = str01.size() - 1; - VERIFY( csz01 == csz02 ); - csz01 = str01.find('/'); - VERIFY( csz01 == npos ); - - return true; -} -#endif - -static int -main () -{ - test01(); -#ifndef GDB_STRING_VIEW - static_assert( test02() ); -#endif - - return 0; -} - -} // namespace operations_find_1 diff --git a/gdb/unittests/basic_string_view/operations/find/char/2.cc b/gdb/unittests/basic_string_view/operations/find/char/2.cc deleted file mode 100644 index c6bb97f10a6..00000000000 --- a/gdb/unittests/basic_string_view/operations/find/char/2.cc +++ /dev/null @@ -1,166 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view find_first_of - -namespace operations_find_2 { - -static void -test02 () -{ - typedef gdb::string_view::size_type csize_type; - csize_type npos = gdb::string_view::npos; - csize_type csz01, csz02; - - const char str_lit01[] = "mave"; - const gdb::string_view str01("mavericks, santa cruz"); - gdb::string_view str02(str_lit01); - gdb::string_view str03("s, s"); - gdb::string_view str04; - - // size_type find_first_of(const string_view&, size_type pos = 0) const; - gdb::string_view str05("xena rulez"); - csz01 = str01.find_first_of(str01); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str01, 4); - VERIFY( csz01 == 4 ); - csz01 = str01.find_first_of(str02, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str02, 3); - VERIFY( csz01 == 3 ); - csz01 = str01.find_first_of(str03, 0); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_of(str03, 3); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_of(str03, 12); - VERIFY( csz01 == 16 ); - csz01 = str01.find_first_of(str05, 0); - VERIFY( csz01 == 1 ); - csz01 = str01.find_first_of(str05, 4); - VERIFY( csz01 == 4 ); - - // An empty string_view consists of no characters - // therefore it should be found at every point in a string_view, - // except beyond the end - // However, str1.find_first_of(str2,pos) finds the first character in - // str1 (starting at pos) that exists in str2, which is none for empty str2 - csz01 = str01.find_first_of(str04, 0); - VERIFY( csz01 == npos ); - csz01 = str01.find_first_of(str04, 5); - VERIFY( csz01 == npos ); - - // size_type find_first_of(const char* s, size_type pos, size_type n) const; - csz01 = str01.find_first_of(str_lit01, 0, 3); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str_lit01, 3, 0); - VERIFY( csz01 == npos ); - - // size_type find_first_of(const char* s, size_type pos = 0) const; - csz01 = str01.find_first_of(str_lit01); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str_lit01, 3); - VERIFY( csz01 == 3 ); - - // size_type find_first_of(char c, size_type pos = 0) const; - csz01 = str01.find_first_of('z'); - csz02 = str01.size() - 1; - VERIFY( csz01 == csz02 ); -} - -#ifndef GDB_STRING_VIEW -constexpr bool -test03() -{ - typedef std::string_view::size_type csize_type; - csize_type npos = std::string_view::npos; - csize_type csz01 = 0, csz02 = 0; - - const char str_lit01[] = "mave"; - const std::string_view str01("mavericks, santa cruz"); - std::string_view str02(str_lit01); - std::string_view str03("s, s"); - std::string_view str04; - -#undef VERIFY -#define VERIFY(x) if(!(x)) return false - - // size_type find_first_of(const string_view&, size_type pos = 0) const; - std::string_view str05("xena rulez"); - csz01 = str01.find_first_of(str01); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str01, 4); - VERIFY( csz01 == 4 ); - csz01 = str01.find_first_of(str02, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str02, 3); - VERIFY( csz01 == 3 ); - csz01 = str01.find_first_of(str03, 0); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_of(str03, 3); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_of(str03, 12); - VERIFY( csz01 == 16 ); - csz01 = str01.find_first_of(str05, 0); - VERIFY( csz01 == 1 ); - csz01 = str01.find_first_of(str05, 4); - VERIFY( csz01 == 4 ); - - // An empty string_view consists of no characters - // therefore it should be found at every point in a string_view, - // except beyond the end - // However, str1.find_first_of(str2,pos) finds the first character in - // str1 (starting at pos) that exists in str2, which is none for empty str2 - csz01 = str01.find_first_of(str04, 0); - VERIFY( csz01 == npos ); - csz01 = str01.find_first_of(str04, 5); - VERIFY( csz01 == npos ); - - // size_type find_first_of(const char* s, size_type pos, size_type n) const; - csz01 = str01.find_first_of(str_lit01, 0, 3); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str_lit01, 3, 0); - VERIFY( csz01 == npos ); - - // size_type find_first_of(const char* s, size_type pos = 0) const; - csz01 = str01.find_first_of(str_lit01); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str_lit01, 3); - VERIFY( csz01 == 3 ); - - // size_type find_first_of(char c, size_type pos = 0) const; - csz01 = str01.find_first_of('z'); - csz02 = str01.size() - 1; - VERIFY( csz01 == csz02 ); - - return true; -} -#endif - -static int -main () -{ - test02(); -#ifndef GDB_STRING_VIEW - static_assert( test03() ); -#endif - - return 0; -} - -} // namespace operations_find_2 { diff --git a/gdb/unittests/basic_string_view/operations/find/char/3.cc b/gdb/unittests/basic_string_view/operations/find/char/3.cc deleted file mode 100644 index 078fda35d45..00000000000 --- a/gdb/unittests/basic_string_view/operations/find/char/3.cc +++ /dev/null @@ -1,166 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view find_first_not_of - -namespace operations_find_3 { - -static void -test03 () -{ - typedef gdb::string_view::size_type csize_type; - csize_type npos = gdb::string_view::npos; - csize_type csz01; - - const gdb::string_view str01("Bob Rock, per me"); - const char str_lit01[] = "Bob Rock"; - gdb::string_view str02("ovvero Trivi"); - gdb::string_view str03(str_lit01); - gdb::string_view str04; - - // size_type find_first_not_of(const string_view&, size_type pos = 0) const; - csz01 = str01.find_first_not_of(str01); - VERIFY( csz01 == npos ); - csz01 = str01.find_first_not_of(str02, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_not_of(str02, 10); - VERIFY( csz01 == 10 ); - csz01 = str01.find_first_not_of(str02, 12); - VERIFY( csz01 == 14 ); - csz01 = str01.find_first_not_of(str03, 0); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_not_of(str03, 15); - VERIFY( csz01 == 15 ); - csz01 = str01.find_first_not_of(str03, 16); - VERIFY( csz01 == npos ); - csz01 = str01.find_first_not_of(str04, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_not_of(str04, 12); - VERIFY( csz01 == 12 ); - csz01 = str03.find_first_not_of(str01, 0); - VERIFY( csz01 == npos ); - csz01 = str04.find_first_not_of(str02, 0); - VERIFY( csz01 == npos ); - - // size_type find_first_not_of(const char* s, size_type pos, size_type n) const; - csz01 = str01.find_first_not_of(str_lit01, 0, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_not_of(str_lit01, 0, 8); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_not_of(str_lit01, 10, 0); - VERIFY( csz01 == 10 ); - - // size_type find_first_not_of(const char* s, size_type pos = 0) const; - csz01 = str01.find_first_not_of(str_lit01); - VERIFY( csz01 == 8 ); - csz01 = str02.find_first_not_of(str_lit01, 2); - VERIFY( csz01 == 2 ); - - // size_type find_first_not_of(char c, size_type pos = 0) const; - csz01 = str01.find_first_not_of('B'); - VERIFY( csz01 == 1 ); - csz01 = str01.find_first_not_of('o', 1); - VERIFY( csz01 == 2 ); - csz01 = str02.find_first_not_of('z'); - VERIFY( csz01 == 0 ); - csz01 = str04.find_first_not_of('S'); - VERIFY( csz01 == npos ); -} - -#ifndef GDB_STRING_VIEW -constexpr bool -test04() -{ - typedef std::string_view::size_type csize_type; - csize_type npos = std::string_view::npos; - csize_type csz01 = 0; - - const std::string_view str01("Bob Rock, per me"); - const char str_lit01[] = "Bob Rock"; - std::string_view str02("ovvero Trivi"); - std::string_view str03(str_lit01); - std::string_view str04; - -#undef VERIFY -#define VERIFY(x) if(!(x)) return false - - // size_type find_first_not_of(const string_view&, size_type pos = 0) const; - csz01 = str01.find_first_not_of(str01); - VERIFY( csz01 == npos ); - csz01 = str01.find_first_not_of(str02, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_not_of(str02, 10); - VERIFY( csz01 == 10 ); - csz01 = str01.find_first_not_of(str02, 12); - VERIFY( csz01 == 14 ); - csz01 = str01.find_first_not_of(str03, 0); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_not_of(str03, 15); - VERIFY( csz01 == 15 ); - csz01 = str01.find_first_not_of(str03, 16); - VERIFY( csz01 == npos ); - csz01 = str01.find_first_not_of(str04, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_not_of(str04, 12); - VERIFY( csz01 == 12 ); - csz01 = str03.find_first_not_of(str01, 0); - VERIFY( csz01 == npos ); - csz01 = str04.find_first_not_of(str02, 0); - VERIFY( csz01 == npos ); - - // size_type find_first_not_of(const char* s, size_type pos, size_type n) const; - csz01 = str01.find_first_not_of(str_lit01, 0, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_not_of(str_lit01, 0, 8); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_not_of(str_lit01, 10, 0); - VERIFY( csz01 == 10 ); - - // size_type find_first_not_of(const char* s, size_type pos = 0) const; - csz01 = str01.find_first_not_of(str_lit01); - VERIFY( csz01 == 8 ); - csz01 = str02.find_first_not_of(str_lit01, 2); - VERIFY( csz01 == 2 ); - - // size_type find_first_not_of(char c, size_type pos = 0) const; - csz01 = str01.find_first_not_of('B'); - VERIFY( csz01 == 1 ); - csz01 = str01.find_first_not_of('o', 1); - VERIFY( csz01 == 2 ); - csz01 = str02.find_first_not_of('z'); - VERIFY( csz01 == 0 ); - csz01 = str04.find_first_not_of('S'); - VERIFY( csz01 == npos ); - - return true; -} -#endif - -static int -main () -{ - test03(); -#ifndef GDB_STRING_VIEW - static_assert( test04() ); -#endif - - return 0; -} - -} // namespace operations_find_3 diff --git a/gdb/unittests/basic_string_view/operations/find/char/4.cc b/gdb/unittests/basic_string_view/operations/find/char/4.cc deleted file mode 100644 index 9e19c01030d..00000000000 --- a/gdb/unittests/basic_string_view/operations/find/char/4.cc +++ /dev/null @@ -1,45 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view find - -namespace operations_find_4 { - -// libstdc++/31401 -static void -test01() -{ - typedef gdb::string_view::size_type csize_type; - csize_type npos = gdb::string_view::npos; - - gdb::string_view use = "anu"; - csize_type pos1 = use.find("a", npos); - - VERIFY( pos1 == npos ); -} - -static int -main () -{ - test01(); - - return 0; -} - -} // namespace operations_find_4 diff --git a/gdb/unittests/basic_string_view/operations/find/wchar_t/1.cc b/gdb/unittests/basic_string_view/operations/find/wchar_t/1.cc deleted file mode 100644 index 08e9e7249c8..00000000000 --- a/gdb/unittests/basic_string_view/operations/find/wchar_t/1.cc +++ /dev/null @@ -1,163 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view find - -#include -#include - -void -test01() -{ - typedef std::wstring_view::size_type csize_type; - typedef std::wstring_view::const_reference cref; - typedef std::wstring_view::reference ref; - csize_type npos = std::wstring_view::npos; - csize_type csz01, csz02; - - const wchar_t str_lit01[] = L"mave"; - const std::wstring_view str01(L"mavericks, santa cruz"); - std::wstring_view str02(str_lit01); - std::wstring_view str03(L"s, s"); - std::wstring_view str04; - - // size_type find(const wstring_view&, size_type pos = 0) const; - csz01 = str01.find(str01); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str01, 4); - VERIFY( csz01 == npos ); - csz01 = str01.find(str02, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str02, 3); - VERIFY( csz01 == npos ); - csz01 = str01.find(str03, 0); - VERIFY( csz01 == 8 ); - csz01 = str01.find(str03, 3); - VERIFY( csz01 == 8 ); - csz01 = str01.find(str03, 12); - VERIFY( csz01 == npos ); - - // An empty string_view consists of no characters - // therefore it should be found at every point in a string_view, - // except beyond the end - csz01 = str01.find(str04, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str04, 5); - VERIFY( csz01 == 5 ); - csz01 = str01.find(str04, str01.size()); - VERIFY( csz01 == str01.size() ); - csz01 = str01.find(str04, str01.size()+1); - VERIFY( csz01 == npos ); - - // size_type find(const wchar_t* s, size_type pos, size_type n) const; - csz01 = str01.find(str_lit01, 0, 3); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str_lit01, 3, 0); - VERIFY( csz01 == 3 ); - - // size_type find(const wchar_t* s, size_type pos = 0) const; - csz01 = str01.find(str_lit01); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str_lit01, 3); - VERIFY( csz01 == npos ); - - // size_type find(wchar_t c, size_type pos = 0) const; - csz01 = str01.find(L'z'); - csz02 = str01.size() - 1; - VERIFY( csz01 == csz02 ); - csz01 = str01.find(L'/'); - VERIFY( csz01 == npos ); -} - -constexpr bool -test02() -{ - typedef std::wstring_view::size_type csize_type; - typedef std::wstring_view::const_reference cref; - typedef std::wstring_view::reference ref; - csize_type npos = std::wstring_view::npos; - csize_type csz01 = 0, csz02 = 0; - - const wchar_t str_lit01[] = L"mave"; - const std::wstring_view str01(L"mavericks, santa cruz"); - std::wstring_view str02(str_lit01); - std::wstring_view str03(L"s, s"); - std::wstring_view str04; - -#undef VERIFY -#define VERIFY(x) if(!(x)) return false - - // size_type find(const wstring_view&, size_type pos = 0) const; - csz01 = str01.find(str01); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str01, 4); - VERIFY( csz01 == npos ); - csz01 = str01.find(str02, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str02, 3); - VERIFY( csz01 == npos ); - csz01 = str01.find(str03, 0); - VERIFY( csz01 == 8 ); - csz01 = str01.find(str03, 3); - VERIFY( csz01 == 8 ); - csz01 = str01.find(str03, 12); - VERIFY( csz01 == npos ); - - // An empty string_view consists of no characters - // therefore it should be found at every point in a string_view, - // except beyond the end - csz01 = str01.find(str04, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str04, 5); - VERIFY( csz01 == 5 ); - csz01 = str01.find(str04, str01.size()); - VERIFY( csz01 == str01.size() ); - csz01 = str01.find(str04, str01.size()+1); - VERIFY( csz01 == npos ); - - // size_type find(const wchar_t* s, size_type pos, size_type n) const; - csz01 = str01.find(str_lit01, 0, 3); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str_lit01, 3, 0); - VERIFY( csz01 == 3 ); - - // size_type find(const wchar_t* s, size_type pos = 0) const; - csz01 = str01.find(str_lit01); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str_lit01, 3); - VERIFY( csz01 == npos ); - - // size_type find(wchar_t c, size_type pos = 0) const; - csz01 = str01.find(L'z'); - csz02 = str01.size() - 1; - VERIFY( csz01 == csz02 ); - csz01 = str01.find(L'/'); - VERIFY( csz01 == npos ); - - return true; -} - -int -main() -{ - test01(); - static_assert( test02() ); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/operations/find/wchar_t/2.cc b/gdb/unittests/basic_string_view/operations/find/wchar_t/2.cc deleted file mode 100644 index fa38fe8e79c..00000000000 --- a/gdb/unittests/basic_string_view/operations/find/wchar_t/2.cc +++ /dev/null @@ -1,161 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view find_first_of - -#include -#include - -void -test02() -{ - typedef std::wstring_view::size_type csize_type; - csize_type npos = std::wstring_view::npos; - csize_type csz01, csz02; - - const wchar_t str_lit01[] = L"mave"; - const std::wstring_view str01(L"mavericks, santa cruz"); - std::wstring_view str02(str_lit01); - std::wstring_view str03(L"s, s"); - std::wstring_view str04; - - // size_type find_first_of(const wstring_view&, size_type pos = 0) const; - std::wstring_view str05(L"xena rulez"); - csz01 = str01.find_first_of(str01); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str01, 4); - VERIFY( csz01 == 4 ); - csz01 = str01.find_first_of(str02, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str02, 3); - VERIFY( csz01 == 3 ); - csz01 = str01.find_first_of(str03, 0); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_of(str03, 3); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_of(str03, 12); - VERIFY( csz01 == 16 ); - csz01 = str01.find_first_of(str05, 0); - VERIFY( csz01 == 1 ); - csz01 = str01.find_first_of(str05, 4); - VERIFY( csz01 == 4 ); - - // An empty string_view consists of no characters - // therefore it should be found at every point in a string_view, - // except beyond the end - // However, str1.find_first_of(str2,pos) finds the first character in - // str1 (starting at pos) that exists in str2, which is none for empty str2 - csz01 = str01.find_first_of(str04, 0); - VERIFY( csz01 == npos ); - csz01 = str01.find_first_of(str04, 5); - VERIFY( csz01 == npos ); - - // size_type find_first_of(const wchar_t* s, size_type pos, size_type n) const; - csz01 = str01.find_first_of(str_lit01, 0, 3); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str_lit01, 3, 0); - VERIFY( csz01 == npos ); - - // size_type find_first_of(const wchar_t* s, size_type pos = 0) const; - csz01 = str01.find_first_of(str_lit01); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str_lit01, 3); - VERIFY( csz01 == 3 ); - - // size_type find_first_of(wchar_t c, size_type pos = 0) const; - csz01 = str01.find_first_of(L'z'); - csz02 = str01.size() - 1; - VERIFY( csz01 == csz02 ); -} - -constexpr bool -test04() -{ - typedef std::wstring_view::size_type csize_type; - csize_type npos = std::wstring_view::npos; - csize_type csz01 = 0, csz02 = 0; - - const wchar_t str_lit01[] = L"mave"; - const std::wstring_view str01(L"mavericks, santa cruz"); - std::wstring_view str02(str_lit01); - std::wstring_view str03(L"s, s"); - std::wstring_view str04; - -#undef VERIFY -#define VERIFY(x) if(!(x)) return false - - // size_type find_first_of(const wstring_view&, size_type pos = 0) const; - std::wstring_view str05(L"xena rulez"); - csz01 = str01.find_first_of(str01); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str01, 4); - VERIFY( csz01 == 4 ); - csz01 = str01.find_first_of(str02, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str02, 3); - VERIFY( csz01 == 3 ); - csz01 = str01.find_first_of(str03, 0); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_of(str03, 3); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_of(str03, 12); - VERIFY( csz01 == 16 ); - csz01 = str01.find_first_of(str05, 0); - VERIFY( csz01 == 1 ); - csz01 = str01.find_first_of(str05, 4); - VERIFY( csz01 == 4 ); - - // An empty string_view consists of no characters - // therefore it should be found at every point in a string_view, - // except beyond the end - // However, str1.find_first_of(str2,pos) finds the first character in - // str1 (starting at pos) that exists in str2, which is none for empty str2 - csz01 = str01.find_first_of(str04, 0); - VERIFY( csz01 == npos ); - csz01 = str01.find_first_of(str04, 5); - VERIFY( csz01 == npos ); - - // size_type find_first_of(const wchar_t* s, size_type pos, size_type n) const; - csz01 = str01.find_first_of(str_lit01, 0, 3); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str_lit01, 3, 0); - VERIFY( csz01 == npos ); - - // size_type find_first_of(const wchar_t* s, size_type pos = 0) const; - csz01 = str01.find_first_of(str_lit01); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str_lit01, 3); - VERIFY( csz01 == 3 ); - - // size_type find_first_of(wchar_t c, size_type pos = 0) const; - csz01 = str01.find_first_of(L'z'); - csz02 = str01.size() - 1; - VERIFY( csz01 == csz02 ); - - return true; -} - -int -main() -{ - test02(); - static_assert( test04() ); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/operations/find/wchar_t/3.cc b/gdb/unittests/basic_string_view/operations/find/wchar_t/3.cc deleted file mode 100644 index 93a238c3865..00000000000 --- a/gdb/unittests/basic_string_view/operations/find/wchar_t/3.cc +++ /dev/null @@ -1,161 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view find_first_not_of - -#include -#include - -void -test03() -{ - typedef std::wstring_view::size_type csize_type; - csize_type npos = std::wstring_view::npos; - csize_type csz01; - - const std::wstring_view str01(L"Bob Rock, per me"); - const wchar_t str_lit01[] = L"Bob Rock"; - std::wstring_view str02(L"ovvero Trivi"); - std::wstring_view str03(str_lit01); - std::wstring_view str04; - - // size_type find_first_not_of(const string_view&, size_type pos = 0) const; - csz01 = str01.find_first_not_of(str01); - VERIFY( csz01 == npos ); - csz01 = str01.find_first_not_of(str02, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_not_of(str02, 10); - VERIFY( csz01 == 10 ); - csz01 = str01.find_first_not_of(str02, 12); - VERIFY( csz01 == 14 ); - csz01 = str01.find_first_not_of(str03, 0); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_not_of(str03, 15); - VERIFY( csz01 == 15 ); - csz01 = str01.find_first_not_of(str03, 16); - VERIFY( csz01 == npos ); - csz01 = str01.find_first_not_of(str04, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_not_of(str04, 12); - VERIFY( csz01 == 12 ); - csz01 = str03.find_first_not_of(str01, 0); - VERIFY( csz01 == npos ); - csz01 = str04.find_first_not_of(str02, 0); - VERIFY( csz01 == npos ); - - // size_type find_first_not_of(const char* s, size_type pos, size_type n) const; - csz01 = str01.find_first_not_of(str_lit01, 0, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_not_of(str_lit01, 0, 8); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_not_of(str_lit01, 10, 0); - VERIFY( csz01 == 10 ); - - // size_type find_first_not_of(const char* s, size_type pos = 0) const; - csz01 = str01.find_first_not_of(str_lit01); - VERIFY( csz01 == 8 ); - csz01 = str02.find_first_not_of(str_lit01, 2); - VERIFY( csz01 == 2 ); - - // size_type find_first_not_of(char c, size_type pos = 0) const; - csz01 = str01.find_first_not_of(L'B'); - VERIFY( csz01 == 1 ); - csz01 = str01.find_first_not_of(L'o', 1); - VERIFY( csz01 == 2 ); - csz01 = str02.find_first_not_of(L'z'); - VERIFY( csz01 == 0 ); - csz01 = str04.find_first_not_of(L'S'); - VERIFY( csz01 == npos ); -} - -constexpr bool -test04() -{ - typedef std::wstring_view::size_type csize_type; - csize_type npos = std::wstring_view::npos; - csize_type csz01 = 0; - - const std::wstring_view str01(L"Bob Rock, per me"); - const wchar_t str_lit01[] = L"Bob Rock"; - std::wstring_view str02(L"ovvero Trivi"); - std::wstring_view str03(str_lit01); - std::wstring_view str04; - -#undef VERIFY -#define VERIFY(x) if(!(x)) return false - - // size_type find_first_not_of(const string_view&, size_type pos = 0) const; - csz01 = str01.find_first_not_of(str01); - VERIFY( csz01 == npos ); - csz01 = str01.find_first_not_of(str02, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_not_of(str02, 10); - VERIFY( csz01 == 10 ); - csz01 = str01.find_first_not_of(str02, 12); - VERIFY( csz01 == 14 ); - csz01 = str01.find_first_not_of(str03, 0); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_not_of(str03, 15); - VERIFY( csz01 == 15 ); - csz01 = str01.find_first_not_of(str03, 16); - VERIFY( csz01 == npos ); - csz01 = str01.find_first_not_of(str04, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_not_of(str04, 12); - VERIFY( csz01 == 12 ); - csz01 = str03.find_first_not_of(str01, 0); - VERIFY( csz01 == npos ); - csz01 = str04.find_first_not_of(str02, 0); - VERIFY( csz01 == npos ); - - // size_type find_first_not_of(const char* s, size_type pos, size_type n) const; - csz01 = str01.find_first_not_of(str_lit01, 0, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_not_of(str_lit01, 0, 8); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_not_of(str_lit01, 10, 0); - VERIFY( csz01 == 10 ); - - // size_type find_first_not_of(const char* s, size_type pos = 0) const; - csz01 = str01.find_first_not_of(str_lit01); - VERIFY( csz01 == 8 ); - csz01 = str02.find_first_not_of(str_lit01, 2); - VERIFY( csz01 == 2 ); - - // size_type find_first_not_of(char c, size_type pos = 0) const; - csz01 = str01.find_first_not_of(L'B'); - VERIFY( csz01 == 1 ); - csz01 = str01.find_first_not_of(L'o', 1); - VERIFY( csz01 == 2 ); - csz01 = str02.find_first_not_of(L'z'); - VERIFY( csz01 == 0 ); - csz01 = str04.find_first_not_of(L'S'); - VERIFY( csz01 == npos ); - - return true; -} - -int -main() -{ - test03(); - static_assert( test04() ); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/operations/find/wchar_t/4.cc b/gdb/unittests/basic_string_view/operations/find/wchar_t/4.cc deleted file mode 100644 index 7b484bd6b9b..00000000000 --- a/gdb/unittests/basic_string_view/operations/find/wchar_t/4.cc +++ /dev/null @@ -1,44 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view find - -#include -#include - -// libstdc++/31401 -void -test01() -{ - typedef std::wstring_view::size_type csize_type; - csize_type npos = std::wstring_view::npos; - - std::wstring_view use = L"anu"; - csize_type pos1 = use.find(L"a", npos); - - VERIFY( pos1 == npos ); -} - -int -main() -{ - test01(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/operations/rfind/char/1.cc b/gdb/unittests/basic_string_view/operations/rfind/char/1.cc deleted file mode 100644 index b764cd959ab..00000000000 --- a/gdb/unittests/basic_string_view/operations/rfind/char/1.cc +++ /dev/null @@ -1,95 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -namespace operations_rfind_1 { - -// basic_string_view rfind - -static void -test01 () -{ - typedef gdb::string_view::size_type csize_type; - typedef gdb::string_view::const_reference cref; - typedef gdb::string_view::reference ref; - csize_type npos = gdb::string_view::npos; - csize_type csz01, csz02; - - const char str_lit01[] = "mave"; - const gdb::string_view str01("mavericks, santa cruz"); - gdb::string_view str02(str_lit01); - gdb::string_view str03("s, s"); - gdb::string_view str04; - - // size_type rfind(const string_view&, size_type pos = 0) const; - csz01 = str01.rfind(str01); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str01, 4); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str02,3); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str02); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str03); - VERIFY( csz01 == 8 ); - csz01 = str01.rfind(str03, 3); - VERIFY( csz01 == npos ); - csz01 = str01.rfind(str03, 12); - VERIFY( csz01 == 8 ); - - // An empty string_view consists of no characters - // therefore it should be found at every point in a string_view, - // except beyond the end - csz01 = str01.rfind(str04, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str04, 5); - VERIFY( csz01 == 5 ); - csz01 = str01.rfind(str04, str01.size()); - VERIFY( csz01 == str01.size() ); - csz01 = str01.rfind(str04, str01.size()+1); - VERIFY( csz01 == str01.size() ); - - // size_type rfind(const char* s, size_type pos, size_type n) const; - csz01 = str01.rfind(str_lit01, 0, 3); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str_lit01, 3, 0); - VERIFY( csz01 == 3 ); - - // size_type rfind(const char* s, size_type pos = 0) const; - csz01 = str01.rfind(str_lit01); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str_lit01, 3); - VERIFY( csz01 == 0 ); - - // size_type rfind(char c, size_type pos = 0) const; - csz01 = str01.rfind('z'); - csz02 = str01.size() - 1; - VERIFY( csz01 == csz02 ); - csz01 = str01.rfind('/'); - VERIFY( csz01 == npos ); -} - -static int -main () -{ - test01(); - - return 0; -} - -} // namespace operations_rfind_1 diff --git a/gdb/unittests/basic_string_view/operations/rfind/char/2.cc b/gdb/unittests/basic_string_view/operations/rfind/char/2.cc deleted file mode 100644 index 915a111fbcc..00000000000 --- a/gdb/unittests/basic_string_view/operations/rfind/char/2.cc +++ /dev/null @@ -1,53 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -namespace operations_rfind_2 { - -// basic_string_view::find_last_of - -static void -test02 () -{ - gdb::string_view z("ab"); - gdb::string_view::size_type pos; - pos = z.find_last_of("ab"); - VERIFY( pos == 1 ); - pos = z.find_last_of("Xa"); - VERIFY( pos == 0 ); - pos = z.find_last_of("Xb"); - VERIFY( pos == 1 ); - pos = z.find_last_of("XYZ"); - VERIFY( pos == gdb::string_view::npos ); - pos = z.find_last_of('a'); - VERIFY( pos == 0 ); - pos = z.find_last_of('b'); - VERIFY( pos == 1 ); - pos = z.find_last_of('X'); - VERIFY( pos == gdb::string_view::npos ); -} - -static int -main () -{ - test02(); - - return 0; -} - -} // namespace operations_rfind_2 diff --git a/gdb/unittests/basic_string_view/operations/rfind/char/3.cc b/gdb/unittests/basic_string_view/operations/rfind/char/3.cc deleted file mode 100644 index a15debf97ec..00000000000 --- a/gdb/unittests/basic_string_view/operations/rfind/char/3.cc +++ /dev/null @@ -1,68 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -namespace operations_rfind_3 { - -// basic_string_view::find_last_not_of - -static void -test03 () -{ - typedef gdb::string_view::size_type csize_type; - gdb::string_view::size_type pos; - csize_type npos = gdb::string_view::npos; - - gdb::string_view x; - pos = x.find_last_not_of('X'); - VERIFY( pos == npos ); - pos = x.find_last_not_of("XYZ"); - VERIFY( pos == npos ); - - gdb::string_view y("a"); - pos = y.find_last_not_of('X'); - VERIFY( pos == 0 ); - pos = y.find_last_not_of('a'); - VERIFY( pos == npos ); - pos = y.find_last_not_of("XYZ"); - VERIFY( pos == 0 ); - pos = y.find_last_not_of("a"); - VERIFY( pos == npos ); - - gdb::string_view z("ab"); - pos = z.find_last_not_of('X'); - VERIFY( pos == 1 ); - pos = z.find_last_not_of("XYZ"); - VERIFY( pos == 1 ); - pos = z.find_last_not_of('b'); - VERIFY( pos == 0 ); - pos = z.find_last_not_of("Xb"); - VERIFY( pos == 0 ); - pos = z.find_last_not_of("Xa"); - VERIFY( pos == 1 ); -} - -static int -main () -{ - test03(); - - return 0; -} - -} // namespace operations_rfind_3 diff --git a/gdb/unittests/basic_string_view/operations/rfind/wchar_t/1.cc b/gdb/unittests/basic_string_view/operations/rfind/wchar_t/1.cc deleted file mode 100644 index d5ad681eded..00000000000 --- a/gdb/unittests/basic_string_view/operations/rfind/wchar_t/1.cc +++ /dev/null @@ -1,94 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -#include -#include - -// basic_string_view rfind - -void -test01() -{ - typedef std::wstring_view::size_type csize_type; - typedef std::wstring_view::const_reference cref; - typedef std::wstring_view::reference ref; - csize_type npos = std::wstring_view::npos; - csize_type csz01, csz02; - - const wchar_t str_lit01[] = L"mave"; - const std::wstring_view str01(L"mavericks, santa cruz"); - std::wstring_view str02(str_lit01); - std::wstring_view str03(L"s, s"); - std::wstring_view str04; - - // size_type rfind(const wstring_view&, size_type pos = 0) const; - csz01 = str01.rfind(str01); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str01, 4); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str02,3); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str02); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str03); - VERIFY( csz01 == 8 ); - csz01 = str01.rfind(str03, 3); - VERIFY( csz01 == npos ); - csz01 = str01.rfind(str03, 12); - VERIFY( csz01 == 8 ); - - // An empty string_view consists of no characters - // therefore it should be found at every point in a string_view, - // except beyond the end - csz01 = str01.rfind(str04, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str04, 5); - VERIFY( csz01 == 5 ); - csz01 = str01.rfind(str04, str01.size()); - VERIFY( csz01 == str01.size() ); - csz01 = str01.rfind(str04, str01.size()+1); - VERIFY( csz01 == str01.size() ); - - // size_type rfind(const wchar_t* s, size_type pos, size_type n) const; - csz01 = str01.rfind(str_lit01, 0, 3); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str_lit01, 3, 0); - VERIFY( csz01 == 3 ); - - // size_type rfind(const wchar_t* s, size_type pos = 0) const; - csz01 = str01.rfind(str_lit01); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str_lit01, 3); - VERIFY( csz01 == 0 ); - - // size_type rfind(wchar_t c, size_type pos = 0) const; - csz01 = str01.rfind(L'z'); - csz02 = str01.size() - 1; - VERIFY( csz01 == csz02 ); - csz01 = str01.rfind(L'/'); - VERIFY( csz01 == npos ); -} - -int -main() -{ - test01(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/operations/rfind/wchar_t/2.cc b/gdb/unittests/basic_string_view/operations/rfind/wchar_t/2.cc deleted file mode 100644 index 6f3dc744ad7..00000000000 --- a/gdb/unittests/basic_string_view/operations/rfind/wchar_t/2.cc +++ /dev/null @@ -1,52 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -#include -#include - -// basic_string_view::find_last_of - -void -test02() -{ - std::wstring_view::size_type pos; - std::wstring_view z(L"ab"); - pos = z.find_last_of(L"ab"); - VERIFY( pos == 1 ); - pos = z.find_last_of(L"Xa"); - VERIFY( pos == 0 ); - pos = z.find_last_of(L"Xb"); - VERIFY( pos == 1 ); - pos = z.find_last_of(L"XYZ"); - VERIFY( pos == std::wstring_view::npos ); - pos = z.find_last_of(L'a'); - VERIFY( pos == 0 ); - pos = z.find_last_of(L'b'); - VERIFY( pos == 1 ); - pos = z.find_last_of(L'X'); - VERIFY( pos == std::wstring_view::npos ); -} - -int -main() -{ - test02(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/operations/rfind/wchar_t/3.cc b/gdb/unittests/basic_string_view/operations/rfind/wchar_t/3.cc deleted file mode 100644 index b67f8ec08af..00000000000 --- a/gdb/unittests/basic_string_view/operations/rfind/wchar_t/3.cc +++ /dev/null @@ -1,66 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -#include -#include - -// basic_string_view::find_last_not_of - -void -test03() -{ - typedef std::wstring_view::size_type csize_type; - std::wstring_view::size_type pos; - csize_type npos = std::wstring_view::npos; - - std::wstring_view x; - pos = x.find_last_not_of(L'X'); - VERIFY( pos == npos ); - pos = x.find_last_not_of(L"XYZ"); - VERIFY( pos == npos ); - - std::wstring_view y(L"a"); - pos = y.find_last_not_of(L'X'); - VERIFY( pos == 0 ); - pos = y.find_last_not_of(L'a'); - VERIFY( pos == npos ); - pos = y.find_last_not_of(L"XYZ"); - VERIFY( pos == 0 ); - pos = y.find_last_not_of(L"a"); - VERIFY( pos == npos ); - - std::wstring_view z(L"ab"); - pos = z.find_last_not_of(L'X'); - VERIFY( pos == 1 ); - pos = z.find_last_not_of(L"XYZ"); - VERIFY( pos == 1 ); - pos = z.find_last_not_of(L'b'); - VERIFY( pos == 0 ); - pos = z.find_last_not_of(L"Xb"); - VERIFY( pos == 0 ); - pos = z.find_last_not_of(L"Xa"); - VERIFY( pos == 1 ); -} -int -main() -{ - test03(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/operations/string_conversion/1.cc b/gdb/unittests/basic_string_view/operations/string_conversion/1.cc deleted file mode 100644 index 33784231d8d..00000000000 --- a/gdb/unittests/basic_string_view/operations/string_conversion/1.cc +++ /dev/null @@ -1,51 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2014-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view::to_string - -#include -#include -#include -#include -#include - -void -test01() -{ - const char str_lit[] = "123456789A"; - const std::string_view sv(str_lit); - char buffer[4] = { 0 }; - - std::string s1{sv}; - VERIFY( s1 == str_lit ); - using test_alloc = __gnu_test::tracker_allocator; - std::basic_string, test_alloc> - s2{sv, test_alloc{}}; - static_assert( std::is_same::value, - "to_string() uses custom allocator" ); - VERIFY( std::equal(s1.begin(), s1.end(), s2.begin(), s2.end()) ); - auto s3 = static_cast(sv); - VERIFY( s3 == s1 ); -} - -int -main() -{ - test01(); -} diff --git a/gdb/unittests/basic_string_view/operations/substr/char/1.cc b/gdb/unittests/basic_string_view/operations/substr/char/1.cc deleted file mode 100644 index 19454466699..00000000000 --- a/gdb/unittests/basic_string_view/operations/substr/char/1.cc +++ /dev/null @@ -1,79 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view::substr - -namespace operations_substr_1 { - -static void -test01 () -{ - typedef gdb::string_view::size_type csize_type; - typedef gdb::string_view::const_reference cref; - typedef gdb::string_view::reference ref; - csize_type csz01; - - const char str_lit01[] = "rockaway, pacifica"; - const gdb::string_view str01(str_lit01); - gdb::string_view str02; - - // basic_string_view - // substr(size_type pos = 0, size_type n = npos) const; - csz01 = str01.size(); - str02 = str01.substr(0, 1); - VERIFY( str02 == "r" ); - str02 = str01.substr(10); - VERIFY( str02 == "pacifica" ); - - try - { - str02 = str01.substr(csz01 + 1); - VERIFY( false ); - } - catch(gdb_exception& fail) - { - VERIFY( true ); - } - catch(...) - { - VERIFY( false ); - } - - try - { - str02 = str01.substr(csz01); - VERIFY( str02.size() == 0 ); - VERIFY( str02.begin() == str01.end() ); - VERIFY( true ); - } - catch(...) - { - VERIFY( false ); - } -} - -static int -main () -{ - test01(); - - return 0; -} - -} // namespace operations_substr_1 diff --git a/gdb/unittests/basic_string_view/operations/substr/wchar_t/1.cc b/gdb/unittests/basic_string_view/operations/substr/wchar_t/1.cc deleted file mode 100644 index bfe79ac7a55..00000000000 --- a/gdb/unittests/basic_string_view/operations/substr/wchar_t/1.cc +++ /dev/null @@ -1,79 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view::substr - -#include -#include -#include - -void -test01() -{ - typedef std::wstring_view::size_type csize_type; - typedef std::wstring_view::const_reference cref; - typedef std::wstring_view::reference ref; - csize_type csz01; - - const wchar_t str_lit01[] = L"rockaway, pacifica"; - const std::wstring_view str01(str_lit01); - std::wstring_view str02; - - // basic_string_view - // substr(size_type pos = 0, size_type n = npos) const; - csz01 = str01.size(); - str02 = str01.substr(0, 1); - VERIFY( str02 == L"r" ); - str02 = str01.substr(10); - VERIFY( str02 == L"pacifica" ); - - try - { - str02 = str01.substr(csz01 + 1); - VERIFY( false ); - } - catch(std::out_of_range& fail) - { - VERIFY( true ); - } - catch(...) - { - VERIFY( false ); - } - - try - { - str02 = str01.substr(csz01); - VERIFY( str02.size() == 0 ); - VERIFY( str02.begin() == str01.end() ); - VERIFY( true ); - } - catch(...) - { - VERIFY( false ); - } -} - -int -main() -{ - test01(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/operators/char/2.cc b/gdb/unittests/basic_string_view/operators/char/2.cc deleted file mode 100644 index 30e557f4599..00000000000 --- a/gdb/unittests/basic_string_view/operators/char/2.cc +++ /dev/null @@ -1,373 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string non-member functions - -// operator== -/* -template - bool operator==(const basic_string& lhs, - const basic_string& rhs); - -template - bool operator==(const charT* lhs, - const basic_string& rhs); - -template - bool operator==(const basic_string& lhs, - const charT* rhs); -*/ - -// operator!= -/* -template - bool operator!=(const basic_string& lhs, - const basic_string& rhs); - -template - bool operator!=(const charT* lhs, - const basic_string& rhs); - -template - bool operator!=(const basic_string& lhs, - const charT* rhs); -*/ - -// operator< -/* -template - bool operator< (const basic_string& lhs, - const basic_string& rhs); - -template - bool operator< (const basic_string& lhs, - const charT* rhs); - -template - bool operator< (const charT* lhs, - const basic_string& rhs); -*/ - -// operator> -/* -template - bool operator> (const basic_string& lhs, - const basic_string& rhs); - -template - bool operator> (const basic_string& lhs, - const charT* rhs); - -template - bool operator> (const charT* lhs, - const basic_string& rhs); -*/ - -// operator<= -/* -template - bool operator<=(const basic_string& lhs, - const basic_string& rhs); - -template - bool operator<=(const basic_string& lhs, - const charT* rhs); - -template - bool operator<=(const charT* lhs, - const basic_string& rhs); -*/ - -// operator>= -/* -template - bool operator>=(const basic_string& lhs, - const basic_string& rhs); - -template - bool operator>=(const basic_string& lhs, - const charT* rhs); - -template - bool operator>=(const charT* lhs, - const basic_string& rhs); -*/ - -namespace operators_2 { - -static void -test01() -{ - gdb::string_view str_0("costa rica"); - gdb::string_view str_1("costa marbella"); - gdb::string_view str_2("cost"); - gdb::string_view str_3("costa ricans"); - gdb::string_view str_4; - - str_4 = str_0; - //comparisons between string objects - VERIFY( !(str_0 == str_1) ); - VERIFY( !(str_0 == str_2) ); - VERIFY( !(str_0 == str_3) ); - VERIFY( !(str_1 == str_0) ); - VERIFY( !(str_2 == str_0) ); - VERIFY( !(str_3 == str_0) ); - VERIFY( str_4 == str_0 ); - VERIFY( str_0 == str_4 ); - - VERIFY( str_0 != str_1 ); - VERIFY( str_0 != str_2 ); - VERIFY( str_0 != str_3 ); - VERIFY( str_1 != str_0 ); - VERIFY( str_2 != str_0 ); - VERIFY( str_3 != str_0 ); - VERIFY( !(str_0 != str_4) ); - VERIFY( !(str_4 != str_0) ); - - VERIFY( str_0 > str_1 ); //true cuz r>m - VERIFY( str_0 > str_2 ); - VERIFY( !(str_0 > str_3) ); - VERIFY( !(str_1 > str_0) ); //false cuz m str_0) ); - VERIFY( str_3 > str_0 ); - VERIFY( !(str_0 > str_4) ); - VERIFY( !(str_4 > str_0) ); - - VERIFY( !(str_0 < str_1) ); //false cuz r>m - VERIFY( !(str_0 < str_2) ); - VERIFY( str_0 < str_3 ); - VERIFY( str_1 < str_0 ); //true cuz m= str_1 ); //true cuz r>m - VERIFY( str_0 >= str_2 ); - VERIFY( !(str_0 >= str_3) ); - VERIFY( !(str_1 >= str_0) );//false cuz m= str_0) ); - VERIFY( str_3 >= str_0 ); - VERIFY( str_0 >= str_4 ); - VERIFY( str_4 >= str_0 ); - - VERIFY( !(str_0 <= str_1) );//false cuz r>m - VERIFY( !(str_0 <= str_2) ); - VERIFY( str_0 <= str_3 ); - VERIFY( str_1 <= str_0 );//true cuz m "costa marbella" ); //true cuz r>m - VERIFY( str_0 > "cost" ); - VERIFY( !(str_0 > "costa ricans") ); - VERIFY( !("costa marbella" > str_0) );//false cuz m str_0) ); - VERIFY( "costa ricans" > str_0 ); - VERIFY( !("costa rica" > str_0) ); - VERIFY( !(str_0 > "costa rica") ); - - VERIFY( !(str_0 < "costa marbella") );//false cuz r>m - VERIFY( !(str_0 < "cost") ); - VERIFY( str_0 < "costa ricans" ); - VERIFY( "costa marbella" < str_0 );//true cuz m= "costa marbella" );//true cuz r>m - VERIFY( str_0 >= "cost" ); - VERIFY( !(str_0 >= "costa ricans") ); - VERIFY( !("costa marbella" >= str_0) );//false cuz m= str_0) ); - VERIFY( "costa ricans" >= str_0 ); - VERIFY( "costa rica" >= str_0 ); - VERIFY( str_0 >= "costa rica" ); - - VERIFY( !(str_0 <= "costa marbella") );//false cuz r>m - VERIFY( !(str_0 <= "cost") ); - VERIFY( str_0 <= "costa ricans" ); - VERIFY( "costa marbella" <= str_0 );//true cuz m str_1 ); //true cuz r>m - VERIFY( str_0 > str_2 ); - VERIFY( !(str_0 > str_3) ); - VERIFY( !(str_1 > str_0) ); //false cuz m str_0) ); - VERIFY( str_3 > str_0 ); - VERIFY( !(str_0 > str_4) ); - VERIFY( !(str_4 > str_0) ); - - VERIFY( !(str_0 < str_1) ); //false cuz r>m - VERIFY( !(str_0 < str_2) ); - VERIFY( str_0 < str_3 ); - VERIFY( str_1 < str_0 ); //true cuz m= str_1 ); //true cuz r>m - VERIFY( str_0 >= str_2 ); - VERIFY( !(str_0 >= str_3) ); - VERIFY( !(str_1 >= str_0) );//false cuz m= str_0) ); - VERIFY( str_3 >= str_0 ); - VERIFY( str_0 >= str_4 ); - VERIFY( str_4 >= str_0 ); - - VERIFY( !(str_0 <= str_1) );//false cuz r>m - VERIFY( !(str_0 <= str_2) ); - VERIFY( str_0 <= str_3 ); - VERIFY( str_1 <= str_0 );//true cuz m "costa marbella" ); //true cuz r>m - VERIFY( str_0 > "cost" ); - VERIFY( !(str_0 > "costa ricans") ); - VERIFY( !("costa marbella" > str_0) );//false cuz m str_0) ); - VERIFY( "costa ricans" > str_0 ); - VERIFY( !("costa rica" > str_0) ); - VERIFY( !(str_0 > "costa rica") ); - - VERIFY( !(str_0 < "costa marbella") );//false cuz r>m - VERIFY( !(str_0 < "cost") ); - VERIFY( str_0 < "costa ricans" ); - VERIFY( "costa marbella" < str_0 );//true cuz m= "costa marbella" );//true cuz r>m - VERIFY( str_0 >= "cost" ); - VERIFY( !(str_0 >= "costa ricans") ); - VERIFY( !("costa marbella" >= str_0) );//false cuz m= str_0) ); - VERIFY( "costa ricans" >= str_0 ); - VERIFY( "costa rica" >= str_0 ); - VERIFY( str_0 >= "costa rica" ); - - VERIFY( !(str_0 <= "costa marbella") );//false cuz r>m - VERIFY( !(str_0 <= "cost") ); - VERIFY( str_0 <= "costa ricans" ); - VERIFY( "costa marbella" <= str_0 );//true cuz m. - -// basic_string_view non-member functions - -// operator== -/* -template - bool operator==(const basic_string_view& lhs, - const basic_string_view& rhs); - -template - bool operator==(const charT* lhs, - const basic_string_view& rhs); - -template - bool operator==(const basic_string_view& lhs, - const charT* rhs); -*/ - -// operator!= -/* -template - bool operator!=(const basic_string_view& lhs, - const basic_string_view& rhs); - -template - bool operator!=(const charT* lhs, - const basic_string_view& rhs); - -template - bool operator!=(const basic_string_view& lhs, - const charT* rhs); -*/ - -// operator< -/* -template - bool operator< (const basic_string_view& lhs, - const basic_string_view& rhs); - -template - bool operator< (const basic_string_view& lhs, - const charT* rhs); - -template - bool operator< (const charT* lhs, - const basic_string_view& rhs); -*/ - -// operator> -/* -template - bool operator> (const basic_string_view& lhs, - const basic_string_view& rhs); - -template - bool operator> (const basic_string_view& lhs, - const charT* rhs); - -template - bool operator> (const charT* lhs, - const basic_string_view& rhs); -*/ - -// operator<= -/* -template - bool operator<=(const basic_string_view& lhs, - const basic_string_view& rhs); - -template - bool operator<=(const basic_string_view& lhs, - const charT* rhs); - -template - bool operator<=(const charT* lhs, - const basic_string_view& rhs); -*/ - -// operator>= -/* -template - bool operator>=(const basic_string_view& lhs, - const basic_string_view& rhs); - -template - bool operator>=(const basic_string_view& lhs, - const charT* rhs); - -template - bool operator>=(const charT* lhs, - const basic_string_view& rhs); -*/ - -#include -#include - -void -test01() -{ - std::wstring_view str_0(L"costa rica"); - std::wstring_view str_1(L"costa marbella"); - std::wstring_view str_2(L"cost"); - std::wstring_view str_3(L"costa ricans"); - std::wstring_view str_4; - - str_4 = str_0; - //comparisons between string_view objects - VERIFY( !(str_0 == str_1) ); - VERIFY( !(str_0 == str_2) ); - VERIFY( !(str_0 == str_3) ); - VERIFY( !(str_1 == str_0) ); - VERIFY( !(str_2 == str_0) ); - VERIFY( !(str_3 == str_0) ); - VERIFY( str_4 == str_0 ); - VERIFY( str_0 == str_4 ); - - VERIFY( str_0 != str_1 ); - VERIFY( str_0 != str_2 ); - VERIFY( str_0 != str_3 ); - VERIFY( str_1 != str_0 ); - VERIFY( str_2 != str_0 ); - VERIFY( str_3 != str_0 ); - VERIFY( !(str_0 != str_4) ); - VERIFY( !(str_4 != str_0) ); - - VERIFY( str_0 > str_1 ); //true cuz r>m - VERIFY( str_0 > str_2 ); - VERIFY( !(str_0 > str_3) ); - VERIFY( !(str_1 > str_0) ); //false cuz m str_0) ); - VERIFY( str_3 > str_0 ); - VERIFY( !(str_0 > str_4) ); - VERIFY( !(str_4 > str_0) ); - - VERIFY( !(str_0 < str_1) ); //false cuz r>m - VERIFY( !(str_0 < str_2) ); - VERIFY( str_0 < str_3 ); - VERIFY( str_1 < str_0 ); //true cuz m= str_1 ); //true cuz r>m - VERIFY( str_0 >= str_2 ); - VERIFY( !(str_0 >= str_3) ); - VERIFY( !(str_1 >= str_0) );//false cuz m= str_0) ); - VERIFY( str_3 >= str_0 ); - VERIFY( str_0 >= str_4 ); - VERIFY( str_4 >= str_0 ); - - VERIFY( !(str_0 <= str_1) );//false cuz r>m - VERIFY( !(str_0 <= str_2) ); - VERIFY( str_0 <= str_3 ); - VERIFY( str_1 <= str_0 );//true cuz m L"costa marbella" ); //true cuz r>m - VERIFY( str_0 > L"cost" ); - VERIFY( !(str_0 > L"costa ricans") ); - VERIFY( !(L"costa marbella" > str_0) );//false cuz m str_0) ); - VERIFY( L"costa ricans" > str_0 ); - VERIFY( !(L"costa rica" > str_0) ); - VERIFY( !(str_0 > L"costa rica") ); - - VERIFY( !(str_0 < L"costa marbella") );//false cuz r>m - VERIFY( !(str_0 < L"cost") ); - VERIFY( str_0 < L"costa ricans" ); - VERIFY( L"costa marbella" < str_0 );//true cuz m= L"costa marbella" );//true cuz r>m - VERIFY( str_0 >= L"cost" ); - VERIFY( !(str_0 >= L"costa ricans") ); - VERIFY( !(L"costa marbella" >= str_0) );//false cuz m= str_0) ); - VERIFY( L"costa ricans" >= str_0 ); - VERIFY( L"costa rica" >= str_0 ); - VERIFY( str_0 >= L"costa rica" ); - - VERIFY( !(str_0 <= L"costa marbella") );//false cuz r>m - VERIFY( !(str_0 <= L"cost") ); - VERIFY( str_0 <= L"costa ricans" ); - VERIFY( L"costa marbella" <= str_0 );//true cuz m str_1 ); //true cuz r>m - VERIFY( str_0 > str_2 ); - VERIFY( !(str_0 > str_3) ); - VERIFY( !(str_1 > str_0) ); //false cuz m str_0) ); - VERIFY( str_3 > str_0 ); - VERIFY( !(str_0 > str_4) ); - VERIFY( !(str_4 > str_0) ); - - VERIFY( !(str_0 < str_1) ); //false cuz r>m - VERIFY( !(str_0 < str_2) ); - VERIFY( str_0 < str_3 ); - VERIFY( str_1 < str_0 ); //true cuz m= str_1 ); //true cuz r>m - VERIFY( str_0 >= str_2 ); - VERIFY( !(str_0 >= str_3) ); - VERIFY( !(str_1 >= str_0) );//false cuz m= str_0) ); - VERIFY( str_3 >= str_0 ); - VERIFY( str_0 >= str_4 ); - VERIFY( str_4 >= str_0 ); - - VERIFY( !(str_0 <= str_1) );//false cuz r>m - VERIFY( !(str_0 <= str_2) ); - VERIFY( str_0 <= str_3 ); - VERIFY( str_1 <= str_0 );//true cuz m L"costa marbella" ); //true cuz r>m - VERIFY( str_0 > L"cost" ); - VERIFY( !(str_0 > L"costa ricans") ); - VERIFY( !(L"costa marbella" > str_0) );//false cuz m str_0) ); - VERIFY( L"costa ricans" > str_0 ); - VERIFY( !(L"costa rica" > str_0) ); - VERIFY( !(str_0 > L"costa rica") ); - - VERIFY( !(str_0 < L"costa marbella") );//false cuz r>m - VERIFY( !(str_0 < L"cost") ); - VERIFY( str_0 < L"costa ricans" ); - VERIFY( L"costa marbella" < str_0 );//true cuz m= L"costa marbella" );//true cuz r>m - VERIFY( str_0 >= L"cost" ); - VERIFY( !(str_0 >= L"costa ricans") ); - VERIFY( !(L"costa marbella" >= str_0) );//false cuz m= str_0) ); - VERIFY( L"costa ricans" >= str_0 ); - VERIFY( L"costa rica" >= str_0 ); - VERIFY( str_0 >= L"costa rica" ); - - VERIFY( !(str_0 <= L"costa marbella") );//false cuz r>m - VERIFY( !(str_0 <= L"cost") ); - VERIFY( str_0 <= L"costa ricans" ); - VERIFY( L"costa marbella" <= str_0 );//true cuz m. - -// C++17 27.7, range access [iterator.range] - -#include - -void -test01() -{ - std::string_view s("Hello, World!"); - std::begin(s); - std::end(s); - std::rbegin(s); - std::rend(s); -} - -void -test02() -{ - constexpr std::string_view s("Hello, World!"); - [[maybe_unused]] constexpr auto b = std::begin(s); - [[maybe_unused]] constexpr auto e = std::end(s); - [[maybe_unused]] constexpr auto cb = std::cbegin(s); - [[maybe_unused]] constexpr auto ce = std::cend(s); - [[maybe_unused]] constexpr auto rb = std::rbegin(s); - [[maybe_unused]] constexpr auto re = std::rend(s); - [[maybe_unused]] constexpr auto crb = std::crbegin(s); - [[maybe_unused]] constexpr auto cre = std::crend(s); -} diff --git a/gdb/unittests/basic_string_view/range_access/wchar_t/1.cc b/gdb/unittests/basic_string_view/range_access/wchar_t/1.cc deleted file mode 100644 index 68b6b1c8c96..00000000000 --- a/gdb/unittests/basic_string_view/range_access/wchar_t/1.cc +++ /dev/null @@ -1,47 +0,0 @@ -// { dg-do compile } -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// C++17 27.7, range access [iterator.range] - -#include - -void -test01() -{ - std::wstring_view ws(L"Hello, World!"); - std::begin(ws); - std::end(ws); - std::rbegin(ws); - std::rend(ws); -} - -void -test02() -{ - constexpr std::wstring_view ws(L"Hello, World!"); - [[maybe_unused]] constexpr auto b = std::begin(ws); - [[maybe_unused]] constexpr auto e = std::end(ws); - [[maybe_unused]] constexpr auto cb = std::cbegin(ws); - [[maybe_unused]] constexpr auto ce = std::cend(ws); - [[maybe_unused]] constexpr auto rb = std::rbegin(ws); - [[maybe_unused]] constexpr auto re = std::rend(ws); - [[maybe_unused]] constexpr auto crb = std::crbegin(ws); - [[maybe_unused]] constexpr auto cre = std::crend(ws); -} diff --git a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/1.cc b/gdb/unittests/basic_string_view/requirements/explicit_instantiation/1.cc deleted file mode 100644 index afea9946bf4..00000000000 --- a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/1.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - - -// This file tests explicit instantiation of basic_string - -#include - -// { dg-do compile } -// { dg-options "-std=gnu++17" } - -template class std::basic_string_view>; diff --git a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char/1.cc b/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char/1.cc deleted file mode 100644 index 7db0e922257..00000000000 --- a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char/1.cc +++ /dev/null @@ -1,23 +0,0 @@ -// { dg-do compile } -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this library; see the file COPYING3. If not see -// . - -#include - -template class std::basic_string_view; diff --git a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char16_t/1.cc b/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char16_t/1.cc deleted file mode 100644 index 5eb588fce32..00000000000 --- a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char16_t/1.cc +++ /dev/null @@ -1,24 +0,0 @@ -// { dg-do compile } -// { dg-options "-std=gnu++17" } -// { dg-require-cstdint "" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this library; see the file COPYING3. If not see -// . - -#include - -template class std::basic_string_view; diff --git a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char32_t/1.cc b/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char32_t/1.cc deleted file mode 100644 index 2c6460277dd..00000000000 --- a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char32_t/1.cc +++ /dev/null @@ -1,24 +0,0 @@ -// { dg-do compile } -// { dg-options "-std=gnu++17" } -// { dg-require-cstdint "" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this library; see the file COPYING3. If not see -// . - -#include - -template class std::basic_string_view; diff --git a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/wchar_t/1.cc b/gdb/unittests/basic_string_view/requirements/explicit_instantiation/wchar_t/1.cc deleted file mode 100644 index 213615f222e..00000000000 --- a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/wchar_t/1.cc +++ /dev/null @@ -1,23 +0,0 @@ -// { dg-do compile } -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this library; see the file COPYING3. If not see -// . - -#include - -template class std::basic_string_view; diff --git a/gdb/unittests/basic_string_view/requirements/typedefs.cc b/gdb/unittests/basic_string_view/requirements/typedefs.cc deleted file mode 100644 index 2bb08abfd25..00000000000 --- a/gdb/unittests/basic_string_view/requirements/typedefs.cc +++ /dev/null @@ -1,47 +0,0 @@ - -// { dg-options "-std=gnu++17" } -// { dg-do compile } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -#include -#include - -namespace __gnu_test -{ - template - struct traits> : public traits_base - { - typedef std::true_type is_container; - typedef std::true_type is_reversible; - }; -} - -#include - -// Check container for required typedefs. - -__gnu_test::basic_types t1b; -__gnu_test::reversible_types t1r; -typedef typename std::string_view::traits_type traits_type1; - -#ifdef _GLIBCXX_USE_WCHAR_T -__gnu_test::basic_types t2b; -__gnu_test::reversible_types t2r; -typedef typename std::wstring_view::traits_type traits_type2; -#endif diff --git a/gdb/unittests/basic_string_view/typedefs.cc b/gdb/unittests/basic_string_view/typedefs.cc deleted file mode 100644 index c4222bf8ebf..00000000000 --- a/gdb/unittests/basic_string_view/typedefs.cc +++ /dev/null @@ -1,36 +0,0 @@ -// { dg-options "-std=gnu++17" } -// { dg-do compile } - -// Copyright (C) 2014-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -#include - -template - using check1_t = std::basic_string_view; - -using check2_t = std::string_view; - -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 -using check3_t = std::u16string_view; -using check4_t = std::u32string_view; -#endif - -#ifdef _GLIBCXX_USE_WCHAR_T -using check5_t = std::wstring_view; -#endif - diff --git a/gdb/unittests/basic_string_view/types/1.cc b/gdb/unittests/basic_string_view/types/1.cc deleted file mode 100644 index d742df23a44..00000000000 --- a/gdb/unittests/basic_string_view/types/1.cc +++ /dev/null @@ -1,43 +0,0 @@ -// -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . -// - -// { dg-options "-std=gnu++17" } -// { dg-do compile } - -#include - -struct T -{ - typedef std::string_view String_view; - typedef String_view::iterator iterator; - typedef String_view::const_iterator const_iterator; - - char t(iterator f) { return *f; } - char t(const_iterator f) const { return *f; } -}; - -void -f() -{ - std::string_view s; - T t; - T::const_iterator i = s.begin(); - - t.t(i); -} diff --git a/gdb/unittests/string_view-selftests.c b/gdb/unittests/string_view-selftests.c deleted file mode 100644 index cf43d29502c..00000000000 --- a/gdb/unittests/string_view-selftests.c +++ /dev/null @@ -1,193 +0,0 @@ -/* Self tests for string_view for GDB, the GNU debugger. - - Copyright (C) 2018-2023 Free Software Foundation, Inc. - - This file is part of GDB. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* No need to test string_view if we're using C++17, since we're going to use - the "real" version. */ -#if __cplusplus < 201703L - -#define GNULIB_NAMESPACE gnulib - -#include "diagnostics.h" - -/* Since this file uses GNULIB_NAMESPACE, some code defined in headers ends up - using system functions rather than gnulib replacements. This is not really - a problem for this test, but it generates some warnings with Clang, silence - them. */ -DIAGNOSTIC_PUSH -DIAGNOSTIC_IGNORE_USER_DEFINED_WARNINGS - -#include "defs.h" -#include "gdbsupport/selftest.h" -#include "gdbsupport/gdb_string_view.h" - -/* Used by the included .cc files below. Included here because the - included test files are wrapped in a namespace. */ -#include -#include -#include -#include - -DIAGNOSTIC_POP - -/* libstdc++'s testsuite uses VERIFY. */ -#define VERIFY SELF_CHECK - -/* Used to disable testing features not supported by - gdb::string_view. */ -#define GDB_STRING_VIEW - -namespace selftests { -namespace string_view { - -/* The actual tests live in separate files, which were originally - copied over from libstdc++'s testsuite. To preserve the structure - and help with comparison with the original tests, the file names - have been preserved, and only minimal modification was done to have - them compile against gdb::string_view instead of std::string_view: - - - std::string_view->gdb::string_view, etc. - - ATTRIBUTE_UNUSED in a few places - - wrap each file in a namespace so they can all be compiled as a - single unit. - - libstdc++'s license and formatting style was preserved. -*/ - -#include "basic_string_view/capacity/1.cc" -#include "basic_string_view/cons/char/1.cc" -#include "basic_string_view/cons/char/2.cc" -#include "basic_string_view/cons/char/3.cc" -#include "basic_string_view/element_access/char/1.cc" -#include "basic_string_view/element_access/char/empty.cc" -#include "basic_string_view/element_access/char/front_back.cc" -#include "basic_string_view/inserters/char/2.cc" -#include "basic_string_view/modifiers/remove_prefix/char/1.cc" -#include "basic_string_view/modifiers/remove_suffix/char/1.cc" -#include "basic_string_view/modifiers/swap/char/1.cc" -#include "basic_string_view/operations/compare/char/1.cc" -#include "basic_string_view/operations/compare/char/13650.cc" -#include "basic_string_view/operations/copy/char/1.cc" -#include "basic_string_view/operations/data/char/1.cc" -#include "basic_string_view/operations/find/char/1.cc" -#include "basic_string_view/operations/find/char/2.cc" -#include "basic_string_view/operations/find/char/3.cc" -#include "basic_string_view/operations/find/char/4.cc" -#include "basic_string_view/operations/rfind/char/1.cc" -#include "basic_string_view/operations/rfind/char/2.cc" -#include "basic_string_view/operations/rfind/char/3.cc" -#include "basic_string_view/operations/substr/char/1.cc" -#include "basic_string_view/operators/char/2.cc" - -static void -run_tests () -{ - capacity_1::main (); - cons_1::main (); - cons_2::main (); - cons_3::main (); - element_access_1::main (); - element_access_empty::main (); - element_access_front_back::main (); - inserters_2::main (); - modifiers_remove_prefix::main (); - modifiers_remove_suffix::main (); - modifiers_swap::test01 (); - operations_compare_1::main (); - operations_compare_13650::main (); - operations_copy_1::main (); - operations_data_1::main (); - operations_find_1::main (); - operations_find_2::main (); - operations_find_3::main (); - operations_find_4::main (); - operations_rfind_1::main (); - operations_rfind_2::main (); - operations_rfind_3::main (); - operations_substr_1::main (); - operators_2::main (); - - constexpr gdb::string_view sv_empty; - SELF_CHECK (sv_empty.empty ()); - - std::string std_string = "fika"; - gdb::string_view sv1 (std_string); - SELF_CHECK (sv1 == "fika"); - - constexpr const char *fika = "fika"; - gdb::string_view sv2 (fika); - SELF_CHECK (sv2 == "fika"); - - constexpr gdb::string_view sv3 (fika, 3); - SELF_CHECK (sv3 == "fik"); - - constexpr gdb::string_view sv4 (sv3); - SELF_CHECK (sv4 == "fik"); - - constexpr gdb::string_view::iterator it_begin = sv4.begin (); - static_assert (*it_begin == 'f', ""); - - constexpr gdb::string_view::iterator it_end = sv4.end (); - static_assert (*it_end == 'a', ""); - - const gdb::string_view::reverse_iterator it_rbegin = sv4.rbegin (); - SELF_CHECK (*it_rbegin == 'k'); - - const gdb::string_view::reverse_iterator it_rend = sv4.rend (); - SELF_CHECK (*(it_rend - 1) == 'f'); - - constexpr gdb::string_view::size_type size = sv4.size (); - static_assert (size == 3, ""); - - constexpr gdb::string_view::size_type length = sv4.length (); - static_assert (length == 3, ""); - - constexpr gdb::string_view::size_type max_size = sv4.max_size (); - static_assert (max_size > 0, ""); - - constexpr bool empty = sv4.empty (); - static_assert (!empty, ""); - - constexpr char c1 = sv4[1]; - static_assert (c1 == 'i', ""); - - constexpr char c2 = sv4.at (2); - static_assert (c2 == 'k', ""); - - constexpr char front = sv4.front (); - static_assert (front == 'f', ""); - - constexpr char back = sv4.back (); - static_assert (back == 'k', ""); - - constexpr const char *data = sv4.data (); - static_assert (data == fika, ""); -} - -} /* namespace string_view */ -} /* namespace selftests */ - -#endif /* __cplusplus < 201703L */ - -void _initialize_string_view_selftests (); -void -_initialize_string_view_selftests () -{ -#if defined(GDB_STRING_VIEW) - selftests::register_test ("string_view", selftests::string_view::run_tests); -#endif -} diff --git a/gdbsupport/gdb_string_view.h b/gdbsupport/gdb_string_view.h deleted file mode 100644 index cf7af623327..00000000000 --- a/gdbsupport/gdb_string_view.h +++ /dev/null @@ -1,566 +0,0 @@ -// Components for manipulating non-owning sequences of characters -*- C++ -*- - - -#ifndef COMMON_GDB_STRING_VIEW_H -#define COMMON_GDB_STRING_VIEW_H - -// Note: This file has been stolen from the gcc repo -// (libstdc++-v3/include/experimental/string_view) and has local modifications. - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// Under Section 7 of GPL version 3, you are granted additional -// permissions described in the GCC Runtime Library Exception, version -// 3.1, as published by the Free Software Foundation. - -// You should have received a copy of the GNU General Public License and -// a copy of the GCC Runtime Library Exception along with this program; -// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -// . - -// -// N3762 basic_string_view library -// - - -#if __cplusplus >= 201703L - -#include - -namespace gdb { - using string_view = std::string_view; -} /* namespace gdb */ - -#else /* __cplusplus < 201703L */ - -#include -#include -#include "gdb_assert.h" - -namespace gdb { - - /** - * @class basic_string_view - * @brief A non-owning reference to a string. - * - * @ingroup strings - * @ingroup sequences - * @ingroup experimental - * - * @tparam _CharT Type of character - * @tparam _Traits Traits for character type, defaults to - * char_traits<_CharT>. - * - * A basic_string_view looks like this: - * - * @code - * _CharT* _M_str - * size_t _M_len - * @endcode - */ - template> - class basic_string_view - { - public: - - // types - using traits_type = _Traits; - using value_type = _CharT; - using pointer = const _CharT*; - using const_pointer = const _CharT*; - using reference = const _CharT&; - using const_reference = const _CharT&; - using const_iterator = const _CharT*; - using iterator = const_iterator; - using const_reverse_iterator = std::reverse_iterator; - using reverse_iterator = const_reverse_iterator; - using size_type = size_t; - using difference_type = ptrdiff_t; - static constexpr size_type npos = size_type(-1); - - // [string.view.cons], construct/copy - - constexpr - basic_string_view() noexcept - : _M_len{0}, _M_str{nullptr} - { } - - constexpr basic_string_view(const basic_string_view&) noexcept = default; - - template - basic_string_view(const std::basic_string<_CharT, _Traits, - _Allocator>& __str) noexcept - : _M_len{__str.length()}, _M_str{__str.data()} - { } - - /*constexpr*/ basic_string_view(const _CharT* __str) - : _M_len{__str == nullptr ? 0 : traits_type::length(__str)}, - _M_str{__str} - { } - - constexpr basic_string_view(const _CharT* __str, size_type __len) - : _M_len{__len}, - _M_str{__str} - { } - - basic_string_view& - operator=(const basic_string_view&) noexcept = default; - - // [string.view.iterators], iterators - - constexpr const_iterator - begin() const noexcept - { return this->_M_str; } - - constexpr const_iterator - end() const noexcept - { return this->_M_str + this->_M_len; } - - constexpr const_iterator - cbegin() const noexcept - { return this->_M_str; } - - constexpr const_iterator - cend() const noexcept - { return this->_M_str + this->_M_len; } - - const_reverse_iterator - rbegin() const noexcept - { return const_reverse_iterator(this->end()); } - - const_reverse_iterator - rend() const noexcept - { return const_reverse_iterator(this->begin()); } - - const_reverse_iterator - crbegin() const noexcept - { return const_reverse_iterator(this->end()); } - - const_reverse_iterator - crend() const noexcept - { return const_reverse_iterator(this->begin()); } - - // [string.view.capacity], capacity - - constexpr size_type - size() const noexcept - { return this->_M_len; } - - constexpr size_type - length() const noexcept - { return _M_len; } - - constexpr size_type - max_size() const noexcept - { - return (npos - sizeof(size_type) - sizeof(void*)) - / sizeof(value_type) / 4; - } - - constexpr bool - empty() const noexcept - { return this->_M_len == 0; } - - // [string.view.access], element access - - constexpr const _CharT& - operator[](size_type __pos) const - { - // TODO: Assert to restore in a way compatible with the constexpr. - // __glibcxx_assert(__pos < this->_M_len); - return *(this->_M_str + __pos); - } - - constexpr const _CharT& - at(size_type __pos) const - { - return __pos < this->_M_len - ? *(this->_M_str + __pos) - : (error (_("basic_string_view::at: __pos " - "(which is %zu) >= this->size() " - "(which is %zu)"), - __pos, this->size()), - *this->_M_str); - } - - constexpr const _CharT& - front() const - { - // TODO: Assert to restore in a way compatible with the constexpr. - // __glibcxx_assert(this->_M_len > 0); - return *this->_M_str; - } - - constexpr const _CharT& - back() const - { - // TODO: Assert to restore in a way compatible with the constexpr. - // __glibcxx_assert(this->_M_len > 0); - return *(this->_M_str + this->_M_len - 1); - } - - constexpr const _CharT* - data() const noexcept - { return this->_M_str; } - - // [string.view.modifiers], modifiers: - - /*constexpr*/ void - remove_prefix(size_type __n) - { - gdb_assert (this->_M_len >= __n); - this->_M_str += __n; - this->_M_len -= __n; - } - - /*constexpr*/ void - remove_suffix(size_type __n) - { this->_M_len -= __n; } - - /*constexpr*/ void - swap(basic_string_view& __sv) noexcept - { - auto __tmp = *this; - *this = __sv; - __sv = __tmp; - } - - - // [string.view.ops], string operations: - - template - explicit operator std::basic_string<_CharT, _Traits, _Allocator>() const - { - return { this->_M_str, this->_M_len }; - } - - size_type - copy(_CharT* __str, size_type __n, size_type __pos = 0) const - { - gdb_assert (__str != nullptr || __n == 0); - if (__pos > this->_M_len) - error (_("basic_string_view::copy: __pos " - "(which is %zu) > this->size() " - "(which is %zu)"), - __pos, this->size()); - size_type __rlen{std::min(__n, size_type{this->_M_len - __pos})}; - for (auto __begin = this->_M_str + __pos, - __end = __begin + __rlen; __begin != __end;) - *__str++ = *__begin++; - return __rlen; - } - - - // [string.view.ops], string operations: - - /*constexpr*/ basic_string_view - substr(size_type __pos, size_type __n=npos) const - { - return __pos <= this->_M_len - ? basic_string_view{this->_M_str + __pos, - std::min(__n, size_type{this->_M_len - __pos})} - : (error (_("basic_string_view::substr: __pos " - "(which is %zu) > this->size() " - "(which is %zu)"), - __pos, this->size()), basic_string_view{}); - } - - /*constexpr*/ int - compare(basic_string_view __str) const noexcept - { - int __ret = traits_type::compare(this->_M_str, __str._M_str, - std::min(this->_M_len, __str._M_len)); - if (__ret == 0) - __ret = _S_compare(this->_M_len, __str._M_len); - return __ret; - } - - /*constexpr*/ int - compare(size_type __pos1, size_type __n1, basic_string_view __str) const - { return this->substr(__pos1, __n1).compare(__str); } - - /*constexpr*/ int - compare(size_type __pos1, size_type __n1, - basic_string_view __str, size_type __pos2, size_type __n2) const - { return this->substr(__pos1, __n1).compare(__str.substr(__pos2, __n2)); } - - /*constexpr*/ int - compare(const _CharT* __str) const noexcept - { return this->compare(basic_string_view{__str}); } - - /*constexpr*/ int - compare(size_type __pos1, size_type __n1, const _CharT* __str) const - { return this->substr(__pos1, __n1).compare(basic_string_view{__str}); } - - /*constexpr*/ int - compare(size_type __pos1, size_type __n1, - const _CharT* __str, size_type __n2) const - { - return this->substr(__pos1, __n1) - .compare(basic_string_view(__str, __n2)); - } - - /*constexpr*/ size_type - find(basic_string_view __str, size_type __pos = 0) const noexcept - { return this->find(__str._M_str, __pos, __str._M_len); } - - /*constexpr*/ size_type - find(_CharT __c, size_type __pos=0) const noexcept; - - /*constexpr*/ size_type - find(const _CharT* __str, size_type __pos, size_type __n) const noexcept; - - /*constexpr*/ size_type - find(const _CharT* __str, size_type __pos=0) const noexcept - { return this->find(__str, __pos, traits_type::length(__str)); } - - /*constexpr*/ size_type - rfind(basic_string_view __str, size_type __pos = npos) const noexcept - { return this->rfind(__str._M_str, __pos, __str._M_len); } - - /*constexpr*/ size_type - rfind(_CharT __c, size_type __pos = npos) const noexcept; - - /*constexpr*/ size_type - rfind(const _CharT* __str, size_type __pos, size_type __n) const noexcept; - - /*constexpr*/ size_type - rfind(const _CharT* __str, size_type __pos = npos) const noexcept - { return this->rfind(__str, __pos, traits_type::length(__str)); } - - /*constexpr*/ size_type - find_first_of(basic_string_view __str, size_type __pos = 0) const noexcept - { return this->find_first_of(__str._M_str, __pos, __str._M_len); } - - /*constexpr*/ size_type - find_first_of(_CharT __c, size_type __pos = 0) const noexcept - { return this->find(__c, __pos); } - - /*constexpr*/ size_type - find_first_of(const _CharT* __str, size_type __pos, size_type __n) const; - - /*constexpr*/ size_type - find_first_of(const _CharT* __str, size_type __pos = 0) const noexcept - { return this->find_first_of(__str, __pos, traits_type::length(__str)); } - - /*constexpr*/ size_type - find_last_of(basic_string_view __str, - size_type __pos = npos) const noexcept - { return this->find_last_of(__str._M_str, __pos, __str._M_len); } - - size_type - find_last_of(_CharT __c, size_type __pos=npos) const noexcept - { return this->rfind(__c, __pos); } - - /*constexpr*/ size_type - find_last_of(const _CharT* __str, size_type __pos, size_type __n) const; - - /*constexpr*/ size_type - find_last_of(const _CharT* __str, size_type __pos = npos) const noexcept - { return this->find_last_of(__str, __pos, traits_type::length(__str)); } - - /*constexpr*/ size_type - find_first_not_of(basic_string_view __str, - size_type __pos = 0) const noexcept - { return this->find_first_not_of(__str._M_str, __pos, __str._M_len); } - - /*constexpr*/ size_type - find_first_not_of(_CharT __c, size_type __pos = 0) const noexcept; - - /*constexpr*/ size_type - find_first_not_of(const _CharT* __str, - size_type __pos, size_type __n) const; - - /*constexpr*/ size_type - find_first_not_of(const _CharT* __str, size_type __pos = 0) const noexcept - { - return this->find_first_not_of(__str, __pos, - traits_type::length(__str)); - } - - /*constexpr*/ size_type - find_last_not_of(basic_string_view __str, - size_type __pos = npos) const noexcept - { return this->find_last_not_of(__str._M_str, __pos, __str._M_len); } - - /*constexpr*/ size_type - find_last_not_of(_CharT __c, size_type __pos = npos) const noexcept; - - /*constexpr*/ size_type - find_last_not_of(const _CharT* __str, - size_type __pos, size_type __n) const; - - /*constexpr*/ size_type - find_last_not_of(const _CharT* __str, - size_type __pos = npos) const noexcept - { - return this->find_last_not_of(__str, __pos, - traits_type::length(__str)); - } - - private: - - static constexpr int - _S_compare(size_type __n1, size_type __n2) noexcept - { - return difference_type(__n1 - __n2) > std::numeric_limits::max() - ? std::numeric_limits::max() - : difference_type(__n1 - __n2) < std::numeric_limits::min() - ? std::numeric_limits::min() - : static_cast(difference_type(__n1 - __n2)); - } - - size_t _M_len; - const _CharT* _M_str; - }; - - // [string.view.comparison], non-member basic_string_view comparison functions - - namespace __detail - { - // Identity transform to create a non-deduced context, so that only one - // argument participates in template argument deduction and the other - // argument gets implicitly converted to the deduced type. See n3766.html. - template - using __idt = typename std::common_type<_Tp>::type; - } - - template - /*constexpr*/ bool - operator==(basic_string_view<_CharT, _Traits> __x, - basic_string_view<_CharT, _Traits> __y) noexcept - { return __x.size() == __y.size() && __x.compare(__y) == 0; } - - template - /*constexpr*/ bool - operator==(basic_string_view<_CharT, _Traits> __x, - __detail::__idt> __y) noexcept - { return __x.size() == __y.size() && __x.compare(__y) == 0; } - - template - /*constexpr*/ bool - operator==(__detail::__idt> __x, - basic_string_view<_CharT, _Traits> __y) noexcept - { return __x.size() == __y.size() && __x.compare(__y) == 0; } - - template - /*constexpr*/ bool - operator!=(basic_string_view<_CharT, _Traits> __x, - basic_string_view<_CharT, _Traits> __y) noexcept - { return !(__x == __y); } - - template - /*constexpr*/ bool - operator!=(basic_string_view<_CharT, _Traits> __x, - __detail::__idt> __y) noexcept - { return !(__x == __y); } - - template - /*constexpr*/ bool - operator!=(__detail::__idt> __x, - basic_string_view<_CharT, _Traits> __y) noexcept - { return !(__x == __y); } - - template - /*constexpr*/ bool - operator< (basic_string_view<_CharT, _Traits> __x, - basic_string_view<_CharT, _Traits> __y) noexcept - { return __x.compare(__y) < 0; } - - template - /*constexpr*/ bool - operator< (basic_string_view<_CharT, _Traits> __x, - __detail::__idt> __y) noexcept - { return __x.compare(__y) < 0; } - - template - /*constexpr*/ bool - operator< (__detail::__idt> __x, - basic_string_view<_CharT, _Traits> __y) noexcept - { return __x.compare(__y) < 0; } - - template - /*constexpr*/ bool - operator> (basic_string_view<_CharT, _Traits> __x, - basic_string_view<_CharT, _Traits> __y) noexcept - { return __x.compare(__y) > 0; } - - template - /*constexpr*/ bool - operator> (basic_string_view<_CharT, _Traits> __x, - __detail::__idt> __y) noexcept - { return __x.compare(__y) > 0; } - - template - /*constexpr*/ bool - operator> (__detail::__idt> __x, - basic_string_view<_CharT, _Traits> __y) noexcept - { return __x.compare(__y) > 0; } - - template - /*constexpr*/ bool - operator<=(basic_string_view<_CharT, _Traits> __x, - basic_string_view<_CharT, _Traits> __y) noexcept - { return __x.compare(__y) <= 0; } - - template - /*constexpr*/ bool - operator<=(basic_string_view<_CharT, _Traits> __x, - __detail::__idt> __y) noexcept - { return __x.compare(__y) <= 0; } - - template - /*constexpr*/ bool - operator<=(__detail::__idt> __x, - basic_string_view<_CharT, _Traits> __y) noexcept - { return __x.compare(__y) <= 0; } - - template - /*constexpr*/ bool - operator>=(basic_string_view<_CharT, _Traits> __x, - basic_string_view<_CharT, _Traits> __y) noexcept - { return __x.compare(__y) >= 0; } - - template - /*constexpr*/ bool - operator>=(basic_string_view<_CharT, _Traits> __x, - __detail::__idt> __y) noexcept - { return __x.compare(__y) >= 0; } - - template - /*constexpr*/ bool - operator>=(__detail::__idt> __x, - basic_string_view<_CharT, _Traits> __y) noexcept - { return __x.compare(__y) >= 0; } - - // basic_string_view typedef names - - using string_view = basic_string_view; -} /* namespace gdb */ - -#include "gdb_string_view.tcc" - -#endif // __cplusplus < 201703L - -namespace gdb { - -static inline std::string -to_string(const std::string_view &view) -{ - return { view.data (), view.size () }; -} - -} - -#endif /* COMMON_GDB_STRING_VIEW_H */ diff --git a/gdbsupport/gdb_string_view.tcc b/gdbsupport/gdb_string_view.tcc deleted file mode 100644 index 0798105673b..00000000000 --- a/gdbsupport/gdb_string_view.tcc +++ /dev/null @@ -1,219 +0,0 @@ -// Components for manipulating non-owning sequences of characters -*- C++ -*- - -// Note: This file has been stolen from the gcc repo -// (libstdc++-v3/include/experimental/bits/string_view.tcc) and has local -// modifications. - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// Under Section 7 of GPL version 3, you are granted additional -// permissions described in the GCC Runtime Library Exception, version -// 3.1, as published by the Free Software Foundation. - -// You should have received a copy of the GNU General Public License and -// a copy of the GCC Runtime Library Exception along with this program; -// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -// . - -/** @file experimental/bits/string_view.tcc - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{experimental/string_view} - */ - -// -// N3762 basic_string_view library -// - -#ifndef GDB_STRING_VIEW_TCC -#define GDB_STRING_VIEW_TCC 1 - -namespace gdb -{ - template - /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type - basic_string_view<_CharT, _Traits>:: - find(const _CharT* __str, size_type __pos, size_type __n) const noexcept - { - gdb_assert (__str != nullptr || __n == 0); - - if (__n == 0) - return __pos <= this->_M_len ? __pos : npos; - - if (__n <= this->_M_len) - { - for (; __pos <= this->_M_len - __n; ++__pos) - if (traits_type::eq(this->_M_str[__pos], __str[0]) - && traits_type::compare(this->_M_str + __pos + 1, - __str + 1, __n - 1) == 0) - return __pos; - } - return npos; - } - - template - /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type - basic_string_view<_CharT, _Traits>:: - find(_CharT __c, size_type __pos) const noexcept - { - size_type __ret = npos; - if (__pos < this->_M_len) - { - const size_type __n = this->_M_len - __pos; - const _CharT* __p = traits_type::find(this->_M_str + __pos, __n, __c); - if (__p) - __ret = __p - this->_M_str; - } - return __ret; - } - - template - /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type - basic_string_view<_CharT, _Traits>:: - rfind(const _CharT* __str, size_type __pos, size_type __n) const noexcept - { - gdb_assert (__str != nullptr || __n == 0); - - if (__n <= this->_M_len) - { - __pos = std::min(size_type(this->_M_len - __n), __pos); - do - { - if (traits_type::compare(this->_M_str + __pos, __str, __n) == 0) - return __pos; - } - while (__pos-- > 0); - } - return npos; - } - - template - /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type - basic_string_view<_CharT, _Traits>:: - rfind(_CharT __c, size_type __pos) const noexcept - { - size_type __size = this->_M_len; - if (__size > 0) - { - if (--__size > __pos) - __size = __pos; - for (++__size; __size-- > 0; ) - if (traits_type::eq(this->_M_str[__size], __c)) - return __size; - } - return npos; - } - - template - /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type - basic_string_view<_CharT, _Traits>:: - find_first_of(const _CharT* __str, size_type __pos, size_type __n) const - { - gdb_assert (__str != nullptr || __n == 0); - for (; __n && __pos < this->_M_len; ++__pos) - { - const _CharT* __p = traits_type::find(__str, __n, - this->_M_str[__pos]); - if (__p) - return __pos; - } - return npos; - } - - template - /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type - basic_string_view<_CharT, _Traits>:: - find_last_of(const _CharT* __str, size_type __pos, size_type __n) const - { - gdb_assert (__str != nullptr || __n == 0); - size_type __size = this->size(); - if (__size && __n) - { - if (--__size > __pos) - __size = __pos; - do - { - if (traits_type::find(__str, __n, this->_M_str[__size])) - return __size; - } - while (__size-- != 0); - } - return npos; - } - - template - /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type - basic_string_view<_CharT, _Traits>:: - find_first_not_of(const _CharT* __str, size_type __pos, size_type __n) const - { - gdb_assert (__str != nullptr || __n == 0); - for (; __pos < this->_M_len; ++__pos) - if (!traits_type::find(__str, __n, this->_M_str[__pos])) - return __pos; - return npos; - } - - template - /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type - basic_string_view<_CharT, _Traits>:: - find_first_not_of(_CharT __c, size_type __pos) const noexcept - { - for (; __pos < this->_M_len; ++__pos) - if (!traits_type::eq(this->_M_str[__pos], __c)) - return __pos; - return npos; - } - - template - /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type - basic_string_view<_CharT, _Traits>:: - find_last_not_of(const _CharT* __str, size_type __pos, size_type __n) const - { - gdb_assert (__str != nullptr || __n == 0); - size_type __size = this->_M_len; - if (__size) - { - if (--__size > __pos) - __size = __pos; - do - { - if (!traits_type::find(__str, __n, this->_M_str[__size])) - return __size; - } - while (__size--); - } - return npos; - } - - template - /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type - basic_string_view<_CharT, _Traits>:: - find_last_not_of(_CharT __c, size_type __pos) const noexcept - { - size_type __size = this->_M_len; - if (__size) - { - if (--__size > __pos) - __size = __pos; - do - { - if (!traits_type::eq(this->_M_str[__size], __c)) - return __size; - } - while (__size--); - } - return npos; - } -} // namespace gdb - -#endif // GDB_STRING_VIEW_TCC From patchwork Tue Nov 21 12:04:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lancelot SIX X-Patchwork-Id: 80465 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 125F638582A5 for ; Tue, 21 Nov 2023 12:07:18 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by sourceware.org (Postfix) with ESMTPS id 7F366385829E for ; Tue, 21 Nov 2023 12:05:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7F366385829E Authentication-Results: sourceware.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=amd.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7F366385829E Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.236.40 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1700568361; cv=pass; b=rOYkSEOoIG2Uw8Vbxa07W0IZ/M94KyJOHZ0Eip1Bu82Rsptzloo/dfqKa22vFX9hX5oLxL9QdliaSrETn1liZOHFxIEtoz5iEhpm5eRtSztm0Ydjd7xHsp8AZe5IjY2eCG2fd5/QaCFZhcNe6mVOLTPQxFo5TLT3w33S7kHrKiY= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1700568361; c=relaxed/simple; bh=37EO+zlc3jA5I15IDu0xMceQ5NVCqvHOqOVVH7M0i/8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=GDw087jn5vYcsvr1oxRgl0YUTbTsueSVJ9/9pKS/qOTHNbbaYUO2HbwdeKeU3sQ0k4HMLf/5k9i8DX7anxYS0hOp+ysbqC7/jHre1kwGkh2svm/QOV+ndE4axDy490ux6dhA+dvTOt23xkMNYqq5jhOIDDeY69cKJh+s/fbsPPA= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WaA/nNYDQDYu5RAvRxE7Q7BSKyFUzSX476yPLy5vYu2EMwf5mGWSbXuPOrMRVZFIyzbXgS18TlaJWjkNfqjyCmKyd0bv1mMJN3g+Wtyui0DTXYDmef4/JebSECH6mmN2BFAhKNX/mMyFmADrEjFymQzXkmIymd16bPN+Yb5Pbi1Vc4Pbvb0orYH5z2E6NtesWEleA1Jq3h9JWrOKyzJyH/gqDGTArVqxBkUbAoJurA2iYy3hkfGN6svejpP1eMf0PvnG9gvVWkJLZqg4r+cx6EFDT7HVz2h6Xtd1rjhd2YWeOHFxwBpHwq38iP2/FnrljZ+NXJFyV6xZQwVW8Ww8ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RHNJ4lKVt8jP4lLqkUBPVGTE7AFIYnrUi2fPh+DonS8=; b=duJIe0y+QjHNs5MDR3ONanOu0ZBWn6Ym0cCjqngOMEmrKF7pld/gvrGNB1F7i7FQIk3O0Fzl7eeJuSs4iQXsls3HRYTieCfA2wwhUmFSExsG6Xt8/PgS3P16iWBsK+mu13I7HxOeEymZqohZaInq9fWgWeWOkdW/ax/KNe65gPha0PYKEa0kXe9nwlZJ+n8+BzfJQxEVmVNV5xgB4tsK4ZDF97fzx6eKUfGfodhisvWYz/Bu2TixGinO7j1IsLmg8rMTBtBt3LyIDpztzX1tHKum/sk++r8kH45Rh/LuOPAVu/wB3+HOxAVN9hzWwFc2Z7IKLTAHyzPlpQmnTHHrhw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=sourceware.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RHNJ4lKVt8jP4lLqkUBPVGTE7AFIYnrUi2fPh+DonS8=; b=iKzGA237bJ18MQjce4QwZHDN8U94HEq2rKvZ1c0DX+KDbT5SW7iuBnHxrQXv/Nm814U6G0i+SXMuwPIJ+n6vnPgFgGbtPL8xTWDnbryeM+qGP15Af2KNeS5pNdSyGldQgS0qJUQ6heczcu+aNEciEDTPb5vhtWEbVl7VvwWdRso= Received: from BL1PR13CA0265.namprd13.prod.outlook.com (2603:10b6:208:2ba::30) by MW3PR12MB4539.namprd12.prod.outlook.com (2603:10b6:303:59::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.18; Tue, 21 Nov 2023 12:05:55 +0000 Received: from MN1PEPF0000F0E2.namprd04.prod.outlook.com (2603:10b6:208:2ba:cafe::c8) by BL1PR13CA0265.outlook.office365.com (2603:10b6:208:2ba::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.17 via Frontend Transport; Tue, 21 Nov 2023 12:05:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MN1PEPF0000F0E2.mail.protection.outlook.com (10.167.242.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7025.12 via Frontend Transport; Tue, 21 Nov 2023 12:05:54 +0000 Received: from hpe6u-23.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Tue, 21 Nov 2023 06:05:52 -0600 From: Lancelot Six To: CC: , , Lancelot Six Subject: [COMMITTED PATCH v2 7/9] gdbsupport: Replace gdb::invoke_result with std::invoke_result Date: Tue, 21 Nov 2023 12:04:58 +0000 Message-ID: <20231121120500.1394523-8-lancelot.six@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028204821.fp5hh7bahrmrnpjl@hpe6u-23> References: <20231028204821.fp5hh7bahrmrnpjl@hpe6u-23> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000F0E2:EE_|MW3PR12MB4539:EE_ X-MS-Office365-Filtering-Correlation-Id: b819083a-3bef-4740-3fed-08dbea8a36a1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: agFdbnf5XPHfF2V8RV+8cNFT/xrELtBpLbjRpIFn8rvLUWd7QUN1y/h5LGDA9led0ZPdygmI8wT7fZIhakYbNV+TFgDnPCu401h6zh6Ri91YHyYuUjg+ZZoH9i37L7JPOTjBTOLcPXztHFoMtaCGbHS3mr7VJn5Ub8BphfeRUYRkJ6S4nQSrLYIW+sMQ9QBMHC4zjDs9SY2z6NFzIrL+DLnwzUCWQppAmuoXI5j+5iFnanWeKZb9VPbCNz8HKs76LW4qxnLdOhoXc4Tf5FFOELIlFMj5c4vdPrb+SlyzlOppIe7eYwdmhqvDuqQmv7ixoRht1911z0RC2SvmyXTS87gjv/q03vq20GlBxR5SSMKOgM4P1mqR2S3y1en2Xrad9DipPopWQi7LJP/lyyVAqAWSmsPUTTU7zrpCMP3Izsb3AXBqM/9vGax7tysWbi3Xtca4sWyK5mQR+7pSWE7QyzldFvGY4jby7HadVgQhV+JHs2ZqHg2dOvEa/MJcti705OUkX29mLqCd57OEUQGUOPe7QclladSHHYqFdITxL3SPRX3Y1x+31tfm0f40PwfYDCMRdINbjOBHV7xIwaSk82f2q8q6WKr23Oe/IKmgnQymyzIvmBaShllx/p2yj6Hq65ioPdju55KOZ8A/G2YYWfGZjvlzwKuyvZTh6LpdKpUkSs63yIhF+pCL3fbUCXwNrjFiJLw+lVCGH0bC8rNQVRMy8FghCu/7T+l/93o/9JMNxda+DUeEsuaaCeexJJrlIOcNyhzWL9NdSI5CKSxJ6hjx/2DV/9crU72Y5i341SM= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(346002)(136003)(376002)(396003)(39860400002)(230922051799003)(82310400011)(1800799012)(64100799003)(186009)(451199024)(46966006)(40470700004)(36840700001)(44832011)(40480700001)(5660300002)(8676002)(4326008)(41300700001)(8936002)(2906002)(70586007)(70206006)(316002)(6916009)(54906003)(40460700003)(47076005)(86362001)(478600001)(26005)(16526019)(1076003)(36756003)(7696005)(2616005)(336012)(426003)(356005)(81166007)(83380400001)(36860700001)(82740400003)(2004002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 12:05:54.5512 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b819083a-3bef-4740-3fed-08dbea8a36a1 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MN1PEPF0000F0E2.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4539 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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: 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+patchwork=sourceware.org@sourceware.org Given that GDB now requires C++17, we can replace gdb::invoke_result with std::invoke_result which is provided by . This patch also removes gdbsupport/invoke-result.h as it is not used anymore. Change-Id: I7e567356d38d6b3d85d8797d61cfc83f6f933f22 Approved-By: Tom Tromey Approved-By: Pedro Alves --- gdbsupport/filtered-iterator.h | 4 ++-- gdbsupport/function-view.h | 4 ++-- gdbsupport/invoke-result.h | 37 ---------------------------------- gdbsupport/parallel-for.h | 9 ++++----- gdbsupport/safe-iterator.h | 4 ++-- 5 files changed, 10 insertions(+), 48 deletions(-) delete mode 100644 gdbsupport/invoke-result.h diff --git a/gdbsupport/filtered-iterator.h b/gdbsupport/filtered-iterator.h index 9e9548ef824..aa3366942d1 100644 --- a/gdbsupport/filtered-iterator.h +++ b/gdbsupport/filtered-iterator.h @@ -19,7 +19,7 @@ #ifndef COMMON_FILTERED_ITERATOR_H #define COMMON_FILTERED_ITERATOR_H -#include "gdbsupport/invoke-result.h" +#include /* A filtered iterator. This wraps BaseIterator and automatically skips elements that FilterFunc filters out. Requires that @@ -56,7 +56,7 @@ class filtered_iterator : filtered_iterator (static_cast (other)) {} - typename gdb::invoke_result::type operator* () const { return *m_it; } diff --git a/gdbsupport/function-view.h b/gdbsupport/function-view.h index cd62d40fd5e..ed113c74cfd 100644 --- a/gdbsupport/function-view.h +++ b/gdbsupport/function-view.h @@ -192,7 +192,7 @@ You can find unit tests covering the whole API in unittests/function-view-selftests.c. */ -#include "invoke-result.h" +#include namespace gdb { namespace fv_detail { @@ -230,7 +230,7 @@ class function_view /* True if Func can be called with Args, and either the result is Res, convertible to Res or Res is void. */ template::type> + typename Res2 = typename std::invoke_result::type> struct IsCompatibleCallable : CompatibleReturnType {}; diff --git a/gdbsupport/invoke-result.h b/gdbsupport/invoke-result.h deleted file mode 100644 index c9bb55e5b08..00000000000 --- a/gdbsupport/invoke-result.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Compatibility wrapper around std::result_of and std::invoke_result. - - Copyright (C) 2022-2023 Free Software Foundation, Inc. - - This file is part of GDB. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifndef GDBSUPPORT_INVOKE_RESULT_H -#define GDBSUPPORT_INVOKE_RESULT_H - -#include - -namespace gdb -{ -#if __cplusplus >= 201703L -template -using invoke_result = std::invoke_result; -#else -template -using invoke_result = std::result_of; -#endif - -} /* namespace gdb */ - -#endif /* GDBSUPPORT_INVOKE_RESULT_H */ diff --git a/gdbsupport/parallel-for.h b/gdbsupport/parallel-for.h index b57f7ea97e1..ee7bfd948e2 100644 --- a/gdbsupport/parallel-for.h +++ b/gdbsupport/parallel-for.h @@ -22,7 +22,6 @@ #include #include -#include "gdbsupport/invoke-result.h" #include "gdbsupport/thread-pool.h" #include "gdbsupport/function-view.h" @@ -145,14 +144,14 @@ struct par_for_accumulator template typename gdb::detail::par_for_accumulator< - typename gdb::invoke_result::type + typename std::invoke_result::type >::result_type parallel_for_each (unsigned n, RandomIt first, RandomIt last, RangeFunction callback, gdb::function_view task_size = nullptr) { using result_type - = typename gdb::invoke_result::type; + = typename std::invoke_result::type; /* If enabled, print debug info about how the work is distributed across the threads. */ @@ -305,13 +304,13 @@ parallel_for_each (unsigned n, RandomIt first, RandomIt last, template typename gdb::detail::par_for_accumulator< - typename gdb::invoke_result::type + typename std::invoke_result::type >::result_type sequential_for_each (unsigned n, RandomIt first, RandomIt last, RangeFunction callback, gdb::function_view task_size = nullptr) { - using result_type = typename gdb::invoke_result::type; + using result_type = typename std::invoke_result::type; gdb::detail::par_for_accumulator results (0); diff --git a/gdbsupport/safe-iterator.h b/gdbsupport/safe-iterator.h index ccd772ca2a5..b4891328f1a 100644 --- a/gdbsupport/safe-iterator.h +++ b/gdbsupport/safe-iterator.h @@ -19,7 +19,7 @@ #ifndef COMMON_SAFE_ITERATOR_H #define COMMON_SAFE_ITERATOR_H -#include "gdbsupport/invoke-result.h" +#include /* A forward iterator that wraps Iterator, such that when iterating with iterator IT, it is possible to delete *IT without invalidating @@ -77,7 +77,7 @@ class basic_safe_iterator basic_safe_iterator () {} - typename gdb::invoke_result::type + typename std::invoke_result::type operator* () const { return *m_it; } From patchwork Tue Nov 21 12:04:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lancelot SIX X-Patchwork-Id: 80461 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 886F438582A0 for ; Tue, 21 Nov 2023 12:06:25 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2087.outbound.protection.outlook.com [40.107.96.87]) by sourceware.org (Postfix) with ESMTPS id D34863858410 for ; Tue, 21 Nov 2023 12:05:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D34863858410 Authentication-Results: sourceware.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=amd.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D34863858410 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.96.87 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1700568359; cv=pass; b=aaSGtV5DUK7Ns33wusjwRM4OPsJZmWKcD5jOVOP7cv9k077w36cdi8iMVR5mJ9SfSW3S6Wcc633xRYAf1v2cPZTKlMFAwD5tRdAv6Zr4tYZoDGesysRgbHzI+R+HojUfvOWL54KMkclm3UIsOGWc2SlyJiHfiutTSV4JOR1epRg= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1700568359; c=relaxed/simple; bh=HAH9Ry4oL/Bh/0ON7BPbs+09v5XAxn4eWPAF7VJ/zMU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=grtgk7DC5Av4so32mvugCN/FKLCvIdeyyTavCR7BJxtMukWBOlDyQ+IWvPjCzjGo9k7pDDLoEsoDJ/Iltxksbf6BGvZ4k2b7GBVIZcJqpbkaFpyq9WhZW26hs3cQ4MBZyRPVc1msYSJvDnfS7t2Lm036r36K3xj1jVPawugMmqM= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=flrnb5Cqzu6F81ceih3Y6GuK/hFWeCi+3oEwH2ydUeYR1S89+AGtD4Egml/sHWRZzYpGK/ENT059WWlLcC6qzlwAmWnRFBuO3NXvaJs7I1/q6Pgb4a+6ZMxHmISR5nyJnsqdD4lAV5fNUEOMWQY/6BfdvM8b7RfF77jjgeZng6ng6v/ABSwzKVxq6Qod2Xe0BIoXNPdmrNgctchs96Yp9Qfxrw0V/NCNePW5btqwjy+kK6gX9qyZ9AXLk9fvT1FTPZbCZgPity4UAbpS3awCdXySGrqpSxsByDh+Cwxs616EqRgfvV8sMnB5f7TMqhk28tfIAMIRiwvqUqtOuYh+4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XKKRNt7JMiTTn/7fDV7Jei/pFm7kIt/kp/6lpHjZrCE=; b=KdM/8OJCmgWH7ckvbTWgDyKi8CUL6gXDvIT+Mk7U1LJBuCccNMQLWDNKje99/WYYOm/gsdz3YcTn84gk5eVjPSBxFmGQrSvwEZ8SOQ3fgKhXqZ5bGYwWHEwZs3OGFmOQ+aTEeiZvTYLIOU0LlqDBnmqRwuUEeteJ1DCGTXb0wpp//ENC1U6l1NtR+CCMRgeioo/4xCsc0mQcl6zs4xjR74RdN6vMLAV7qErcitgdTXGtBFPq0DI9KF6Ay9Cd7MeNJ2DM4pnOORcUvhOLRkA3LahdsbqnL5WOhYKkkP+NEbCmrYdv2wLE+t8P5TWltHjTaFWl4/FbCH5gHYGdhdSNEg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=sourceware.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XKKRNt7JMiTTn/7fDV7Jei/pFm7kIt/kp/6lpHjZrCE=; b=eAiPHL0pmE6WPvJWcBqWCsxqo+Poq8d0omurtVEoPSOnGoocRskvbDIdxJ/OTDosRirQh/JABkd8eBctavbyAPw2MeQgD1wzzYfesoMsZE+NAZFeII4MJB5nlSWZpluc49BK0cVamBFoZTGsCflyEUlgh3C2M9N0cTWptQXRxOE= Received: from MN2PR12CA0036.namprd12.prod.outlook.com (2603:10b6:208:a8::49) by MN0PR12MB5835.namprd12.prod.outlook.com (2603:10b6:208:37a::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.18; Tue, 21 Nov 2023 12:05:54 +0000 Received: from MN1PEPF0000F0E4.namprd04.prod.outlook.com (2603:10b6:208:a8:cafe::d9) by MN2PR12CA0036.outlook.office365.com (2603:10b6:208:a8::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.28 via Frontend Transport; Tue, 21 Nov 2023 12:05:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MN1PEPF0000F0E4.mail.protection.outlook.com (10.167.242.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7025.12 via Frontend Transport; Tue, 21 Nov 2023 12:05:54 +0000 Received: from hpe6u-23.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Tue, 21 Nov 2023 06:05:52 -0600 From: Lancelot Six To: CC: , , Lancelot Six Subject: [COMMITTED PATCH v2 8/9] gdb/disasm.h: Mark callbacks noexcept unconditionally Date: Tue, 21 Nov 2023 12:04:59 +0000 Message-ID: <20231121120500.1394523-9-lancelot.six@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028204821.fp5hh7bahrmrnpjl@hpe6u-23> References: <20231028204821.fp5hh7bahrmrnpjl@hpe6u-23> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000F0E4:EE_|MN0PR12MB5835:EE_ X-MS-Office365-Filtering-Correlation-Id: 62e89fa1-6406-4d59-c47e-08dbea8a36a1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mXZF+XTKTPMy0QPFBUFVVy088iAArhaURL8WvA5kg9PogvPqJP4cKyekKY/JldGm4MSolx2qxO5kN3jONRWEPOGcCyz4Cj33pVDeCv3MRUpuYOLR/cQiZR0r2O5bXfr64dCG7KH2zQgQMSnUK7ccWMx2GR6c6ob/MSEhG9n2VsUjALXmRAmsQypfXRK/I2qHuZiT4VrdjftAYCdyJfmw8pt5hz5Ob+jezpO2sQvGORwR2C+k/n5X/W24t1N7gZHcNJpG//bPQTGXDWY5AkYTHxVQsnHkbAQSizEUZH5JtG/P0XuNc16tsHrtvIrV1DmZaSFidgi2vBVK0ox6Dxn0aYJPAOoCMJuCGGm9gs1ZnRCA3qJNiBu8yHC3ldYalc3cRiXknlSJi2SwScOhN/19R0h74qrPW/Lp6naZ3eZ9+JDToidNKb/5SErXy4ucr4fZ4JZxVuDIr8ZVtLQsrDJxwcRvP+PlzXT7ENyw+5Et4byyeK9ocEjTmby5Mo0bfaX0apndrassyS9OuFlhv915pk9NvgCiakxTbIgvt2BuYXCsxKaTfjeynP10rjLOmRZui6R0qEI7x1vE2T9qW+O8V1KCWC3WSYK8WJgi5xN/5i8swTQVwTSUFc4lcGBb6u57gh1dcMIZvDUvKzY5LQcP/Yv+fyW5T7lq9vLP1OJJ82jPlsyqT1vTSGNKtD+IkROyaNyp8lPe3FAN6Bx34i02b+PlVH4DLup5FlQRVYS9eFkvcxMQpjoC3Ucawj1XdMBjrQonC/bwERAu1mMqP6TBD229bZcxxc3qH94z5yRCMzqmiG9cxRQc3Vhe9KcVgCVI X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(396003)(39860400002)(136003)(346002)(376002)(230173577357003)(230273577357003)(230922051799003)(1800799012)(186009)(82310400011)(451199024)(64100799003)(36840700001)(40470700004)(46966006)(83380400001)(36860700001)(40480700001)(40460700003)(356005)(81166007)(70586007)(54906003)(70206006)(5660300002)(86362001)(8936002)(316002)(4326008)(8676002)(6916009)(44832011)(2906002)(41300700001)(7696005)(478600001)(47076005)(426003)(82740400003)(336012)(36756003)(2616005)(1076003)(26005)(16526019)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 12:05:54.5546 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 62e89fa1-6406-4d59-c47e-08dbea8a36a1 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MN1PEPF0000F0E4.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5835 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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: 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+patchwork=sourceware.org@sourceware.org Given that C++17 is now a requirement for GDB, update gdb/disasm.h to define callback function types noexcept unconditionally. The pre-C++17 configuration is not supported anymore. Change-Id: I0a38e22b7912c70a11425363a991f0b01614343e Approved-By: Tom Tromey Approved-By: Pedro Alves --- gdb/disasm.h | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/gdb/disasm.h b/gdb/disasm.h index 5596bd62a10..90fa1dfc02b 100644 --- a/gdb/disasm.h +++ b/gdb/disasm.h @@ -26,12 +26,6 @@ struct gdbarch; struct ui_out; struct ui_file; -#if __cplusplus >= 201703L -#define LIBOPCODE_CALLBACK_NOEXCEPT noexcept -#else -#define LIBOPCODE_CALLBACK_NOEXCEPT -#endif - /* A wrapper around a disassemble_info and a gdbarch. This is the core set of data that all disassembler sub-classes will need. This class doesn't actually implement the disassembling process, that is something @@ -58,27 +52,18 @@ struct gdb_disassemble_info protected: /* Types for the function callbacks within m_di. The actual function - signatures here are taken from include/dis-asm.h. The noexcept macro - expands to 'noexcept' for C++17 and later, otherwise, it expands to - nothing. This is because including noexcept was ignored for function - types before C++17, but both GCC and Clang warn that the noexcept - will become relevant when you switch to C++17, and this warning - causes the build to fail. */ + signatures here are taken from include/dis-asm.h. */ using read_memory_ftype = int (*) (bfd_vma, bfd_byte *, unsigned int, struct disassemble_info *) - LIBOPCODE_CALLBACK_NOEXCEPT; + noexcept; using memory_error_ftype - = void (*) (int, bfd_vma, struct disassemble_info *) - LIBOPCODE_CALLBACK_NOEXCEPT; + = void (*) (int, bfd_vma, struct disassemble_info *) noexcept; using print_address_ftype - = void (*) (bfd_vma, struct disassemble_info *) - LIBOPCODE_CALLBACK_NOEXCEPT; + = void (*) (bfd_vma, struct disassemble_info *) noexcept; using fprintf_ftype - = int (*) (void *, const char *, ...) - LIBOPCODE_CALLBACK_NOEXCEPT; + = int (*) (void *, const char *, ...) noexcept; using fprintf_styled_ftype - = int (*) (void *, enum disassembler_style, const char *, ...) - LIBOPCODE_CALLBACK_NOEXCEPT; + = int (*) (void *, enum disassembler_style, const char *, ...) noexcept; /* Constructor, many fields in m_di are initialized from GDBARCH. The remaining arguments are function callbacks that are written into m_di. From patchwork Tue Nov 21 12:05:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lancelot SIX X-Patchwork-Id: 80462 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4E9BA385801D for ; Tue, 21 Nov 2023 12:06:47 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2062.outbound.protection.outlook.com [40.107.212.62]) by sourceware.org (Postfix) with ESMTPS id 786B83858289 for ; Tue, 21 Nov 2023 12:05:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 786B83858289 Authentication-Results: sourceware.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=amd.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 786B83858289 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.212.62 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1700568360; cv=pass; b=Y5NpdlGBQj7846WIDlp+8kH6/4N3J6k3OmpNIlsM1C7khV7hqNRbD+adNmhHLU1AFj3S3rTHI1WLyWX16quM5kplOIcNgKSDdKeo0JDyufT0sDjnY/hZprf1Muiqa0i2LpTKLQ1iaMxLE/ekVLIIkSWbkNQ+AulClslpT+ehHvM= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1700568360; c=relaxed/simple; bh=iXsetJtj1hxO0H3fNuLC7Af6EwLFiD6/7jufJpz0cHY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=FV8rnqaZOB3jnp+t8utqqyjI4KChM6A0atBN29G/3zq2o4rq1n76vXMAvYkNLBvu1PCFgTHWh53LKg5W+Ww1QxC6LgyeGn02wVR7tgpl3uESC+NIzVuMIrolFHFanmkmuX/tDlswDWEFgqvfJXRGBdY2SToYMiJqzN/cGyL6oxY= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T9qJf6tmtrPdMeGMOVOKd+kFg2kjXa22FQs8dC9Te9UCe5xjWFpnV2fmFTsfTXVPh+Sj36PN6wHYJImEFkQtczHj4zEWjSDDGZbLG+2HLytmG+bJbhlzRdcgwnVwDOURpi+FwbQc5jTDpaUKZnafFtajysDoIfiVBRMpHWl4vbTxEP8xhMtIlAq3vetvhuJyPvmh878KPPCvW56uq547qDtBEbwJurHP1sXp32ADwmlwZw+JFMNgm+ReIF4BoKUvGsJrVx010BLmFA6Iw7cIe9lgZtv4kpQRJ5S0rHB4bgxWgV+TbuXSyKlQfB4zUNfcBOa9OW2SxYA8JuivPNJeVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=e5tD/3k8oaL/LlQIpEmetSBpoQsEZuA8NFiyWi4Ljds=; b=Kljy36TAdIK3iwzsY1DAQecyJ0gFYKsqUxd4L+DC8hepWW+oHUV75PidIo1n14m0VUWTW2LRFhWQ3WlmgS7l71itGOEjd+Whw6eF0ziJYqryQ/g3psJtKaHKNiclk787yatjvXkUg43v44buQqNUD0m3he5v+JzmP2U/W7jgYfkahXBLv5qW9EpfM4v7LxA0ApWrMIqlCyMcwecxDK28KFooyAriihVAQHFUrvSf9AkCLPE5y5kgH8T+sVVJgII1GA1S9LqdJ/7G6JGRYhH7/YVdrC9IeL9IE0YQjfwBlJQyqOvLBbn2N2R8favKwKA7D0161fyntGqgpTPA7mNkKQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=sourceware.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=e5tD/3k8oaL/LlQIpEmetSBpoQsEZuA8NFiyWi4Ljds=; b=0UKoteYPVqXhDZWn+JKfM0+9RmyW0g4EC7HMXU61oTvDSJn7GuI2NFxv4cDI0vuVxr1cPuLkdHlIx288VCOykHdOa3Yxi5hlo7j5Z4nn7GEBfakT5O3T0J5kUSUN8kqqsCGBeBROo9CPTVpUxeIFRoFxXQx8Cu1mpb5sRhFlanQ= Received: from BL1PR13CA0094.namprd13.prod.outlook.com (2603:10b6:208:2b9::9) by CH3PR12MB8753.namprd12.prod.outlook.com (2603:10b6:610:178::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.28; Tue, 21 Nov 2023 12:05:54 +0000 Received: from MN1PEPF0000F0E3.namprd04.prod.outlook.com (2603:10b6:208:2b9:cafe::78) by BL1PR13CA0094.outlook.office365.com (2603:10b6:208:2b9::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.16 via Frontend Transport; Tue, 21 Nov 2023 12:05:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MN1PEPF0000F0E3.mail.protection.outlook.com (10.167.242.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7025.12 via Frontend Transport; Tue, 21 Nov 2023 12:05:54 +0000 Received: from hpe6u-23.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Tue, 21 Nov 2023 06:05:53 -0600 From: Lancelot Six To: CC: , , Lancelot Six Subject: [COMMITTED PATCH v2 9/9] gdb: Use initializers in lambda captures unconditionally Date: Tue, 21 Nov 2023 12:05:00 +0000 Message-ID: <20231121120500.1394523-10-lancelot.six@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028204821.fp5hh7bahrmrnpjl@hpe6u-23> References: <20231028204821.fp5hh7bahrmrnpjl@hpe6u-23> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000F0E3:EE_|CH3PR12MB8753:EE_ X-MS-Office365-Filtering-Correlation-Id: b4221154-8aa9-4ecd-2de1-08dbea8a36b6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ROpwEpPnHlfJ02ygdGGW/9WB6+M7ekBDDnkWeAZrsDuC6BRrQPEM0VQWiuP88DtxDTMrZAGE7FY/nwfiFPPL6SBJCGz3G+CDYIwVxeG6Vd7vFnJwlZPLkJq5YzZ74yRlghmKVLYErXnUKRyWrtNP9vkHHifCYAGBJpBUN80qVxd3pQUJwo9obsW6oDL8uSOA5TlGEpB4wbpjHx8gZMhp30em6cnuj1QOMR/h2K56ZJHnma5RL/0hvg9hCQjv8VU+SKgSfY9LsXidR34ikBfjvumsI0C5I4UKQ/CKPJxrZdAR49aH5GVWeV7vs/OyC+S/AiRZ3mQrVx1mmz9ToB4aBkHDre8ctc9kKfVktQ5FYDu9McCysPyvrq2f506Cl0nsFvhac/TWrc3fScueBqFsTt5fx60RL6CdE4b3m8nL36iNTo6angQF/UHeOXFu4+r3L6R3Bxx10fwPnhDKY70N3lNjmzp7XI1l/Mk9c9ZKPRN2efDoRhJnyyga7CoDMY9Ch0GM9RvFAbbIHn2uInP/lsaRD1Y/4UsBoG2Q8iDuCg/+7uUGrp5Dq76/ZxYi1sj56Dd4sSYrEVS6LaM2FeLERuL9u/BvxW+5erveuHra3+Eg2VaZ+dlWmsfIJySvymDwsBHwr1YxedNxwar7q19rdBbq3i9+bgXK+YStwLZI6x4Ords0xaBiY7b+drdgBDw3iMrc4DyIG14vREng++YzibvRK1uhRpbkY9CB8IC69Sc3RH0+eUyTs7WFLpMrb0/kMuFZLiG9qLKVxAPNCEOlDg== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(376002)(346002)(396003)(136003)(39860400002)(230922051799003)(451199024)(64100799003)(186009)(82310400011)(1800799012)(36840700001)(46966006)(40470700004)(40460700003)(83380400001)(426003)(336012)(26005)(16526019)(1076003)(47076005)(36860700001)(8676002)(4326008)(8936002)(44832011)(2906002)(5660300002)(41300700001)(478600001)(6666004)(70586007)(7696005)(70206006)(6916009)(54906003)(316002)(36756003)(81166007)(86362001)(82740400003)(356005)(2616005)(40480700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 12:05:54.6883 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b4221154-8aa9-4ecd-2de1-08dbea8a36b6 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MN1PEPF0000F0E3.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8753 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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: 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+patchwork=sourceware.org@sourceware.org Initializers in lambda captures were introduced in C++14, and conditionally used in gdb/cp-support.c and gdb/dwarf2/cooked-index.c. Since C++17 is now required by GDB, use this feature unconditionally. Change-Id: I87a3d567941e5c71217538fa75c952e4d421fa1d Approved-By: Tom Tromey Approved-By: Pedro Alves --- gdb/cp-support.c | 8 +------- gdb/dwarf2/cooked-index.c | 7 +------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/gdb/cp-support.c b/gdb/cp-support.c index 834c4774755..cb169444d2a 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -1657,13 +1657,7 @@ gdb_demangle (const char *name, int options) we might be in a background thread. Instead, arrange for the reporting to happen on the main thread. */ std::string copy = name; - run_on_main_thread ([ -#if __cplusplus >= 201402L - =, copy = std::move (copy) -#else - = -#endif - ] () + run_on_main_thread ([=, copy = std::move (copy)] () { report_failed_demangle (copy.c_str (), core_dump_allowed, crash_signal); diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c index 7c4af3a1681..10631dccecf 100644 --- a/gdb/dwarf2/cooked-index.c +++ b/gdb/dwarf2/cooked-index.c @@ -466,12 +466,7 @@ cooked_index::start_writing_index (dwarf2_per_bfd *per_bfd) started, because it may call 'wait'. */ m_write_future = gdb::thread_pool::g_thread_pool->post_task ([this, per_bfd, -#if __cplusplus >= 201402L - ctx = std::move (ctx) -#else - ctx -#endif - ] () + ctx = std::move (ctx)] () { maybe_write_index (per_bfd, ctx); });