From patchwork Fri Oct 13 14:44:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lancelot SIX X-Patchwork-Id: 77662 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 DB253385C6D6 for ; Fri, 13 Oct 2023 14:45:04 +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-dm6nam11on2057.outbound.protection.outlook.com [40.107.223.57]) by sourceware.org (Postfix) with ESMTPS id 9557B3856DC8 for ; Fri, 13 Oct 2023 14:44:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9557B3856DC8 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-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I5AbOa1bey0bQeSXEX2EQwb9dm3eWZeDTFjFST+wwp8zUHFV0fXQyJvDg455F0P2U9r+6mroOGCMwo98pefZPes6Okg1ySO+ponIFs3dsdQbD6nJWtQ5hvpTmRGVhIkrb/SW05zHvW2xRIxYvQqwEbGpO1K+raeerwdzUWpIZRchUXrVg/EQv9qAijjS8/Tt982Y+VoBCZOzW7tqqtW5KFq5pOOZw0RqjTq3GlLCjZYnv8ZXHCjAzcpmHcHKnbFtMsJJHzN8ux5fshpmEe0M6ri592rvbBBv+ruAE0TivKerjHKXh4JnN45bSWPZMPCU0OQBnI349YyNn1G6TmRpdQ== 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=it1zvKkQlu+NzmGRlVvC3sQiRGM7KbAZsrQEX5eY7a0=; b=W57HSLzlwRKHXrqwj2uT+e0kySsMwye5U7aFWJv8mDPgRubgIqd8uQsorNkzOS0adOPyc19co3sKQ243sSZAV5VXNRAFFhewpsGwShUn7sq3EWE122sRXqcpmGFIM46FQY95O+gqCRFMwyLQ9NzMGk29o969dvVqMXx0l5cuPzuEi9Ij3Ev1n8/9dLUBNlSVkOOnfAY+4HWduP7PMJKHdM0OQUC3ZoxsdiiSxmXqIpqY3BjwPR6oGs9AFshBIOgn+nzZyd0mSo8B8vEq8TQy8fjOMGOVvbtDyF4cJuRAdIo4rpS23m82FuL5Kr7xKqxPh5KhQYBMbF+kfbtr2ED96w== 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 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=it1zvKkQlu+NzmGRlVvC3sQiRGM7KbAZsrQEX5eY7a0=; b=TJM9jc6mfVc3HDW35guFyRMImgfRpzFkg/Z9uMq+OwWyM8hXJExgFObLl7OWe02jLb1IaHQimXiuyXjKcPlZx53BfTMn1w36SD9zebNU5Fo7+VVOFMco905kDmIi2gxYCIlwTSf4uMrSaUdTzUhMIfHXxph1anoZuEhUf75FEho= Received: from CH0P220CA0007.NAMP220.PROD.OUTLOOK.COM (2603:10b6:610:ef::15) by CH2PR12MB4328.namprd12.prod.outlook.com (2603:10b6:610:a6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.38; Fri, 13 Oct 2023 14:44:43 +0000 Received: from DS1PEPF0001709D.namprd05.prod.outlook.com (2603:10b6:610:ef:cafe::b8) by CH0P220CA0007.outlook.office365.com (2603:10b6:610:ef::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.28 via Frontend Transport; Fri, 13 Oct 2023 14:44:43 +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 DS1PEPF0001709D.mail.protection.outlook.com (10.167.18.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Fri, 13 Oct 2023 14:44:43 +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.27; Fri, 13 Oct 2023 09:44:42 -0500 From: Lancelot Six To: CC: Lancelot Six Subject: [PATCH 01/11] gdb/ax_cxx_compile_stdcxx.m4: upgrade Date: Fri, 13 Oct 2023 14:44:08 +0000 Message-ID: <20231013144418.3180617-2-lancelot.six@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231013144418.3180617-1-lancelot.six@amd.com> References: <20231013144418.3180617-1-lancelot.six@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0001709D:EE_|CH2PR12MB4328:EE_ X-MS-Office365-Filtering-Correlation-Id: 4adad9fc-cb16-499b-5039-08dbcbfaf057 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Zq6r6UbLqrud9Vxvqa4VXJiaK0LKYAjVS5tmMyNdWRh+JsoBdSf9q5xy7BWQhLWJPc3if9VsxY1bStEOBtF7Q6UgE1gJhbcb2+VsdwrCvbIcJVRd6KiP+fsMPItThhrFGDHiBaX8kG9Tvo4kRI2PyEMdBNLteOvENTfqN2F+vWmLGSKr9HVlmPU8y6161ngawHU0i4/pMANRy56CwMKD1CCmLbpfU3S0pTTbwKgzIM+ocRSOIDSAY2GEvz5O0maqPluNWMlOgmHq4BJenWYlvTiFJRQEP75bF6f2aXgw1OelJgAJuw8smRqIKldZ4ZjLjTkulIa2TqLDsnK3wxGrKM5iEsiGoJIbi6SkKEEFoQwM5KRMF3qVtzrEALGbPggvw9NOUPbCKxZszBsqAjo9Zd9Jc5rbUYvBKdsFu6zUjubkSXrNR4wTVy7waa8lsDMNgDD7OPErXHzm5eW1Ro0Tk3OC0XqbNq57EriziC17BEryLbFSAbb3qNPSVtVNV2RwjkyUxOQm+m58FIfglFIqiKzvfdTNSLg7XSd+0jARo62UzSnVmAfPYB/ziZp3UjICSp62L5ut5Sah9VXjT+CT66tDosuE7gZsxUvZzDf5eILYrHueuy3dL6mPrzSKYarYrjUkqrxOjDPCGAdoYFY84OUYXc6fbLamOWBm9CwixvSIHQ2uWYXf0o55+ogK788mx9C2zWeEEiRhEV5u5wFbojRNv+ZGb48o2+hLzsu/f7HLIviaixcbpBCspnzdTuVTWTPSZA0aTNKLHYvBgS0EyCiakXDYUEWXuom3azGazDc= 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)(39860400002)(346002)(376002)(396003)(230922051799003)(64100799003)(451199024)(1800799009)(82310400011)(186009)(40470700004)(36840700001)(46966006)(66899024)(966005)(40480700001)(1076003)(4326008)(6916009)(82740400003)(2616005)(40460700003)(426003)(70206006)(336012)(36860700001)(26005)(83380400001)(66574015)(316002)(70586007)(16526019)(8936002)(5660300002)(8676002)(478600001)(30864003)(41300700001)(44832011)(7696005)(6666004)(47076005)(36756003)(356005)(86362001)(81166007)(2906002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2023 14:44:43.6792 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4adad9fc-cb16-499b-5039-08dbcbfaf057 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: DS1PEPF0001709D.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4328 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 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 upgrades gdb/ax_cxx_compile_stdcxx.m4 to follow changes available in [1] and regenerates the configure script. [1] https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html Change-Id: I5b16adc65c9e48a13ad65202d58ab7a9d487214e --- gdb/ax_cxx_compile_stdcxx.m4 | 126 +++++++++++++++++++++++------------ gdb/configure | 44 +++++++++--- gdbserver/configure | 44 +++++++++--- gdbsupport/configure | 44 +++++++++--- 4 files changed, 184 insertions(+), 74 deletions(-) diff --git a/gdb/ax_cxx_compile_stdcxx.m4 b/gdb/ax_cxx_compile_stdcxx.m4 index 68ff8a553f0..b0432599489 100644 --- a/gdb/ax_cxx_compile_stdcxx.m4 +++ b/gdb/ax_cxx_compile_stdcxx.m4 @@ -19,13 +19,13 @@ # # Check for baseline language coverage in the compiler for the specified # version of the C++ standard. If necessary, add switches to CXX and -# CXXCPP to enable support. VERSION may be '11' (for the C++11 standard) -# or '14' (for the C++14 standard). +# CXXCPP to enable support. VERSION may be '11', '14', '17', or '20' for +# the respective C++ standard version. # # The second argument, if specified, indicates whether you insist on an # extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. # -std=c++11). If neither is specified, you get whatever works, with -# preference for an extended mode. +# preference for no added switch, and then for an extended mode. # # The third argument, if specified 'mandatory' or if left unspecified, # indicates that baseline support for the specified C++ standard is @@ -42,14 +42,17 @@ # Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov # Copyright (c) 2015 Paul Norman # Copyright (c) 2015 Moritz Klammler -# Copyright (c) 2016 Krzesimir Nowak +# Copyright (c) 2016, 2018 Krzesimir Nowak +# Copyright (c) 2019 Enji Cooper +# Copyright (c) 2020 Jason Merrill +# Copyright (c) 2021 Jörn Heusipp # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 8 +#serial 18 dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro dnl (serial version number 13). @@ -58,6 +61,7 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"], [$1], [14], [ax_cxx_compile_alternatives="14 1y"], [$1], [17], [ax_cxx_compile_alternatives="17 1z"], + [$1], [20], [ax_cxx_compile_alternatives="20"], [m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl m4_if([$2], [], [], [$2], [ext], [], @@ -70,14 +74,16 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl AC_LANG_PUSH([C++])dnl CXX_DIALECT="" ac_success=no - AC_CACHE_CHECK(whether $CXX supports C++$1 features by default, - ax_cv_cxx_compile_cxx$1, - [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], - [ax_cv_cxx_compile_cxx$1=yes], - [ax_cv_cxx_compile_cxx$1=no])]) - if test x$ax_cv_cxx_compile_cxx$1 = xyes; then - ac_success=yes - fi + + m4_if([$2], [], [dnl + AC_CACHE_CHECK(whether $CXX supports C++$1 features by default, + ax_cv_cxx_compile_cxx$1, + [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], + [ax_cv_cxx_compile_cxx$1=yes], + [ax_cv_cxx_compile_cxx$1=no])]) + if test x$ax_cv_cxx_compile_cxx$1 = xyes; then + ac_success=yes + fi]) m4_if([$2], [noext], [], [dnl if test x$ac_success = xno; then @@ -109,9 +115,18 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl dnl HP's aCC needs +std=c++11 according to: dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf dnl Cray's crayCC needs "-h std=c++11" + dnl MSVC needs -std:c++NN for C++17 and later (default is C++14) for alternative in ${ax_cxx_compile_alternatives}; do - for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do - cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) + for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" MSVC; do + if test x"$switch" = xMSVC; then + dnl AS_TR_SH maps both `:` and `=` to `_` so -std:c++17 would collide + dnl with -std=c++17. We suffix the cache variable name with _MSVC to + dnl avoid this. + switch=-std:c++${alternative} + cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_${switch}_MSVC]) + else + cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) + fi AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, $cachevar, [ac_save_CXX="$CXX" @@ -160,7 +175,6 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11], _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 ) - dnl Test body for checking C++14 support m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14], @@ -168,12 +182,24 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14], _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 ) +dnl Test body for checking C++17 support + m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17], _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 _AX_CXX_COMPILE_STDCXX_testbody_new_in_17 ) +dnl Test body for checking C++20 support + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_20], + _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_17 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_20 +) + + dnl Tests for new features in C++11 m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[ @@ -185,7 +211,11 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[ #error "This is not a C++ compiler" -#elif __cplusplus < 201103L +// MSVC always sets __cplusplus to 199711L in older versions; newer versions +// only set it correctly if /Zc:__cplusplus is specified as well as a +// /std:c++NN switch: +// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ +#elif __cplusplus < 201103L && !defined _MSC_VER #error "This is not a C++11 compiler" @@ -210,11 +240,13 @@ namespace cxx11 struct Base { + virtual ~Base() {} virtual void f() {} }; struct Derived : public Base { + virtual ~Derived() override {} virtual void f() override {} }; @@ -474,7 +506,7 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[ #error "This is not a C++ compiler" -#elif __cplusplus < 201402L +#elif __cplusplus < 201402L && !defined _MSC_VER #error "This is not a C++14 compiler" @@ -598,20 +630,12 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[ #error "This is not a C++ compiler" -#elif __cplusplus <= 201402L +#elif __cplusplus < 201703L && !defined _MSC_VER #error "This is not a C++17 compiler" #else -#if defined(__clang__) - #define REALLY_CLANG -#else - #if defined(__GNUC__) - #define REALLY_GCC - #endif -#endif - #include #include #include @@ -619,16 +643,12 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[ namespace cxx17 { -#if !defined(REALLY_CLANG) namespace test_constexpr_lambdas { - // TODO: test it with clang++ from git - constexpr int foo = [](){return 42;}(); } -#endif // !defined(REALLY_CLANG) namespace test::nested_namespace::definitions { @@ -863,12 +883,9 @@ namespace cxx17 } -#if !defined(REALLY_CLANG) namespace test_template_argument_deduction_for_class_templates { - // TODO: test it with clang++ from git - template struct pair { @@ -887,7 +904,6 @@ namespace cxx17 } } -#endif // !defined(REALLY_CLANG) namespace test_non_type_auto_template_parameters { @@ -901,12 +917,9 @@ namespace cxx17 } -#if !defined(REALLY_CLANG) namespace test_structured_bindings { - // TODO: test it with clang++ from git - int arr[2] = { 1, 2 }; std::pair pr = { 1, 2 }; @@ -938,14 +951,10 @@ namespace cxx17 const auto [ x3, y3 ] = f3(); } -#endif // !defined(REALLY_CLANG) -#if !defined(REALLY_CLANG) namespace test_exception_spec_type_system { - // TODO: test it with clang++ from git - struct Good {}; struct Bad {}; @@ -963,7 +972,6 @@ namespace cxx17 static_assert (std::is_same_v); } -#endif // !defined(REALLY_CLANG) namespace test_inline_variables { @@ -988,6 +996,36 @@ namespace cxx17 } // namespace cxx17 -#endif // __cplusplus <= 201402L +#endif // __cplusplus < 201703L && !defined _MSC_VER + +]]) + + +dnl Tests for new features in C++20 + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_20], [[ + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 202002L && !defined _MSC_VER + +#error "This is not a C++20 compiler" + +#else + +#include + +namespace cxx20 +{ + +// As C++20 supports feature test macros in the standard, there is no +// immediate need to actually test for feature availability on the +// Autoconf side. + +} // namespace cxx20 + +#endif // __cplusplus < 202002L && !defined _MSC_VER ]]) diff --git a/gdb/configure b/gdb/configure index 5361bf42952..408d8a50423 100755 --- a/gdb/configure +++ b/gdb/configure @@ -16501,7 +16501,8 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex ac_compiler_gnu=$ac_cv_cxx_compiler_gnu CXX_DIALECT="" ac_success=no - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5 + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5 $as_echo_n "checking whether $CXX supports C++11 features by default... " >&6; } if ${ax_cv_cxx_compile_cxx11+:} false; then : $as_echo_n "(cached) " >&6 @@ -16517,7 +16518,11 @@ else #error "This is not a C++ compiler" -#elif __cplusplus < 201103L +// MSVC always sets __cplusplus to 199711L in older versions; newer versions +// only set it correctly if /Zc:__cplusplus is specified as well as a +// /std:c++NN switch: +// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ +#elif __cplusplus < 201103L && !defined _MSC_VER #error "This is not a C++11 compiler" @@ -16542,11 +16547,13 @@ namespace cxx11 struct Base { + virtual ~Base() {} virtual void f() {} }; struct Derived : public Base { + virtual ~Derived() override {} virtual void f() override {} }; @@ -16804,9 +16811,9 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11" >&5 $as_echo "$ax_cv_cxx_compile_cxx11" >&6; } - if test x$ax_cv_cxx_compile_cxx11 = xyes; then - ac_success=yes - fi + if test x$ax_cv_cxx_compile_cxx11 = xyes; then + ac_success=yes + fi if test x$ac_success = xno; then for alternative in ${ax_cxx_compile_alternatives}; do @@ -16830,7 +16837,11 @@ else #error "This is not a C++ compiler" -#elif __cplusplus < 201103L +// MSVC always sets __cplusplus to 199711L in older versions; newer versions +// only set it correctly if /Zc:__cplusplus is specified as well as a +// /std:c++NN switch: +// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ +#elif __cplusplus < 201103L && !defined _MSC_VER #error "This is not a C++11 compiler" @@ -16855,11 +16866,13 @@ namespace cxx11 struct Base { + virtual ~Base() {} virtual void f() {} }; struct Derived : public Base { + virtual ~Derived() override {} virtual void f() override {} }; @@ -17132,9 +17145,14 @@ $as_echo "$ac_res" >&6; } fi if test x$ac_success = xno; then - for alternative in ${ax_cxx_compile_alternatives}; do - for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` + for alternative in ${ax_cxx_compile_alternatives}; do + for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" MSVC; do + if test x"$switch" = xMSVC; then + switch=-std:c++${alternative} + cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_${switch}_MSVC" | $as_tr_sh` + else + cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` + fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 $as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } if eval \${$cachevar+:} false; then : @@ -17153,7 +17171,11 @@ else #error "This is not a C++ compiler" -#elif __cplusplus < 201103L +// MSVC always sets __cplusplus to 199711L in older versions; newer versions +// only set it correctly if /Zc:__cplusplus is specified as well as a +// /std:c++NN switch: +// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ +#elif __cplusplus < 201103L && !defined _MSC_VER #error "This is not a C++11 compiler" @@ -17178,11 +17200,13 @@ namespace cxx11 struct Base { + virtual ~Base() {} virtual void f() {} }; struct Derived : public Base { + virtual ~Derived() override {} virtual void f() override {} }; diff --git a/gdbserver/configure b/gdbserver/configure index 202043202cd..a49598fb682 100755 --- a/gdbserver/configure +++ b/gdbserver/configure @@ -5018,7 +5018,8 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex ac_compiler_gnu=$ac_cv_cxx_compiler_gnu CXX_DIALECT="" ac_success=no - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5 + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5 $as_echo_n "checking whether $CXX supports C++11 features by default... " >&6; } if ${ax_cv_cxx_compile_cxx11+:} false; then : $as_echo_n "(cached) " >&6 @@ -5034,7 +5035,11 @@ else #error "This is not a C++ compiler" -#elif __cplusplus < 201103L +// MSVC always sets __cplusplus to 199711L in older versions; newer versions +// only set it correctly if /Zc:__cplusplus is specified as well as a +// /std:c++NN switch: +// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ +#elif __cplusplus < 201103L && !defined _MSC_VER #error "This is not a C++11 compiler" @@ -5059,11 +5064,13 @@ namespace cxx11 struct Base { + virtual ~Base() {} virtual void f() {} }; struct Derived : public Base { + virtual ~Derived() override {} virtual void f() override {} }; @@ -5321,9 +5328,9 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11" >&5 $as_echo "$ax_cv_cxx_compile_cxx11" >&6; } - if test x$ax_cv_cxx_compile_cxx11 = xyes; then - ac_success=yes - fi + if test x$ax_cv_cxx_compile_cxx11 = xyes; then + ac_success=yes + fi if test x$ac_success = xno; then for alternative in ${ax_cxx_compile_alternatives}; do @@ -5347,7 +5354,11 @@ else #error "This is not a C++ compiler" -#elif __cplusplus < 201103L +// MSVC always sets __cplusplus to 199711L in older versions; newer versions +// only set it correctly if /Zc:__cplusplus is specified as well as a +// /std:c++NN switch: +// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ +#elif __cplusplus < 201103L && !defined _MSC_VER #error "This is not a C++11 compiler" @@ -5372,11 +5383,13 @@ namespace cxx11 struct Base { + virtual ~Base() {} virtual void f() {} }; struct Derived : public Base { + virtual ~Derived() override {} virtual void f() override {} }; @@ -5649,9 +5662,14 @@ $as_echo "$ac_res" >&6; } fi if test x$ac_success = xno; then - for alternative in ${ax_cxx_compile_alternatives}; do - for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` + for alternative in ${ax_cxx_compile_alternatives}; do + for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" MSVC; do + if test x"$switch" = xMSVC; then + switch=-std:c++${alternative} + cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_${switch}_MSVC" | $as_tr_sh` + else + cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` + fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 $as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } if eval \${$cachevar+:} false; then : @@ -5670,7 +5688,11 @@ else #error "This is not a C++ compiler" -#elif __cplusplus < 201103L +// MSVC always sets __cplusplus to 199711L in older versions; newer versions +// only set it correctly if /Zc:__cplusplus is specified as well as a +// /std:c++NN switch: +// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ +#elif __cplusplus < 201103L && !defined _MSC_VER #error "This is not a C++11 compiler" @@ -5695,11 +5717,13 @@ namespace cxx11 struct Base { + virtual ~Base() {} virtual void f() {} }; struct Derived : public Base { + virtual ~Derived() override {} virtual void f() override {} }; diff --git a/gdbsupport/configure b/gdbsupport/configure index 2c15e9df840..6d2a4309d7e 100755 --- a/gdbsupport/configure +++ b/gdbsupport/configure @@ -5916,7 +5916,8 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex ac_compiler_gnu=$ac_cv_cxx_compiler_gnu CXX_DIALECT="" ac_success=no - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5 + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5 $as_echo_n "checking whether $CXX supports C++11 features by default... " >&6; } if ${ax_cv_cxx_compile_cxx11+:} false; then : $as_echo_n "(cached) " >&6 @@ -5932,7 +5933,11 @@ else #error "This is not a C++ compiler" -#elif __cplusplus < 201103L +// MSVC always sets __cplusplus to 199711L in older versions; newer versions +// only set it correctly if /Zc:__cplusplus is specified as well as a +// /std:c++NN switch: +// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ +#elif __cplusplus < 201103L && !defined _MSC_VER #error "This is not a C++11 compiler" @@ -5957,11 +5962,13 @@ namespace cxx11 struct Base { + virtual ~Base() {} virtual void f() {} }; struct Derived : public Base { + virtual ~Derived() override {} virtual void f() override {} }; @@ -6219,9 +6226,9 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11" >&5 $as_echo "$ax_cv_cxx_compile_cxx11" >&6; } - if test x$ax_cv_cxx_compile_cxx11 = xyes; then - ac_success=yes - fi + if test x$ax_cv_cxx_compile_cxx11 = xyes; then + ac_success=yes + fi if test x$ac_success = xno; then for alternative in ${ax_cxx_compile_alternatives}; do @@ -6245,7 +6252,11 @@ else #error "This is not a C++ compiler" -#elif __cplusplus < 201103L +// MSVC always sets __cplusplus to 199711L in older versions; newer versions +// only set it correctly if /Zc:__cplusplus is specified as well as a +// /std:c++NN switch: +// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ +#elif __cplusplus < 201103L && !defined _MSC_VER #error "This is not a C++11 compiler" @@ -6270,11 +6281,13 @@ namespace cxx11 struct Base { + virtual ~Base() {} virtual void f() {} }; struct Derived : public Base { + virtual ~Derived() override {} virtual void f() override {} }; @@ -6547,9 +6560,14 @@ $as_echo "$ac_res" >&6; } fi if test x$ac_success = xno; then - for alternative in ${ax_cxx_compile_alternatives}; do - for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` + for alternative in ${ax_cxx_compile_alternatives}; do + for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" MSVC; do + if test x"$switch" = xMSVC; then + switch=-std:c++${alternative} + cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_${switch}_MSVC" | $as_tr_sh` + else + cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` + fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 $as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } if eval \${$cachevar+:} false; then : @@ -6568,7 +6586,11 @@ else #error "This is not a C++ compiler" -#elif __cplusplus < 201103L +// MSVC always sets __cplusplus to 199711L in older versions; newer versions +// only set it correctly if /Zc:__cplusplus is specified as well as a +// /std:c++NN switch: +// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ +#elif __cplusplus < 201103L && !defined _MSC_VER #error "This is not a C++11 compiler" @@ -6593,11 +6615,13 @@ namespace cxx11 struct Base { + virtual ~Base() {} virtual void f() {} }; struct Derived : public Base { + virtual ~Derived() override {} virtual void f() override {} }; From patchwork Fri Oct 13 14:44:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lancelot SIX X-Patchwork-Id: 77669 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 2F84C385C6D9 for ; Fri, 13 Oct 2023 14:46:25 +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-dm6nam10on2056.outbound.protection.outlook.com [40.107.93.56]) by sourceware.org (Postfix) with ESMTPS id 71AA6385559A for ; Fri, 13 Oct 2023 14:45:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 71AA6385559A 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-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ghTq8nsuJFYBJ1EZ2ydADpLXU02frcaPQsVSGke7rc3/sW4gB436XKpqnia/+wPCR9eZYNgrDX9bAzl1hfRuc1jS9uhxiWYZuXe+++qRNUxwvK2X7rdm0U/vuOB4LPcIcy7Yo5ulnAJeIHg6IjxkM4kIZ24iyeJp4WYruRYosO8GzAMo44bqD3Tc1o6vOcViJFCpZNmPhKkgvBw2Mmsh8TmDQSS6XxZIWo2Tu+jPDy817DJBF0H+guOYmN15oryX8dbCnepH7iSmLooL7HhgDMwk0N3ZmRV93+MepWttE6XWqlB5huzfRYH1T6rHkajw5gy+jP8BDM2Q+6EDIgzfYw== 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=dGnktAS67R5PD5dwCqpygxq/Jpat/3m3KlWl1/fCl9s=; b=N8LGip0Np9Lz9SEOVXJmVPpe9xx3/6B87G9CYZtzUoTH4DJHUcrZBMfmCRbSjOpnF4u6U6nmGxieT7SpB0FfVZDNnsxyXqVI2kjQFSNroVxp4ssRpVaICPVcKPUVrHPCRFklQUrBnc+wrJGAK8OmF88qvWWJR+BIlby+ElSu7mzX6NMIP748eQNNiKajS1xveLbyK6XLaxwiBT67zVawF4RBdz3Jo2yfbt4qR2VFNGbAfAHjIKZtyKEA6Arg0spxR+c1LTsWvcBLTNIiSYUXV+GUfCAGujV23gM12PIDqdov7DXqQeJAJJznmbgvHGFG+SBh4SWJb8axFNJcwrM2LA== 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 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=dGnktAS67R5PD5dwCqpygxq/Jpat/3m3KlWl1/fCl9s=; b=FQFKmxrQE9Dzr4jRNp1Ld1ArcVCwFtJNjAuZVTgmmd5XHWsFDnd1GuDgQWBICeseGuZDdvhb2VCVIjNFjIzQqkAEPobs4iCXMTvMO/fKhBryiPv+TB5mGdoy1rAZLZemxQXAl2vdRgEfYupuqHE6n43jRmkusbEQ3pgl/rgvak8= Received: from DM6PR11CA0018.namprd11.prod.outlook.com (2603:10b6:5:190::31) by CH3PR12MB8356.namprd12.prod.outlook.com (2603:10b6:610:130::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.45; Fri, 13 Oct 2023 14:44:55 +0000 Received: from DS1PEPF00017096.namprd05.prod.outlook.com (2603:10b6:5:190:cafe::6b) by DM6PR11CA0018.outlook.office365.com (2603:10b6:5:190::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.27 via Frontend Transport; Fri, 13 Oct 2023 14:44:55 +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 DS1PEPF00017096.mail.protection.outlook.com (10.167.18.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Fri, 13 Oct 2023 14:44:55 +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.27; Fri, 13 Oct 2023 09:44:43 -0500 From: Lancelot Six To: CC: Lancelot Six Subject: [PATCH 02/11] gdb/gdbsupport/gdbserver: Require c++17 Date: Fri, 13 Oct 2023 14:44:09 +0000 Message-ID: <20231013144418.3180617-3-lancelot.six@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231013144418.3180617-1-lancelot.six@amd.com> References: <20231013144418.3180617-1-lancelot.six@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF00017096:EE_|CH3PR12MB8356:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e26976b-2733-49a8-ec43-08dbcbfaf752 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: x5GX1hg8/D7dibST+5BRhMhNImPVSytyC+95t8F+iHmuSmMAQ1CAbLF4VuOZ5zOKmzQACF5jztbh/uSYsmUJcUW2rBuTBxzx8W8MWeMA1Mv8U82EEiTFR3EFmpRbUkUMvJ6zjnztfioN4WnZq6W1RTfe5Gv7m+bA50VdywxON2qNW3lEjx8HgYjvUBctW0gYH+JcG/hPZlUkSsbzbhFEkSLg2ABgJwCEy5IlOIzcJOWCgnX37Q0WsSl3u8OFQEjvoTa2mn/S+k96u1MNdvHjSOOUAtYja8vmsZtAvP7DMNNl0vkFOlaE25fIQLjWBPWnEe+Zv/0jSuY+hCSXnPrvXdAXFED7I4H3mhxcQ54O3Or+JPmNwvMbqK7ShyPxPNZxUB6bJlFSxT6PpsMzH19rAi4NVGwxku3EUXlpExvFP/222Oc59l1ryEbbI13hUrYlnsmM7vvH7LbCWLYPPz+49I9ebQM5HzarrIKT7ase5mmB80x+Vj37WluGh5yGM4iSo+biDWJnQU+s/UDEMIpydbMP2/g70soTRyA5Wqa0sDYe7wlP9fjHQyoOmnv7C3ufXui/2azuY0dZDl0HKEjjEZJ4ciR0bsVVcJk0MfdH3g/A31Qgf6W1TD6PIi5FD771D9g4lNKoisbIO3uN9+y4gTM5FBCUxV4RNkpY7x3UCK1EdNvQI95fXWUnTiIwfVu6nQVD6RN3UdXSVkUI82eRvEyK97LaOKQcxc5kGeWKlLtrd43TZqQLlDnIlkDBewIydJJ2B3lX8uB0DPIjMrdiunA+5aQAstlK/C6mkvTZyYHXLhllObtWCvgs46KBTjGl 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)(136003)(39860400002)(396003)(346002)(230922051799003)(186009)(1800799009)(451199024)(64100799003)(82310400011)(46966006)(36840700001)(40470700004)(7696005)(966005)(316002)(6916009)(70206006)(70586007)(2616005)(478600001)(6666004)(26005)(16526019)(1076003)(8676002)(8936002)(426003)(336012)(4326008)(36756003)(36860700001)(356005)(81166007)(86362001)(2906002)(83380400001)(30864003)(5660300002)(44832011)(41300700001)(47076005)(40480700001)(40460700003)(82740400003)(21314003)(36900700001)(579004)(559001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2023 14:44:55.3163 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7e26976b-2733-49a8-ec43-08dbcbfaf752 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: DS1PEPF00017096.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8356 X-Spam-Status: No, score=-11.2 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_NUMSUBJECT, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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 proposes to require a C++17 compiler to build gdb / gdbsupport / gdbserver. Before this patch, GDB required a C++11 compiler. The general policy regarding bumping C++ language requirement in GDB (as stated in [1]) is: Our general policy is to wait until the oldest compiler that supports C++NN is at least 3 years old. Rationale: We want to ensure reasonably widespread compiler availability, to lower barrier of entry to GDB contributions, and to make it easy for users to easily build new GDB on currently supported stable distributions themselves. 3 years should be sufficient for latest stable releases of distributions to include a compiler for the standard, and/or for new compilers to appear as easily installable optional packages. Requiring everyone to build a compiler first before building GDB, which would happen if we required a too-new compiler, would cause too much inconvenience. See the policy proposal and discussion [here](https://sourceware.org/ml/gdb-patches/2016-10/msg00616.html). The first GCC release which with full C++17 support is GCC-9[2], released in 2019[3], which is over 4 years ago. Clang has had C++17 support since Clang-5[4] released in 2018[5]. A discussions with many distros showed that a C++17-able compiler is always available, meaning that this no hard requirement preventing us to require it going forward. [1] https://sourceware.org/gdb/wiki/Internals%20GDB-C-Coding-Standards#When_is_GDB_going_to_start_requiring_C.2B-.2B-NN_.3F [2] https://gcc.gnu.org/projects/cxx-status.html#cxx17 [3] https://gcc.gnu.org/gcc-9/ [4] https://clang.llvm.org/cxx_status.html [5] https://releases.llvm.org/ Change-Id: Id596f5db17ea346e8a978668825787b3a9a443fd Reviewed-By: Eli Zaretskii --- gdb/NEWS | 3 + gdb/config.in | 4 +- gdb/configure | 1970 ++++++++++++++++++++++++++++++++++----- gdb/configure.ac | 4 +- gdbserver/config.in | 4 +- gdbserver/configure | 1970 ++++++++++++++++++++++++++++++++++----- gdbserver/configure.ac | 4 +- gdbsupport/Makefile.in | 2 +- gdbsupport/config.in | 4 +- gdbsupport/configure | 1970 ++++++++++++++++++++++++++++++++++----- gdbsupport/configure.ac | 4 +- 11 files changed, 5212 insertions(+), 727 deletions(-) diff --git a/gdb/NEWS b/gdb/NEWS index 81264c0cfb3..8ab2e4c593a 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -3,6 +3,9 @@ *** Changes since GDB 14 +* Building GDB and GDBserver now requires a C++17 compiler. + For example, GCC 9 or later. + * GDB index now contains information about the main function. This speeds up startup when it is being used for some large binaries. diff --git a/gdb/config.in b/gdb/config.in index e17245156d8..f8926fe4404 100644 --- a/gdb/config.in +++ b/gdb/config.in @@ -99,8 +99,8 @@ /* Define to 1 if you have the header file. */ #undef HAVE_CURSES_H -/* define if the compiler supports basic C++11 syntax */ -#undef HAVE_CXX11 +/* define if the compiler supports basic C++17 syntax */ +#undef HAVE_CXX17 /* Define to 1 if you have the declaration of `ADDR_NO_RANDOMIZE', and to 0 if you don't. */ diff --git a/gdb/configure b/gdb/configure index 408d8a50423..0878481e354 100755 --- a/gdb/configure +++ b/gdb/configure @@ -803,7 +803,7 @@ CCDEPMODE DEPDIR am__leading_dot CXX_DIALECT -HAVE_CXX11 +HAVE_CXX17 CXXCPP OTOOL64 OTOOL @@ -16491,9 +16491,9 @@ exec 5>>config.log $lt_cl_success || as_fn_exit 1 -# We require a C++11 compiler. Check if one is available, and if +# We require a C++17 compiler. Check if one is available, and if # necessary, set CXX_DIALECT to some -std=xxx switch. - ax_cxx_compile_alternatives="11 0x" ax_cxx_compile_cxx11_required=true + ax_cxx_compile_alternatives="17 1z" ax_cxx_compile_cxx17_required=true ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -16502,9 +16502,9 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu CXX_DIALECT="" ac_success=no - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5 -$as_echo_n "checking whether $CXX supports C++11 features by default... " >&6; } -if ${ax_cv_cxx_compile_cxx11+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++17 features by default" >&5 +$as_echo_n "checking whether $CXX supports C++17 features by default... " >&6; } +if ${ax_cv_cxx_compile_cxx17+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -16801,32 +16801,1362 @@ namespace cxx11 + +// If the compiler admits that it is not ready for C++14, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201402L && !defined _MSC_VER + +#error "This is not a C++14 compiler" + +#else + +namespace cxx14 +{ + + namespace test_polymorphic_lambdas + { + + int + test() + { + const auto lambda = [](auto&&... args){ + const auto istiny = [](auto x){ + return (sizeof(x) == 1UL) ? 1 : 0; + }; + const int aretiny[] = { istiny(args)... }; + return aretiny[0]; + }; + return lambda(1, 1L, 1.0f, '1'); + } + + } + + namespace test_binary_literals + { + + constexpr auto ivii = 0b0000000000101010; + static_assert(ivii == 42, "wrong value"); + + } + + namespace test_generalized_constexpr + { + + template < typename CharT > + constexpr unsigned long + strlen_c(const CharT *const s) noexcept + { + auto length = 0UL; + for (auto p = s; *p; ++p) + ++length; + return length; + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("x") == 1UL, ""); + static_assert(strlen_c("test") == 4UL, ""); + static_assert(strlen_c("another\0test") == 7UL, ""); + + } + + namespace test_lambda_init_capture + { + + int + test() + { + auto x = 0; + const auto lambda1 = [a = x](int b){ return a + b; }; + const auto lambda2 = [a = lambda1(x)](){ return a; }; + return lambda2(); + } + + } + + namespace test_digit_separators + { + + constexpr auto ten_million = 100'000'000; + static_assert(ten_million == 100000000, ""); + + } + + namespace test_return_type_deduction + { + + auto f(int& x) { return x; } + decltype(auto) g(int& x) { return x; } + + template < typename T1, typename T2 > + struct is_same + { + static constexpr auto value = false; + }; + + template < typename T > + struct is_same + { + static constexpr auto value = true; + }; + + int + test() + { + auto x = 0; + static_assert(is_same::value, ""); + static_assert(is_same::value, ""); + return x; + } + + } + +} // namespace cxx14 + +#endif // __cplusplus >= 201402L + + + + +// If the compiler admits that it is not ready for C++17, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201703L && !defined _MSC_VER + +#error "This is not a C++17 compiler" + +#else + +#include +#include +#include + +namespace cxx17 +{ + + namespace test_constexpr_lambdas + { + + constexpr int foo = [](){return 42;}(); + + } + + namespace test::nested_namespace::definitions + { + + } + + namespace test_fold_expression + { + + template + int multiply(Args... args) + { + return (args * ... * 1); + } + + template + bool all(Args... args) + { + return (args && ...); + } + + } + + namespace test_extended_static_assert + { + + static_assert (true); + + } + + namespace test_auto_brace_init_list + { + + auto foo = {5}; + auto bar {5}; + + static_assert(std::is_same, decltype(foo)>::value); + static_assert(std::is_same::value); + } + + namespace test_typename_in_template_template_parameter + { + + template typename X> struct D; + + } + + namespace test_fallthrough_nodiscard_maybe_unused_attributes + { + + int f1() + { + return 42; + } + + [[nodiscard]] int f2() + { + [[maybe_unused]] auto unused = f1(); + + switch (f1()) + { + case 17: + f1(); + [[fallthrough]]; + case 42: + f1(); + } + return f1(); + } + + } + + namespace test_extended_aggregate_initialization + { + + struct base1 + { + int b1, b2 = 42; + }; + + struct base2 + { + base2() { + b3 = 42; + } + int b3; + }; + + struct derived : base1, base2 + { + int d; + }; + + derived d1 {{1, 2}, {}, 4}; // full initialization + derived d2 {{}, {}, 4}; // value-initialized bases + + } + + namespace test_general_range_based_for_loop + { + + struct iter + { + int i; + + int& operator* () + { + return i; + } + + const int& operator* () const + { + return i; + } + + iter& operator++() + { + ++i; + return *this; + } + }; + + struct sentinel + { + int i; + }; + + bool operator== (const iter& i, const sentinel& s) + { + return i.i == s.i; + } + + bool operator!= (const iter& i, const sentinel& s) + { + return !(i == s); + } + + struct range + { + iter begin() const + { + return {0}; + } + + sentinel end() const + { + return {5}; + } + }; + + void f() + { + range r {}; + + for (auto i : r) + { + [[maybe_unused]] auto v = i; + } + } + + } + + namespace test_lambda_capture_asterisk_this_by_value + { + + struct t + { + int i; + int foo() + { + return [*this]() + { + return i; + }(); + } + }; + + } + + namespace test_enum_class_construction + { + + enum class byte : unsigned char + {}; + + byte foo {42}; + + } + + namespace test_constexpr_if + { + + template + int f () + { + if constexpr(cond) + { + return 13; + } + else + { + return 42; + } + } + + } + + namespace test_selection_statement_with_initializer + { + + int f() + { + return 13; + } + + int f2() + { + if (auto i = f(); i > 0) + { + return 3; + } + + switch (auto i = f(); i + 4) + { + case 17: + return 2; + + default: + return 1; + } + } + + } + + namespace test_template_argument_deduction_for_class_templates + { + + template + struct pair + { + pair (T1 p1, T2 p2) + : m1 {p1}, + m2 {p2} + {} + + T1 m1; + T2 m2; + }; + + void f() + { + [[maybe_unused]] auto p = pair{13, 42u}; + } + + } + + namespace test_non_type_auto_template_parameters + { + + template + struct B + {}; + + B<5> b1; + B<'a'> b2; + + } + + namespace test_structured_bindings + { + + int arr[2] = { 1, 2 }; + std::pair pr = { 1, 2 }; + + auto f1() -> int(&)[2] + { + return arr; + } + + auto f2() -> std::pair& + { + return pr; + } + + struct S + { + int x1 : 2; + volatile double y1; + }; + + S f3() + { + return {}; + } + + auto [ x1, y1 ] = f1(); + auto& [ xr1, yr1 ] = f1(); + auto [ x2, y2 ] = f2(); + auto& [ xr2, yr2 ] = f2(); + const auto [ x3, y3 ] = f3(); + + } + + namespace test_exception_spec_type_system + { + + struct Good {}; + struct Bad {}; + + void g1() noexcept; + void g2(); + + template + Bad + f(T*, T*); + + template + Good + f(T1*, T2*); + + static_assert (std::is_same_v); + + } + + namespace test_inline_variables + { + + template void f(T) + {} + + template inline T g(T) + { + return T{}; + } + + template<> inline void f<>(int) + {} + + template<> int g<>(int) + { + return 5; + } + + } + +} // namespace cxx17 + +#endif // __cplusplus < 201703L && !defined _MSC_VER + + + +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ax_cv_cxx_compile_cxx17=yes +else + ax_cv_cxx_compile_cxx17=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx17" >&5 +$as_echo "$ax_cv_cxx_compile_cxx17" >&6; } + if test x$ax_cv_cxx_compile_cxx17 = xyes; then + ac_success=yes + fi + + if test x$ac_success = xno; then + for alternative in ${ax_cxx_compile_alternatives}; do + switch="-std=gnu++${alternative}" + cachevar=`$as_echo "ax_cv_cxx_compile_cxx17_$switch" | $as_tr_sh` + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++17 features with $switch" >&5 +$as_echo_n "checking whether $CXX supports C++17 features with $switch... " >&6; } +if eval \${$cachevar+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_CXX="$CXX" + CXX="$CXX $switch" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +// If the compiler admits that it is not ready for C++11, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +// MSVC always sets __cplusplus to 199711L in older versions; newer versions +// only set it correctly if /Zc:__cplusplus is specified as well as a +// /std:c++NN switch: +// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ +#elif __cplusplus < 201103L && !defined _MSC_VER + +#error "This is not a C++11 compiler" + +#else + +namespace cxx11 +{ + + namespace test_static_assert + { + + template + struct check + { + static_assert(sizeof(int) <= sizeof(T), "not big enough"); + }; + + } + + namespace test_final_override + { + + struct Base + { + virtual ~Base() {} + virtual void f() {} + }; + + struct Derived : public Base + { + virtual ~Derived() override {} + virtual void f() override {} + }; + + } + + namespace test_double_right_angle_brackets + { + + template < typename T > + struct check {}; + + typedef check single_type; + typedef check> double_type; + typedef check>> triple_type; + typedef check>>> quadruple_type; + + } + + namespace test_decltype + { + + int + f() + { + int a = 1; + decltype(a) b = 2; + return a + b; + } + + } + + namespace test_type_deduction + { + + template < typename T1, typename T2 > + struct is_same + { + static const bool value = false; + }; + + template < typename T > + struct is_same + { + static const bool value = true; + }; + + template < typename T1, typename T2 > + auto + add(T1 a1, T2 a2) -> decltype(a1 + a2) + { + return a1 + a2; + } + + int + test(const int c, volatile int v) + { + static_assert(is_same::value == true, ""); + static_assert(is_same::value == false, ""); + static_assert(is_same::value == false, ""); + auto ac = c; + auto av = v; + auto sumi = ac + av + 'x'; + auto sumf = ac + av + 1.0; + static_assert(is_same::value == true, ""); + static_assert(is_same::value == true, ""); + static_assert(is_same::value == true, ""); + static_assert(is_same::value == false, ""); + static_assert(is_same::value == true, ""); + return (sumf > 0.0) ? sumi : add(c, v); + } + + } + + namespace test_noexcept + { + + int f() { return 0; } + int g() noexcept { return 0; } + + static_assert(noexcept(f()) == false, ""); + static_assert(noexcept(g()) == true, ""); + + } + + namespace test_constexpr + { + + template < typename CharT > + unsigned long constexpr + strlen_c_r(const CharT *const s, const unsigned long acc) noexcept + { + return *s ? strlen_c_r(s + 1, acc + 1) : acc; + } + + template < typename CharT > + unsigned long constexpr + strlen_c(const CharT *const s) noexcept + { + return strlen_c_r(s, 0UL); + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("1") == 1UL, ""); + static_assert(strlen_c("example") == 7UL, ""); + static_assert(strlen_c("another\0example") == 7UL, ""); + + } + + namespace test_rvalue_references + { + + template < int N > + struct answer + { + static constexpr int value = N; + }; + + answer<1> f(int&) { return answer<1>(); } + answer<2> f(const int&) { return answer<2>(); } + answer<3> f(int&&) { return answer<3>(); } + + void + test() + { + int i = 0; + const int c = 0; + static_assert(decltype(f(i))::value == 1, ""); + static_assert(decltype(f(c))::value == 2, ""); + static_assert(decltype(f(0))::value == 3, ""); + } + + } + + namespace test_uniform_initialization + { + + struct test + { + static const int zero {}; + static const int one {1}; + }; + + static_assert(test::zero == 0, ""); + static_assert(test::one == 1, ""); + + } + + namespace test_lambdas + { + + void + test1() + { + auto lambda1 = [](){}; + auto lambda2 = lambda1; + lambda1(); + lambda2(); + } + + int + test2() + { + auto a = [](int i, int j){ return i + j; }(1, 2); + auto b = []() -> int { return '0'; }(); + auto c = [=](){ return a + b; }(); + auto d = [&](){ return c; }(); + auto e = [a, &b](int x) mutable { + const auto identity = [](int y){ return y; }; + for (auto i = 0; i < a; ++i) + a += b--; + return x + identity(a + b); + }(0); + return a + b + c + d + e; + } + + int + test3() + { + const auto nullary = [](){ return 0; }; + const auto unary = [](int x){ return x; }; + using nullary_t = decltype(nullary); + using unary_t = decltype(unary); + const auto higher1st = [](nullary_t f){ return f(); }; + const auto higher2nd = [unary](nullary_t f1){ + return [unary, f1](unary_t f2){ return f2(unary(f1())); }; + }; + return higher1st(nullary) + higher2nd(nullary)(unary); + } + + } + + namespace test_variadic_templates + { + + template + struct sum; + + template + struct sum + { + static constexpr auto value = N0 + sum::value; + }; + + template <> + struct sum<> + { + static constexpr auto value = 0; + }; + + static_assert(sum<>::value == 0, ""); + static_assert(sum<1>::value == 1, ""); + static_assert(sum<23>::value == 23, ""); + static_assert(sum<1, 2>::value == 3, ""); + static_assert(sum<5, 5, 11>::value == 21, ""); + static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, ""); + + } + + // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae + // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function + // because of this. + namespace test_template_alias_sfinae + { + + struct foo {}; + + template + using member = typename T::member_type; + + template + void func(...) {} + + template + void func(member*) {} + + void test(); + + void test() { func(0); } + + } + +} // namespace cxx11 + +#endif // __cplusplus >= 201103L + + + + +// If the compiler admits that it is not ready for C++14, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201402L && !defined _MSC_VER + +#error "This is not a C++14 compiler" + +#else + +namespace cxx14 +{ + + namespace test_polymorphic_lambdas + { + + int + test() + { + const auto lambda = [](auto&&... args){ + const auto istiny = [](auto x){ + return (sizeof(x) == 1UL) ? 1 : 0; + }; + const int aretiny[] = { istiny(args)... }; + return aretiny[0]; + }; + return lambda(1, 1L, 1.0f, '1'); + } + + } + + namespace test_binary_literals + { + + constexpr auto ivii = 0b0000000000101010; + static_assert(ivii == 42, "wrong value"); + + } + + namespace test_generalized_constexpr + { + + template < typename CharT > + constexpr unsigned long + strlen_c(const CharT *const s) noexcept + { + auto length = 0UL; + for (auto p = s; *p; ++p) + ++length; + return length; + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("x") == 1UL, ""); + static_assert(strlen_c("test") == 4UL, ""); + static_assert(strlen_c("another\0test") == 7UL, ""); + + } + + namespace test_lambda_init_capture + { + + int + test() + { + auto x = 0; + const auto lambda1 = [a = x](int b){ return a + b; }; + const auto lambda2 = [a = lambda1(x)](){ return a; }; + return lambda2(); + } + + } + + namespace test_digit_separators + { + + constexpr auto ten_million = 100'000'000; + static_assert(ten_million == 100000000, ""); + + } + + namespace test_return_type_deduction + { + + auto f(int& x) { return x; } + decltype(auto) g(int& x) { return x; } + + template < typename T1, typename T2 > + struct is_same + { + static constexpr auto value = false; + }; + + template < typename T > + struct is_same + { + static constexpr auto value = true; + }; + + int + test() + { + auto x = 0; + static_assert(is_same::value, ""); + static_assert(is_same::value, ""); + return x; + } + + } + +} // namespace cxx14 + +#endif // __cplusplus >= 201402L + + + + +// If the compiler admits that it is not ready for C++17, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201703L && !defined _MSC_VER + +#error "This is not a C++17 compiler" + +#else + +#include +#include +#include + +namespace cxx17 +{ + + namespace test_constexpr_lambdas + { + + constexpr int foo = [](){return 42;}(); + + } + + namespace test::nested_namespace::definitions + { + + } + + namespace test_fold_expression + { + + template + int multiply(Args... args) + { + return (args * ... * 1); + } + + template + bool all(Args... args) + { + return (args && ...); + } + + } + + namespace test_extended_static_assert + { + + static_assert (true); + + } + + namespace test_auto_brace_init_list + { + + auto foo = {5}; + auto bar {5}; + + static_assert(std::is_same, decltype(foo)>::value); + static_assert(std::is_same::value); + } + + namespace test_typename_in_template_template_parameter + { + + template typename X> struct D; + + } + + namespace test_fallthrough_nodiscard_maybe_unused_attributes + { + + int f1() + { + return 42; + } + + [[nodiscard]] int f2() + { + [[maybe_unused]] auto unused = f1(); + + switch (f1()) + { + case 17: + f1(); + [[fallthrough]]; + case 42: + f1(); + } + return f1(); + } + + } + + namespace test_extended_aggregate_initialization + { + + struct base1 + { + int b1, b2 = 42; + }; + + struct base2 + { + base2() { + b3 = 42; + } + int b3; + }; + + struct derived : base1, base2 + { + int d; + }; + + derived d1 {{1, 2}, {}, 4}; // full initialization + derived d2 {{}, {}, 4}; // value-initialized bases + + } + + namespace test_general_range_based_for_loop + { + + struct iter + { + int i; + + int& operator* () + { + return i; + } + + const int& operator* () const + { + return i; + } + + iter& operator++() + { + ++i; + return *this; + } + }; + + struct sentinel + { + int i; + }; + + bool operator== (const iter& i, const sentinel& s) + { + return i.i == s.i; + } + + bool operator!= (const iter& i, const sentinel& s) + { + return !(i == s); + } + + struct range + { + iter begin() const + { + return {0}; + } + + sentinel end() const + { + return {5}; + } + }; + + void f() + { + range r {}; + + for (auto i : r) + { + [[maybe_unused]] auto v = i; + } + } + + } + + namespace test_lambda_capture_asterisk_this_by_value + { + + struct t + { + int i; + int foo() + { + return [*this]() + { + return i; + }(); + } + }; + + } + + namespace test_enum_class_construction + { + + enum class byte : unsigned char + {}; + + byte foo {42}; + + } + + namespace test_constexpr_if + { + + template + int f () + { + if constexpr(cond) + { + return 13; + } + else + { + return 42; + } + } + + } + + namespace test_selection_statement_with_initializer + { + + int f() + { + return 13; + } + + int f2() + { + if (auto i = f(); i > 0) + { + return 3; + } + + switch (auto i = f(); i + 4) + { + case 17: + return 2; + + default: + return 1; + } + } + + } + + namespace test_template_argument_deduction_for_class_templates + { + + template + struct pair + { + pair (T1 p1, T2 p2) + : m1 {p1}, + m2 {p2} + {} + + T1 m1; + T2 m2; + }; + + void f() + { + [[maybe_unused]] auto p = pair{13, 42u}; + } + + } + + namespace test_non_type_auto_template_parameters + { + + template + struct B + {}; + + B<5> b1; + B<'a'> b2; + + } + + namespace test_structured_bindings + { + + int arr[2] = { 1, 2 }; + std::pair pr = { 1, 2 }; + + auto f1() -> int(&)[2] + { + return arr; + } + + auto f2() -> std::pair& + { + return pr; + } + + struct S + { + int x1 : 2; + volatile double y1; + }; + + S f3() + { + return {}; + } + + auto [ x1, y1 ] = f1(); + auto& [ xr1, yr1 ] = f1(); + auto [ x2, y2 ] = f2(); + auto& [ xr2, yr2 ] = f2(); + const auto [ x3, y3 ] = f3(); + + } + + namespace test_exception_spec_type_system + { + + struct Good {}; + struct Bad {}; + + void g1() noexcept; + void g2(); + + template + Bad + f(T*, T*); + + template + Good + f(T1*, T2*); + + static_assert (std::is_same_v); + + } + + namespace test_inline_variables + { + + template void f(T) + {} + + template inline T g(T) + { + return T{}; + } + + template<> inline void f<>(int) + {} + + template<> int g<>(int) + { + return 5; + } + + } + +} // namespace cxx17 + +#endif // __cplusplus < 201703L && !defined _MSC_VER + + + _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : - ax_cv_cxx_compile_cxx11=yes + eval $cachevar=yes else - ax_cv_cxx_compile_cxx11=no + eval $cachevar=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CXX="$ac_save_CXX" fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11" >&5 -$as_echo "$ax_cv_cxx_compile_cxx11" >&6; } - if test x$ax_cv_cxx_compile_cxx11 = xyes; then - ac_success=yes - fi +eval ac_res=\$$cachevar + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + if eval test x\$$cachevar = xyes; then + CXX_DIALECT="$switch" + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi + ac_success=yes + break + fi + done + fi if test x$ac_success = xno; then - for alternative in ${ax_cxx_compile_alternatives}; do - switch="-std=gnu++${alternative}" - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 -$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } + for alternative in ${ax_cxx_compile_alternatives}; do + for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" MSVC; do + if test x"$switch" = xMSVC; then + switch=-std:c++${alternative} + cachevar=`$as_echo "ax_cv_cxx_compile_cxx17_${switch}_MSVC" | $as_tr_sh` + else + cachevar=`$as_echo "ax_cv_cxx_compile_cxx17_$switch" | $as_tr_sh` + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++17 features with $switch" >&5 +$as_echo_n "checking whether $CXX supports C++17 features with $switch... " >&6; } if eval \${$cachevar+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_CXX="$CXX" - CXX="$CXX $switch" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + CXX="$CXX $switch" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -17120,337 +18450,501 @@ namespace cxx11 -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - eval $cachevar=yes -else - eval $cachevar=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CXX="$ac_save_CXX" -fi -eval ac_res=\$$cachevar - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - if eval test x\$$cachevar = xyes; then - CXX_DIALECT="$switch" - CXX="$CXX $switch" - if test -n "$CXXCPP" ; then - CXXCPP="$CXXCPP $switch" - fi - ac_success=yes - break - fi - done - fi - if test x$ac_success = xno; then - for alternative in ${ax_cxx_compile_alternatives}; do - for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" MSVC; do - if test x"$switch" = xMSVC; then - switch=-std:c++${alternative} - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_${switch}_MSVC" | $as_tr_sh` - else - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 -$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } -if eval \${$cachevar+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_save_CXX="$CXX" - CXX="$CXX $switch" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ +// If the compiler admits that it is not ready for C++14, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201402L && !defined _MSC_VER + +#error "This is not a C++14 compiler" + +#else + +namespace cxx14 +{ + + namespace test_polymorphic_lambdas + { + + int + test() + { + const auto lambda = [](auto&&... args){ + const auto istiny = [](auto x){ + return (sizeof(x) == 1UL) ? 1 : 0; + }; + const int aretiny[] = { istiny(args)... }; + return aretiny[0]; + }; + return lambda(1, 1L, 1.0f, '1'); + } + + } + + namespace test_binary_literals + { + + constexpr auto ivii = 0b0000000000101010; + static_assert(ivii == 42, "wrong value"); + + } + + namespace test_generalized_constexpr + { + + template < typename CharT > + constexpr unsigned long + strlen_c(const CharT *const s) noexcept + { + auto length = 0UL; + for (auto p = s; *p; ++p) + ++length; + return length; + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("x") == 1UL, ""); + static_assert(strlen_c("test") == 4UL, ""); + static_assert(strlen_c("another\0test") == 7UL, ""); + + } + + namespace test_lambda_init_capture + { + + int + test() + { + auto x = 0; + const auto lambda1 = [a = x](int b){ return a + b; }; + const auto lambda2 = [a = lambda1(x)](){ return a; }; + return lambda2(); + } + + } + + namespace test_digit_separators + { + + constexpr auto ten_million = 100'000'000; + static_assert(ten_million == 100000000, ""); + + } + + namespace test_return_type_deduction + { + + auto f(int& x) { return x; } + decltype(auto) g(int& x) { return x; } + + template < typename T1, typename T2 > + struct is_same + { + static constexpr auto value = false; + }; + + template < typename T > + struct is_same + { + static constexpr auto value = true; + }; + + int + test() + { + auto x = 0; + static_assert(is_same::value, ""); + static_assert(is_same::value, ""); + return x; + } + + } + +} // namespace cxx14 + +#endif // __cplusplus >= 201402L + + -// If the compiler admits that it is not ready for C++11, why torture it? +// If the compiler admits that it is not ready for C++17, why torture it? // Hopefully, this will speed up the test. #ifndef __cplusplus #error "This is not a C++ compiler" -// MSVC always sets __cplusplus to 199711L in older versions; newer versions -// only set it correctly if /Zc:__cplusplus is specified as well as a -// /std:c++NN switch: -// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ -#elif __cplusplus < 201103L && !defined _MSC_VER +#elif __cplusplus < 201703L && !defined _MSC_VER -#error "This is not a C++11 compiler" +#error "This is not a C++17 compiler" #else -namespace cxx11 +#include +#include +#include + +namespace cxx17 { - namespace test_static_assert + namespace test_constexpr_lambdas { - template - struct check - { - static_assert(sizeof(int) <= sizeof(T), "not big enough"); - }; + constexpr int foo = [](){return 42;}(); } - namespace test_final_override + namespace test::nested_namespace::definitions { - struct Base + } + + namespace test_fold_expression + { + + template + int multiply(Args... args) { - virtual ~Base() {} - virtual void f() {} - }; + return (args * ... * 1); + } - struct Derived : public Base + template + bool all(Args... args) { - virtual ~Derived() override {} - virtual void f() override {} - }; + return (args && ...); + } } - namespace test_double_right_angle_brackets + namespace test_extended_static_assert { - template < typename T > - struct check {}; + static_assert (true); - typedef check single_type; - typedef check> double_type; - typedef check>> triple_type; - typedef check>>> quadruple_type; + } + + namespace test_auto_brace_init_list + { + auto foo = {5}; + auto bar {5}; + + static_assert(std::is_same, decltype(foo)>::value); + static_assert(std::is_same::value); } - namespace test_decltype + namespace test_typename_in_template_template_parameter { - int - f() + template typename X> struct D; + + } + + namespace test_fallthrough_nodiscard_maybe_unused_attributes + { + + int f1() { - int a = 1; - decltype(a) b = 2; - return a + b; + return 42; + } + + [[nodiscard]] int f2() + { + [[maybe_unused]] auto unused = f1(); + + switch (f1()) + { + case 17: + f1(); + [[fallthrough]]; + case 42: + f1(); + } + return f1(); } } - namespace test_type_deduction + namespace test_extended_aggregate_initialization { - template < typename T1, typename T2 > - struct is_same + struct base1 { - static const bool value = false; + int b1, b2 = 42; }; - template < typename T > - struct is_same + struct base2 { - static const bool value = true; + base2() { + b3 = 42; + } + int b3; }; - template < typename T1, typename T2 > - auto - add(T1 a1, T2 a2) -> decltype(a1 + a2) + struct derived : base1, base2 { - return a1 + a2; - } + int d; + }; - int - test(const int c, volatile int v) - { - static_assert(is_same::value == true, ""); - static_assert(is_same::value == false, ""); - static_assert(is_same::value == false, ""); - auto ac = c; - auto av = v; - auto sumi = ac + av + 'x'; - auto sumf = ac + av + 1.0; - static_assert(is_same::value == true, ""); - static_assert(is_same::value == true, ""); - static_assert(is_same::value == true, ""); - static_assert(is_same::value == false, ""); - static_assert(is_same::value == true, ""); - return (sumf > 0.0) ? sumi : add(c, v); - } + derived d1 {{1, 2}, {}, 4}; // full initialization + derived d2 {{}, {}, 4}; // value-initialized bases } - namespace test_noexcept + namespace test_general_range_based_for_loop { - int f() { return 0; } - int g() noexcept { return 0; } + struct iter + { + int i; - static_assert(noexcept(f()) == false, ""); - static_assert(noexcept(g()) == true, ""); + int& operator* () + { + return i; + } - } + const int& operator* () const + { + return i; + } - namespace test_constexpr - { + iter& operator++() + { + ++i; + return *this; + } + }; - template < typename CharT > - unsigned long constexpr - strlen_c_r(const CharT *const s, const unsigned long acc) noexcept + struct sentinel { - return *s ? strlen_c_r(s + 1, acc + 1) : acc; + int i; + }; + + bool operator== (const iter& i, const sentinel& s) + { + return i.i == s.i; } - template < typename CharT > - unsigned long constexpr - strlen_c(const CharT *const s) noexcept + bool operator!= (const iter& i, const sentinel& s) { - return strlen_c_r(s, 0UL); + return !(i == s); } - static_assert(strlen_c("") == 0UL, ""); - static_assert(strlen_c("1") == 1UL, ""); - static_assert(strlen_c("example") == 7UL, ""); - static_assert(strlen_c("another\0example") == 7UL, ""); + struct range + { + iter begin() const + { + return {0}; + } + + sentinel end() const + { + return {5}; + } + }; + + void f() + { + range r {}; + + for (auto i : r) + { + [[maybe_unused]] auto v = i; + } + } } - namespace test_rvalue_references + namespace test_lambda_capture_asterisk_this_by_value { - template < int N > - struct answer + struct t { - static constexpr int value = N; + int i; + int foo() + { + return [*this]() + { + return i; + }(); + } }; - answer<1> f(int&) { return answer<1>(); } - answer<2> f(const int&) { return answer<2>(); } - answer<3> f(int&&) { return answer<3>(); } + } - void - test() - { - int i = 0; - const int c = 0; - static_assert(decltype(f(i))::value == 1, ""); - static_assert(decltype(f(c))::value == 2, ""); - static_assert(decltype(f(0))::value == 3, ""); - } + namespace test_enum_class_construction + { + + enum class byte : unsigned char + {}; + + byte foo {42}; } - namespace test_uniform_initialization + namespace test_constexpr_if { - struct test + template + int f () { - static const int zero {}; - static const int one {1}; - }; - - static_assert(test::zero == 0, ""); - static_assert(test::one == 1, ""); + if constexpr(cond) + { + return 13; + } + else + { + return 42; + } + } } - namespace test_lambdas + namespace test_selection_statement_with_initializer { - void - test1() + int f() { - auto lambda1 = [](){}; - auto lambda2 = lambda1; - lambda1(); - lambda2(); + return 13; } - int - test2() + int f2() { - auto a = [](int i, int j){ return i + j; }(1, 2); - auto b = []() -> int { return '0'; }(); - auto c = [=](){ return a + b; }(); - auto d = [&](){ return c; }(); - auto e = [a, &b](int x) mutable { - const auto identity = [](int y){ return y; }; - for (auto i = 0; i < a; ++i) - a += b--; - return x + identity(a + b); - }(0); - return a + b + c + d + e; + if (auto i = f(); i > 0) + { + return 3; + } + + switch (auto i = f(); i + 4) + { + case 17: + return 2; + + default: + return 1; + } } - int - test3() + } + + namespace test_template_argument_deduction_for_class_templates + { + + template + struct pair { - const auto nullary = [](){ return 0; }; - const auto unary = [](int x){ return x; }; - using nullary_t = decltype(nullary); - using unary_t = decltype(unary); - const auto higher1st = [](nullary_t f){ return f(); }; - const auto higher2nd = [unary](nullary_t f1){ - return [unary, f1](unary_t f2){ return f2(unary(f1())); }; - }; - return higher1st(nullary) + higher2nd(nullary)(unary); + pair (T1 p1, T2 p2) + : m1 {p1}, + m2 {p2} + {} + + T1 m1; + T2 m2; + }; + + void f() + { + [[maybe_unused]] auto p = pair{13, 42u}; } } - namespace test_variadic_templates + namespace test_non_type_auto_template_parameters { - template - struct sum; + template + struct B + {}; - template - struct sum + B<5> b1; + B<'a'> b2; + + } + + namespace test_structured_bindings + { + + int arr[2] = { 1, 2 }; + std::pair pr = { 1, 2 }; + + auto f1() -> int(&)[2] { - static constexpr auto value = N0 + sum::value; - }; + return arr; + } - template <> - struct sum<> + auto f2() -> std::pair& { - static constexpr auto value = 0; + return pr; + } + + struct S + { + int x1 : 2; + volatile double y1; }; - static_assert(sum<>::value == 0, ""); - static_assert(sum<1>::value == 1, ""); - static_assert(sum<23>::value == 23, ""); - static_assert(sum<1, 2>::value == 3, ""); - static_assert(sum<5, 5, 11>::value == 21, ""); - static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, ""); + S f3() + { + return {}; + } + + auto [ x1, y1 ] = f1(); + auto& [ xr1, yr1 ] = f1(); + auto [ x2, y2 ] = f2(); + auto& [ xr2, yr2 ] = f2(); + const auto [ x3, y3 ] = f3(); } - // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae - // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function - // because of this. - namespace test_template_alias_sfinae + namespace test_exception_spec_type_system { - struct foo {}; + struct Good {}; + struct Bad {}; - template - using member = typename T::member_type; + void g1() noexcept; + void g2(); template - void func(...) {} + Bad + f(T*, T*); - template - void func(member*) {} + template + Good + f(T1*, T2*); - void test(); + static_assert (std::is_same_v); - void test() { func(0); } + } + + namespace test_inline_variables + { + + template void f(T) + {} + + template inline T g(T) + { + return T{}; + } + + template<> inline void f<>(int) + {} + + template<> int g<>(int) + { + return 5; + } } -} // namespace cxx11 +} // namespace cxx17 -#endif // __cplusplus >= 201103L +#endif // __cplusplus < 201703L && !defined _MSC_VER @@ -17487,19 +18981,19 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu - if test x$ax_cxx_compile_cxx11_required = xtrue; then + if test x$ax_cxx_compile_cxx17_required = xtrue; then if test x$ac_success = xno; then - as_fn_error $? "*** A compiler with support for C++11 language features is required." "$LINENO" 5 + as_fn_error $? "*** A compiler with support for C++17 language features is required." "$LINENO" 5 fi fi if test x$ac_success = xno; then - HAVE_CXX11=0 - { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++11 support was found" >&5 -$as_echo "$as_me: No compiler with C++11 support was found" >&6;} + HAVE_CXX17=0 + { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++17 support was found" >&5 +$as_echo "$as_me: No compiler with C++17 support was found" >&6;} else - HAVE_CXX11=1 + HAVE_CXX17=1 -$as_echo "#define HAVE_CXX11 1" >>confdefs.h +$as_echo "#define HAVE_CXX17 1" >>confdefs.h fi diff --git a/gdb/configure.ac b/gdb/configure.ac index 3912b77b27f..43e5067e6ff 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -53,9 +53,9 @@ LT_INIT # link tests in the configure script. LT_OUTPUT -# We require a C++11 compiler. Check if one is available, and if +# We require a C++17 compiler. Check if one is available, and if # necessary, set CXX_DIALECT to some -std=xxx switch. -AX_CXX_COMPILE_STDCXX(11, , mandatory) +AX_CXX_COMPILE_STDCXX(17, , mandatory) # Dependency checking. ZW_CREATE_DEPDIR diff --git a/gdbserver/config.in b/gdbserver/config.in index 63876afcf85..ab507aa6f6a 100644 --- a/gdbserver/config.in +++ b/gdbserver/config.in @@ -28,8 +28,8 @@ /* Define to 1 if you have the header file. */ #undef HAVE_ARPA_INET_H -/* define if the compiler supports basic C++11 syntax */ -#undef HAVE_CXX11 +/* define if the compiler supports basic C++17 syntax */ +#undef HAVE_CXX17 /* Define to 1 if you have the declaration of `ADDR_NO_RANDOMIZE', and to 0 if you don't. */ diff --git a/gdbserver/configure b/gdbserver/configure index a49598fb682..c6b8d7803c4 100755 --- a/gdbserver/configure +++ b/gdbserver/configure @@ -669,7 +669,7 @@ ax_pthread_config SED ALLOCA CXX_DIALECT -HAVE_CXX11 +HAVE_CXX17 RANLIB AR INSTALL_DATA @@ -5007,10 +5007,10 @@ ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` -# We require a C++11 compiler. Check if one is available, and if +# We require a C++17 compiler. Check if one is available, and if # necessary, set CXX_DIALECT to some -std=xxx switch. - ax_cxx_compile_alternatives="11 0x" ax_cxx_compile_cxx11_required=true + ax_cxx_compile_alternatives="17 1z" ax_cxx_compile_cxx17_required=true ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -5019,9 +5019,9 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu CXX_DIALECT="" ac_success=no - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5 -$as_echo_n "checking whether $CXX supports C++11 features by default... " >&6; } -if ${ax_cv_cxx_compile_cxx11+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++17 features by default" >&5 +$as_echo_n "checking whether $CXX supports C++17 features by default... " >&6; } +if ${ax_cv_cxx_compile_cxx17+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -5318,32 +5318,1362 @@ namespace cxx11 + +// If the compiler admits that it is not ready for C++14, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201402L && !defined _MSC_VER + +#error "This is not a C++14 compiler" + +#else + +namespace cxx14 +{ + + namespace test_polymorphic_lambdas + { + + int + test() + { + const auto lambda = [](auto&&... args){ + const auto istiny = [](auto x){ + return (sizeof(x) == 1UL) ? 1 : 0; + }; + const int aretiny[] = { istiny(args)... }; + return aretiny[0]; + }; + return lambda(1, 1L, 1.0f, '1'); + } + + } + + namespace test_binary_literals + { + + constexpr auto ivii = 0b0000000000101010; + static_assert(ivii == 42, "wrong value"); + + } + + namespace test_generalized_constexpr + { + + template < typename CharT > + constexpr unsigned long + strlen_c(const CharT *const s) noexcept + { + auto length = 0UL; + for (auto p = s; *p; ++p) + ++length; + return length; + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("x") == 1UL, ""); + static_assert(strlen_c("test") == 4UL, ""); + static_assert(strlen_c("another\0test") == 7UL, ""); + + } + + namespace test_lambda_init_capture + { + + int + test() + { + auto x = 0; + const auto lambda1 = [a = x](int b){ return a + b; }; + const auto lambda2 = [a = lambda1(x)](){ return a; }; + return lambda2(); + } + + } + + namespace test_digit_separators + { + + constexpr auto ten_million = 100'000'000; + static_assert(ten_million == 100000000, ""); + + } + + namespace test_return_type_deduction + { + + auto f(int& x) { return x; } + decltype(auto) g(int& x) { return x; } + + template < typename T1, typename T2 > + struct is_same + { + static constexpr auto value = false; + }; + + template < typename T > + struct is_same + { + static constexpr auto value = true; + }; + + int + test() + { + auto x = 0; + static_assert(is_same::value, ""); + static_assert(is_same::value, ""); + return x; + } + + } + +} // namespace cxx14 + +#endif // __cplusplus >= 201402L + + + + +// If the compiler admits that it is not ready for C++17, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201703L && !defined _MSC_VER + +#error "This is not a C++17 compiler" + +#else + +#include +#include +#include + +namespace cxx17 +{ + + namespace test_constexpr_lambdas + { + + constexpr int foo = [](){return 42;}(); + + } + + namespace test::nested_namespace::definitions + { + + } + + namespace test_fold_expression + { + + template + int multiply(Args... args) + { + return (args * ... * 1); + } + + template + bool all(Args... args) + { + return (args && ...); + } + + } + + namespace test_extended_static_assert + { + + static_assert (true); + + } + + namespace test_auto_brace_init_list + { + + auto foo = {5}; + auto bar {5}; + + static_assert(std::is_same, decltype(foo)>::value); + static_assert(std::is_same::value); + } + + namespace test_typename_in_template_template_parameter + { + + template typename X> struct D; + + } + + namespace test_fallthrough_nodiscard_maybe_unused_attributes + { + + int f1() + { + return 42; + } + + [[nodiscard]] int f2() + { + [[maybe_unused]] auto unused = f1(); + + switch (f1()) + { + case 17: + f1(); + [[fallthrough]]; + case 42: + f1(); + } + return f1(); + } + + } + + namespace test_extended_aggregate_initialization + { + + struct base1 + { + int b1, b2 = 42; + }; + + struct base2 + { + base2() { + b3 = 42; + } + int b3; + }; + + struct derived : base1, base2 + { + int d; + }; + + derived d1 {{1, 2}, {}, 4}; // full initialization + derived d2 {{}, {}, 4}; // value-initialized bases + + } + + namespace test_general_range_based_for_loop + { + + struct iter + { + int i; + + int& operator* () + { + return i; + } + + const int& operator* () const + { + return i; + } + + iter& operator++() + { + ++i; + return *this; + } + }; + + struct sentinel + { + int i; + }; + + bool operator== (const iter& i, const sentinel& s) + { + return i.i == s.i; + } + + bool operator!= (const iter& i, const sentinel& s) + { + return !(i == s); + } + + struct range + { + iter begin() const + { + return {0}; + } + + sentinel end() const + { + return {5}; + } + }; + + void f() + { + range r {}; + + for (auto i : r) + { + [[maybe_unused]] auto v = i; + } + } + + } + + namespace test_lambda_capture_asterisk_this_by_value + { + + struct t + { + int i; + int foo() + { + return [*this]() + { + return i; + }(); + } + }; + + } + + namespace test_enum_class_construction + { + + enum class byte : unsigned char + {}; + + byte foo {42}; + + } + + namespace test_constexpr_if + { + + template + int f () + { + if constexpr(cond) + { + return 13; + } + else + { + return 42; + } + } + + } + + namespace test_selection_statement_with_initializer + { + + int f() + { + return 13; + } + + int f2() + { + if (auto i = f(); i > 0) + { + return 3; + } + + switch (auto i = f(); i + 4) + { + case 17: + return 2; + + default: + return 1; + } + } + + } + + namespace test_template_argument_deduction_for_class_templates + { + + template + struct pair + { + pair (T1 p1, T2 p2) + : m1 {p1}, + m2 {p2} + {} + + T1 m1; + T2 m2; + }; + + void f() + { + [[maybe_unused]] auto p = pair{13, 42u}; + } + + } + + namespace test_non_type_auto_template_parameters + { + + template + struct B + {}; + + B<5> b1; + B<'a'> b2; + + } + + namespace test_structured_bindings + { + + int arr[2] = { 1, 2 }; + std::pair pr = { 1, 2 }; + + auto f1() -> int(&)[2] + { + return arr; + } + + auto f2() -> std::pair& + { + return pr; + } + + struct S + { + int x1 : 2; + volatile double y1; + }; + + S f3() + { + return {}; + } + + auto [ x1, y1 ] = f1(); + auto& [ xr1, yr1 ] = f1(); + auto [ x2, y2 ] = f2(); + auto& [ xr2, yr2 ] = f2(); + const auto [ x3, y3 ] = f3(); + + } + + namespace test_exception_spec_type_system + { + + struct Good {}; + struct Bad {}; + + void g1() noexcept; + void g2(); + + template + Bad + f(T*, T*); + + template + Good + f(T1*, T2*); + + static_assert (std::is_same_v); + + } + + namespace test_inline_variables + { + + template void f(T) + {} + + template inline T g(T) + { + return T{}; + } + + template<> inline void f<>(int) + {} + + template<> int g<>(int) + { + return 5; + } + + } + +} // namespace cxx17 + +#endif // __cplusplus < 201703L && !defined _MSC_VER + + + +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ax_cv_cxx_compile_cxx17=yes +else + ax_cv_cxx_compile_cxx17=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx17" >&5 +$as_echo "$ax_cv_cxx_compile_cxx17" >&6; } + if test x$ax_cv_cxx_compile_cxx17 = xyes; then + ac_success=yes + fi + + if test x$ac_success = xno; then + for alternative in ${ax_cxx_compile_alternatives}; do + switch="-std=gnu++${alternative}" + cachevar=`$as_echo "ax_cv_cxx_compile_cxx17_$switch" | $as_tr_sh` + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++17 features with $switch" >&5 +$as_echo_n "checking whether $CXX supports C++17 features with $switch... " >&6; } +if eval \${$cachevar+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_CXX="$CXX" + CXX="$CXX $switch" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +// If the compiler admits that it is not ready for C++11, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +// MSVC always sets __cplusplus to 199711L in older versions; newer versions +// only set it correctly if /Zc:__cplusplus is specified as well as a +// /std:c++NN switch: +// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ +#elif __cplusplus < 201103L && !defined _MSC_VER + +#error "This is not a C++11 compiler" + +#else + +namespace cxx11 +{ + + namespace test_static_assert + { + + template + struct check + { + static_assert(sizeof(int) <= sizeof(T), "not big enough"); + }; + + } + + namespace test_final_override + { + + struct Base + { + virtual ~Base() {} + virtual void f() {} + }; + + struct Derived : public Base + { + virtual ~Derived() override {} + virtual void f() override {} + }; + + } + + namespace test_double_right_angle_brackets + { + + template < typename T > + struct check {}; + + typedef check single_type; + typedef check> double_type; + typedef check>> triple_type; + typedef check>>> quadruple_type; + + } + + namespace test_decltype + { + + int + f() + { + int a = 1; + decltype(a) b = 2; + return a + b; + } + + } + + namespace test_type_deduction + { + + template < typename T1, typename T2 > + struct is_same + { + static const bool value = false; + }; + + template < typename T > + struct is_same + { + static const bool value = true; + }; + + template < typename T1, typename T2 > + auto + add(T1 a1, T2 a2) -> decltype(a1 + a2) + { + return a1 + a2; + } + + int + test(const int c, volatile int v) + { + static_assert(is_same::value == true, ""); + static_assert(is_same::value == false, ""); + static_assert(is_same::value == false, ""); + auto ac = c; + auto av = v; + auto sumi = ac + av + 'x'; + auto sumf = ac + av + 1.0; + static_assert(is_same::value == true, ""); + static_assert(is_same::value == true, ""); + static_assert(is_same::value == true, ""); + static_assert(is_same::value == false, ""); + static_assert(is_same::value == true, ""); + return (sumf > 0.0) ? sumi : add(c, v); + } + + } + + namespace test_noexcept + { + + int f() { return 0; } + int g() noexcept { return 0; } + + static_assert(noexcept(f()) == false, ""); + static_assert(noexcept(g()) == true, ""); + + } + + namespace test_constexpr + { + + template < typename CharT > + unsigned long constexpr + strlen_c_r(const CharT *const s, const unsigned long acc) noexcept + { + return *s ? strlen_c_r(s + 1, acc + 1) : acc; + } + + template < typename CharT > + unsigned long constexpr + strlen_c(const CharT *const s) noexcept + { + return strlen_c_r(s, 0UL); + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("1") == 1UL, ""); + static_assert(strlen_c("example") == 7UL, ""); + static_assert(strlen_c("another\0example") == 7UL, ""); + + } + + namespace test_rvalue_references + { + + template < int N > + struct answer + { + static constexpr int value = N; + }; + + answer<1> f(int&) { return answer<1>(); } + answer<2> f(const int&) { return answer<2>(); } + answer<3> f(int&&) { return answer<3>(); } + + void + test() + { + int i = 0; + const int c = 0; + static_assert(decltype(f(i))::value == 1, ""); + static_assert(decltype(f(c))::value == 2, ""); + static_assert(decltype(f(0))::value == 3, ""); + } + + } + + namespace test_uniform_initialization + { + + struct test + { + static const int zero {}; + static const int one {1}; + }; + + static_assert(test::zero == 0, ""); + static_assert(test::one == 1, ""); + + } + + namespace test_lambdas + { + + void + test1() + { + auto lambda1 = [](){}; + auto lambda2 = lambda1; + lambda1(); + lambda2(); + } + + int + test2() + { + auto a = [](int i, int j){ return i + j; }(1, 2); + auto b = []() -> int { return '0'; }(); + auto c = [=](){ return a + b; }(); + auto d = [&](){ return c; }(); + auto e = [a, &b](int x) mutable { + const auto identity = [](int y){ return y; }; + for (auto i = 0; i < a; ++i) + a += b--; + return x + identity(a + b); + }(0); + return a + b + c + d + e; + } + + int + test3() + { + const auto nullary = [](){ return 0; }; + const auto unary = [](int x){ return x; }; + using nullary_t = decltype(nullary); + using unary_t = decltype(unary); + const auto higher1st = [](nullary_t f){ return f(); }; + const auto higher2nd = [unary](nullary_t f1){ + return [unary, f1](unary_t f2){ return f2(unary(f1())); }; + }; + return higher1st(nullary) + higher2nd(nullary)(unary); + } + + } + + namespace test_variadic_templates + { + + template + struct sum; + + template + struct sum + { + static constexpr auto value = N0 + sum::value; + }; + + template <> + struct sum<> + { + static constexpr auto value = 0; + }; + + static_assert(sum<>::value == 0, ""); + static_assert(sum<1>::value == 1, ""); + static_assert(sum<23>::value == 23, ""); + static_assert(sum<1, 2>::value == 3, ""); + static_assert(sum<5, 5, 11>::value == 21, ""); + static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, ""); + + } + + // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae + // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function + // because of this. + namespace test_template_alias_sfinae + { + + struct foo {}; + + template + using member = typename T::member_type; + + template + void func(...) {} + + template + void func(member*) {} + + void test(); + + void test() { func(0); } + + } + +} // namespace cxx11 + +#endif // __cplusplus >= 201103L + + + + +// If the compiler admits that it is not ready for C++14, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201402L && !defined _MSC_VER + +#error "This is not a C++14 compiler" + +#else + +namespace cxx14 +{ + + namespace test_polymorphic_lambdas + { + + int + test() + { + const auto lambda = [](auto&&... args){ + const auto istiny = [](auto x){ + return (sizeof(x) == 1UL) ? 1 : 0; + }; + const int aretiny[] = { istiny(args)... }; + return aretiny[0]; + }; + return lambda(1, 1L, 1.0f, '1'); + } + + } + + namespace test_binary_literals + { + + constexpr auto ivii = 0b0000000000101010; + static_assert(ivii == 42, "wrong value"); + + } + + namespace test_generalized_constexpr + { + + template < typename CharT > + constexpr unsigned long + strlen_c(const CharT *const s) noexcept + { + auto length = 0UL; + for (auto p = s; *p; ++p) + ++length; + return length; + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("x") == 1UL, ""); + static_assert(strlen_c("test") == 4UL, ""); + static_assert(strlen_c("another\0test") == 7UL, ""); + + } + + namespace test_lambda_init_capture + { + + int + test() + { + auto x = 0; + const auto lambda1 = [a = x](int b){ return a + b; }; + const auto lambda2 = [a = lambda1(x)](){ return a; }; + return lambda2(); + } + + } + + namespace test_digit_separators + { + + constexpr auto ten_million = 100'000'000; + static_assert(ten_million == 100000000, ""); + + } + + namespace test_return_type_deduction + { + + auto f(int& x) { return x; } + decltype(auto) g(int& x) { return x; } + + template < typename T1, typename T2 > + struct is_same + { + static constexpr auto value = false; + }; + + template < typename T > + struct is_same + { + static constexpr auto value = true; + }; + + int + test() + { + auto x = 0; + static_assert(is_same::value, ""); + static_assert(is_same::value, ""); + return x; + } + + } + +} // namespace cxx14 + +#endif // __cplusplus >= 201402L + + + + +// If the compiler admits that it is not ready for C++17, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201703L && !defined _MSC_VER + +#error "This is not a C++17 compiler" + +#else + +#include +#include +#include + +namespace cxx17 +{ + + namespace test_constexpr_lambdas + { + + constexpr int foo = [](){return 42;}(); + + } + + namespace test::nested_namespace::definitions + { + + } + + namespace test_fold_expression + { + + template + int multiply(Args... args) + { + return (args * ... * 1); + } + + template + bool all(Args... args) + { + return (args && ...); + } + + } + + namespace test_extended_static_assert + { + + static_assert (true); + + } + + namespace test_auto_brace_init_list + { + + auto foo = {5}; + auto bar {5}; + + static_assert(std::is_same, decltype(foo)>::value); + static_assert(std::is_same::value); + } + + namespace test_typename_in_template_template_parameter + { + + template typename X> struct D; + + } + + namespace test_fallthrough_nodiscard_maybe_unused_attributes + { + + int f1() + { + return 42; + } + + [[nodiscard]] int f2() + { + [[maybe_unused]] auto unused = f1(); + + switch (f1()) + { + case 17: + f1(); + [[fallthrough]]; + case 42: + f1(); + } + return f1(); + } + + } + + namespace test_extended_aggregate_initialization + { + + struct base1 + { + int b1, b2 = 42; + }; + + struct base2 + { + base2() { + b3 = 42; + } + int b3; + }; + + struct derived : base1, base2 + { + int d; + }; + + derived d1 {{1, 2}, {}, 4}; // full initialization + derived d2 {{}, {}, 4}; // value-initialized bases + + } + + namespace test_general_range_based_for_loop + { + + struct iter + { + int i; + + int& operator* () + { + return i; + } + + const int& operator* () const + { + return i; + } + + iter& operator++() + { + ++i; + return *this; + } + }; + + struct sentinel + { + int i; + }; + + bool operator== (const iter& i, const sentinel& s) + { + return i.i == s.i; + } + + bool operator!= (const iter& i, const sentinel& s) + { + return !(i == s); + } + + struct range + { + iter begin() const + { + return {0}; + } + + sentinel end() const + { + return {5}; + } + }; + + void f() + { + range r {}; + + for (auto i : r) + { + [[maybe_unused]] auto v = i; + } + } + + } + + namespace test_lambda_capture_asterisk_this_by_value + { + + struct t + { + int i; + int foo() + { + return [*this]() + { + return i; + }(); + } + }; + + } + + namespace test_enum_class_construction + { + + enum class byte : unsigned char + {}; + + byte foo {42}; + + } + + namespace test_constexpr_if + { + + template + int f () + { + if constexpr(cond) + { + return 13; + } + else + { + return 42; + } + } + + } + + namespace test_selection_statement_with_initializer + { + + int f() + { + return 13; + } + + int f2() + { + if (auto i = f(); i > 0) + { + return 3; + } + + switch (auto i = f(); i + 4) + { + case 17: + return 2; + + default: + return 1; + } + } + + } + + namespace test_template_argument_deduction_for_class_templates + { + + template + struct pair + { + pair (T1 p1, T2 p2) + : m1 {p1}, + m2 {p2} + {} + + T1 m1; + T2 m2; + }; + + void f() + { + [[maybe_unused]] auto p = pair{13, 42u}; + } + + } + + namespace test_non_type_auto_template_parameters + { + + template + struct B + {}; + + B<5> b1; + B<'a'> b2; + + } + + namespace test_structured_bindings + { + + int arr[2] = { 1, 2 }; + std::pair pr = { 1, 2 }; + + auto f1() -> int(&)[2] + { + return arr; + } + + auto f2() -> std::pair& + { + return pr; + } + + struct S + { + int x1 : 2; + volatile double y1; + }; + + S f3() + { + return {}; + } + + auto [ x1, y1 ] = f1(); + auto& [ xr1, yr1 ] = f1(); + auto [ x2, y2 ] = f2(); + auto& [ xr2, yr2 ] = f2(); + const auto [ x3, y3 ] = f3(); + + } + + namespace test_exception_spec_type_system + { + + struct Good {}; + struct Bad {}; + + void g1() noexcept; + void g2(); + + template + Bad + f(T*, T*); + + template + Good + f(T1*, T2*); + + static_assert (std::is_same_v); + + } + + namespace test_inline_variables + { + + template void f(T) + {} + + template inline T g(T) + { + return T{}; + } + + template<> inline void f<>(int) + {} + + template<> int g<>(int) + { + return 5; + } + + } + +} // namespace cxx17 + +#endif // __cplusplus < 201703L && !defined _MSC_VER + + + _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : - ax_cv_cxx_compile_cxx11=yes + eval $cachevar=yes else - ax_cv_cxx_compile_cxx11=no + eval $cachevar=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CXX="$ac_save_CXX" fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11" >&5 -$as_echo "$ax_cv_cxx_compile_cxx11" >&6; } - if test x$ax_cv_cxx_compile_cxx11 = xyes; then - ac_success=yes - fi +eval ac_res=\$$cachevar + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + if eval test x\$$cachevar = xyes; then + CXX_DIALECT="$switch" + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi + ac_success=yes + break + fi + done + fi if test x$ac_success = xno; then - for alternative in ${ax_cxx_compile_alternatives}; do - switch="-std=gnu++${alternative}" - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 -$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } + for alternative in ${ax_cxx_compile_alternatives}; do + for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" MSVC; do + if test x"$switch" = xMSVC; then + switch=-std:c++${alternative} + cachevar=`$as_echo "ax_cv_cxx_compile_cxx17_${switch}_MSVC" | $as_tr_sh` + else + cachevar=`$as_echo "ax_cv_cxx_compile_cxx17_$switch" | $as_tr_sh` + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++17 features with $switch" >&5 +$as_echo_n "checking whether $CXX supports C++17 features with $switch... " >&6; } if eval \${$cachevar+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_CXX="$CXX" - CXX="$CXX $switch" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + CXX="$CXX $switch" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -5637,337 +6967,501 @@ namespace cxx11 -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - eval $cachevar=yes -else - eval $cachevar=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CXX="$ac_save_CXX" -fi -eval ac_res=\$$cachevar - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - if eval test x\$$cachevar = xyes; then - CXX_DIALECT="$switch" - CXX="$CXX $switch" - if test -n "$CXXCPP" ; then - CXXCPP="$CXXCPP $switch" - fi - ac_success=yes - break - fi - done - fi - if test x$ac_success = xno; then - for alternative in ${ax_cxx_compile_alternatives}; do - for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" MSVC; do - if test x"$switch" = xMSVC; then - switch=-std:c++${alternative} - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_${switch}_MSVC" | $as_tr_sh` - else - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 -$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } -if eval \${$cachevar+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_save_CXX="$CXX" - CXX="$CXX $switch" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ +// If the compiler admits that it is not ready for C++14, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201402L && !defined _MSC_VER + +#error "This is not a C++14 compiler" + +#else + +namespace cxx14 +{ + + namespace test_polymorphic_lambdas + { + + int + test() + { + const auto lambda = [](auto&&... args){ + const auto istiny = [](auto x){ + return (sizeof(x) == 1UL) ? 1 : 0; + }; + const int aretiny[] = { istiny(args)... }; + return aretiny[0]; + }; + return lambda(1, 1L, 1.0f, '1'); + } + + } + + namespace test_binary_literals + { + + constexpr auto ivii = 0b0000000000101010; + static_assert(ivii == 42, "wrong value"); + + } + + namespace test_generalized_constexpr + { + + template < typename CharT > + constexpr unsigned long + strlen_c(const CharT *const s) noexcept + { + auto length = 0UL; + for (auto p = s; *p; ++p) + ++length; + return length; + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("x") == 1UL, ""); + static_assert(strlen_c("test") == 4UL, ""); + static_assert(strlen_c("another\0test") == 7UL, ""); + + } + + namespace test_lambda_init_capture + { + + int + test() + { + auto x = 0; + const auto lambda1 = [a = x](int b){ return a + b; }; + const auto lambda2 = [a = lambda1(x)](){ return a; }; + return lambda2(); + } + + } + + namespace test_digit_separators + { + + constexpr auto ten_million = 100'000'000; + static_assert(ten_million == 100000000, ""); + + } + + namespace test_return_type_deduction + { + + auto f(int& x) { return x; } + decltype(auto) g(int& x) { return x; } + + template < typename T1, typename T2 > + struct is_same + { + static constexpr auto value = false; + }; + + template < typename T > + struct is_same + { + static constexpr auto value = true; + }; + + int + test() + { + auto x = 0; + static_assert(is_same::value, ""); + static_assert(is_same::value, ""); + return x; + } + + } +} // namespace cxx14 -// If the compiler admits that it is not ready for C++11, why torture it? +#endif // __cplusplus >= 201402L + + + + +// If the compiler admits that it is not ready for C++17, why torture it? // Hopefully, this will speed up the test. #ifndef __cplusplus #error "This is not a C++ compiler" -// MSVC always sets __cplusplus to 199711L in older versions; newer versions -// only set it correctly if /Zc:__cplusplus is specified as well as a -// /std:c++NN switch: -// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ -#elif __cplusplus < 201103L && !defined _MSC_VER +#elif __cplusplus < 201703L && !defined _MSC_VER -#error "This is not a C++11 compiler" +#error "This is not a C++17 compiler" #else -namespace cxx11 +#include +#include +#include + +namespace cxx17 { - namespace test_static_assert + namespace test_constexpr_lambdas { - template - struct check - { - static_assert(sizeof(int) <= sizeof(T), "not big enough"); - }; + constexpr int foo = [](){return 42;}(); } - namespace test_final_override + namespace test::nested_namespace::definitions { - struct Base + } + + namespace test_fold_expression + { + + template + int multiply(Args... args) { - virtual ~Base() {} - virtual void f() {} - }; + return (args * ... * 1); + } - struct Derived : public Base + template + bool all(Args... args) { - virtual ~Derived() override {} - virtual void f() override {} - }; + return (args && ...); + } } - namespace test_double_right_angle_brackets + namespace test_extended_static_assert { - template < typename T > - struct check {}; + static_assert (true); - typedef check single_type; - typedef check> double_type; - typedef check>> triple_type; - typedef check>>> quadruple_type; + } + + namespace test_auto_brace_init_list + { + auto foo = {5}; + auto bar {5}; + + static_assert(std::is_same, decltype(foo)>::value); + static_assert(std::is_same::value); } - namespace test_decltype + namespace test_typename_in_template_template_parameter { - int - f() + template typename X> struct D; + + } + + namespace test_fallthrough_nodiscard_maybe_unused_attributes + { + + int f1() { - int a = 1; - decltype(a) b = 2; - return a + b; + return 42; + } + + [[nodiscard]] int f2() + { + [[maybe_unused]] auto unused = f1(); + + switch (f1()) + { + case 17: + f1(); + [[fallthrough]]; + case 42: + f1(); + } + return f1(); } } - namespace test_type_deduction + namespace test_extended_aggregate_initialization { - template < typename T1, typename T2 > - struct is_same + struct base1 { - static const bool value = false; + int b1, b2 = 42; }; - template < typename T > - struct is_same + struct base2 { - static const bool value = true; + base2() { + b3 = 42; + } + int b3; }; - template < typename T1, typename T2 > - auto - add(T1 a1, T2 a2) -> decltype(a1 + a2) + struct derived : base1, base2 { - return a1 + a2; + int d; + }; + + derived d1 {{1, 2}, {}, 4}; // full initialization + derived d2 {{}, {}, 4}; // value-initialized bases + + } + + namespace test_general_range_based_for_loop + { + + struct iter + { + int i; + + int& operator* () + { + return i; + } + + const int& operator* () const + { + return i; + } + + iter& operator++() + { + ++i; + return *this; + } + }; + + struct sentinel + { + int i; + }; + + bool operator== (const iter& i, const sentinel& s) + { + return i.i == s.i; } - int - test(const int c, volatile int v) + bool operator!= (const iter& i, const sentinel& s) { - static_assert(is_same::value == true, ""); - static_assert(is_same::value == false, ""); - static_assert(is_same::value == false, ""); - auto ac = c; - auto av = v; - auto sumi = ac + av + 'x'; - auto sumf = ac + av + 1.0; - static_assert(is_same::value == true, ""); - static_assert(is_same::value == true, ""); - static_assert(is_same::value == true, ""); - static_assert(is_same::value == false, ""); - static_assert(is_same::value == true, ""); - return (sumf > 0.0) ? sumi : add(c, v); + return !(i == s); + } + + struct range + { + iter begin() const + { + return {0}; + } + + sentinel end() const + { + return {5}; + } + }; + + void f() + { + range r {}; + + for (auto i : r) + { + [[maybe_unused]] auto v = i; + } } } - namespace test_noexcept + namespace test_lambda_capture_asterisk_this_by_value { - int f() { return 0; } - int g() noexcept { return 0; } + struct t + { + int i; + int foo() + { + return [*this]() + { + return i; + }(); + } + }; - static_assert(noexcept(f()) == false, ""); - static_assert(noexcept(g()) == true, ""); + } + + namespace test_enum_class_construction + { + + enum class byte : unsigned char + {}; + + byte foo {42}; } - namespace test_constexpr + namespace test_constexpr_if { - template < typename CharT > - unsigned long constexpr - strlen_c_r(const CharT *const s, const unsigned long acc) noexcept + template + int f () { - return *s ? strlen_c_r(s + 1, acc + 1) : acc; + if constexpr(cond) + { + return 13; + } + else + { + return 42; + } } - template < typename CharT > - unsigned long constexpr - strlen_c(const CharT *const s) noexcept + } + + namespace test_selection_statement_with_initializer + { + + int f() { - return strlen_c_r(s, 0UL); + return 13; } - static_assert(strlen_c("") == 0UL, ""); - static_assert(strlen_c("1") == 1UL, ""); - static_assert(strlen_c("example") == 7UL, ""); - static_assert(strlen_c("another\0example") == 7UL, ""); + int f2() + { + if (auto i = f(); i > 0) + { + return 3; + } + + switch (auto i = f(); i + 4) + { + case 17: + return 2; + + default: + return 1; + } + } } - namespace test_rvalue_references + namespace test_template_argument_deduction_for_class_templates { - template < int N > - struct answer + template + struct pair { - static constexpr int value = N; - }; + pair (T1 p1, T2 p2) + : m1 {p1}, + m2 {p2} + {} - answer<1> f(int&) { return answer<1>(); } - answer<2> f(const int&) { return answer<2>(); } - answer<3> f(int&&) { return answer<3>(); } + T1 m1; + T2 m2; + }; - void - test() + void f() { - int i = 0; - const int c = 0; - static_assert(decltype(f(i))::value == 1, ""); - static_assert(decltype(f(c))::value == 2, ""); - static_assert(decltype(f(0))::value == 3, ""); + [[maybe_unused]] auto p = pair{13, 42u}; } } - namespace test_uniform_initialization + namespace test_non_type_auto_template_parameters { - struct test - { - static const int zero {}; - static const int one {1}; - }; + template + struct B + {}; - static_assert(test::zero == 0, ""); - static_assert(test::one == 1, ""); + B<5> b1; + B<'a'> b2; } - namespace test_lambdas + namespace test_structured_bindings { - void - test1() + int arr[2] = { 1, 2 }; + std::pair pr = { 1, 2 }; + + auto f1() -> int(&)[2] { - auto lambda1 = [](){}; - auto lambda2 = lambda1; - lambda1(); - lambda2(); + return arr; } - int - test2() + auto f2() -> std::pair& { - auto a = [](int i, int j){ return i + j; }(1, 2); - auto b = []() -> int { return '0'; }(); - auto c = [=](){ return a + b; }(); - auto d = [&](){ return c; }(); - auto e = [a, &b](int x) mutable { - const auto identity = [](int y){ return y; }; - for (auto i = 0; i < a; ++i) - a += b--; - return x + identity(a + b); - }(0); - return a + b + c + d + e; + return pr; } - int - test3() + struct S { - const auto nullary = [](){ return 0; }; - const auto unary = [](int x){ return x; }; - using nullary_t = decltype(nullary); - using unary_t = decltype(unary); - const auto higher1st = [](nullary_t f){ return f(); }; - const auto higher2nd = [unary](nullary_t f1){ - return [unary, f1](unary_t f2){ return f2(unary(f1())); }; - }; - return higher1st(nullary) + higher2nd(nullary)(unary); + int x1 : 2; + volatile double y1; + }; + + S f3() + { + return {}; } + auto [ x1, y1 ] = f1(); + auto& [ xr1, yr1 ] = f1(); + auto [ x2, y2 ] = f2(); + auto& [ xr2, yr2 ] = f2(); + const auto [ x3, y3 ] = f3(); + } - namespace test_variadic_templates + namespace test_exception_spec_type_system { - template - struct sum; + struct Good {}; + struct Bad {}; - template - struct sum - { - static constexpr auto value = N0 + sum::value; - }; + void g1() noexcept; + void g2(); - template <> - struct sum<> - { - static constexpr auto value = 0; - }; + template + Bad + f(T*, T*); - static_assert(sum<>::value == 0, ""); - static_assert(sum<1>::value == 1, ""); - static_assert(sum<23>::value == 23, ""); - static_assert(sum<1, 2>::value == 3, ""); - static_assert(sum<5, 5, 11>::value == 21, ""); - static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, ""); + template + Good + f(T1*, T2*); + + static_assert (std::is_same_v); } - // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae - // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function - // because of this. - namespace test_template_alias_sfinae + namespace test_inline_variables { - struct foo {}; - - template - using member = typename T::member_type; - - template - void func(...) {} + template void f(T) + {} - template - void func(member*) {} + template inline T g(T) + { + return T{}; + } - void test(); + template<> inline void f<>(int) + {} - void test() { func(0); } + template<> int g<>(int) + { + return 5; + } } -} // namespace cxx11 +} // namespace cxx17 -#endif // __cplusplus >= 201103L +#endif // __cplusplus < 201703L && !defined _MSC_VER @@ -6004,19 +7498,19 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu - if test x$ax_cxx_compile_cxx11_required = xtrue; then + if test x$ax_cxx_compile_cxx17_required = xtrue; then if test x$ac_success = xno; then - as_fn_error $? "*** A compiler with support for C++11 language features is required." "$LINENO" 5 + as_fn_error $? "*** A compiler with support for C++17 language features is required." "$LINENO" 5 fi fi if test x$ac_success = xno; then - HAVE_CXX11=0 - { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++11 support was found" >&5 -$as_echo "$as_me: No compiler with C++11 support was found" >&6;} + HAVE_CXX17=0 + { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++17 support was found" >&5 +$as_echo "$as_me: No compiler with C++17 support was found" >&6;} else - HAVE_CXX11=1 + HAVE_CXX17=1 -$as_echo "#define HAVE_CXX11 1" >>confdefs.h +$as_echo "#define HAVE_CXX17 1" >>confdefs.h fi diff --git a/gdbserver/configure.ac b/gdbserver/configure.ac index 12bc0090d67..2609a11e6f6 100644 --- a/gdbserver/configure.ac +++ b/gdbserver/configure.ac @@ -46,9 +46,9 @@ AC_PROG_RANLIB AC_ARG_PROGRAM -# We require a C++11 compiler. Check if one is available, and if +# We require a C++17 compiler. Check if one is available, and if # necessary, set CXX_DIALECT to some -std=xxx switch. -AX_CXX_COMPILE_STDCXX(11, , mandatory) +AX_CXX_COMPILE_STDCXX(17, , mandatory) AC_HEADER_STDC diff --git a/gdbsupport/Makefile.in b/gdbsupport/Makefile.in index 07cb78fc4c7..50a5a55e19d 100644 --- a/gdbsupport/Makefile.in +++ b/gdbsupport/Makefile.in @@ -252,7 +252,7 @@ EXEEXT = @EXEEXT@ GENCAT = @GENCAT@ GMSGFMT = @GMSGFMT@ GREP = @GREP@ -HAVE_CXX11 = @HAVE_CXX11@ +HAVE_CXX17 = @HAVE_CXX17@ HAVE_LIBIPT = @HAVE_LIBIPT@ HAVE_LIBXXHASH = @HAVE_LIBXXHASH@ INCINTL = @INCINTL@ diff --git a/gdbsupport/config.in b/gdbsupport/config.in index 2cdc1fbde61..1cef12634bd 100644 --- a/gdbsupport/config.in +++ b/gdbsupport/config.in @@ -28,8 +28,8 @@ */ #undef HAVE_ALLOCA_H -/* define if the compiler supports basic C++11 syntax */ -#undef HAVE_CXX11 +/* define if the compiler supports basic C++17 syntax */ +#undef HAVE_CXX17 /* Define to 1 if you have the declaration of `ADDR_NO_RANDOMIZE', and to 0 if you don't. */ diff --git a/gdbsupport/configure b/gdbsupport/configure index 6d2a4309d7e..0ef3d25a10b 100755 --- a/gdbsupport/configure +++ b/gdbsupport/configure @@ -656,7 +656,7 @@ LIBINTL_DEP LIBINTL USE_NLS CXX_DIALECT -HAVE_CXX11 +HAVE_CXX17 LARGEFILE_CPPFLAGS EGREP GREP @@ -5905,10 +5905,10 @@ fi -# We require a C++11 compiler. Check if one is available, and if +# We require a C++17 compiler. Check if one is available, and if # necessary, set CXX_DIALECT to some -std=xxx switch. - ax_cxx_compile_alternatives="11 0x" ax_cxx_compile_cxx11_required=true + ax_cxx_compile_alternatives="17 1z" ax_cxx_compile_cxx17_required=true ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -5917,9 +5917,9 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu CXX_DIALECT="" ac_success=no - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5 -$as_echo_n "checking whether $CXX supports C++11 features by default... " >&6; } -if ${ax_cv_cxx_compile_cxx11+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++17 features by default" >&5 +$as_echo_n "checking whether $CXX supports C++17 features by default... " >&6; } +if ${ax_cv_cxx_compile_cxx17+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -6216,32 +6216,1362 @@ namespace cxx11 + +// If the compiler admits that it is not ready for C++14, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201402L && !defined _MSC_VER + +#error "This is not a C++14 compiler" + +#else + +namespace cxx14 +{ + + namespace test_polymorphic_lambdas + { + + int + test() + { + const auto lambda = [](auto&&... args){ + const auto istiny = [](auto x){ + return (sizeof(x) == 1UL) ? 1 : 0; + }; + const int aretiny[] = { istiny(args)... }; + return aretiny[0]; + }; + return lambda(1, 1L, 1.0f, '1'); + } + + } + + namespace test_binary_literals + { + + constexpr auto ivii = 0b0000000000101010; + static_assert(ivii == 42, "wrong value"); + + } + + namespace test_generalized_constexpr + { + + template < typename CharT > + constexpr unsigned long + strlen_c(const CharT *const s) noexcept + { + auto length = 0UL; + for (auto p = s; *p; ++p) + ++length; + return length; + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("x") == 1UL, ""); + static_assert(strlen_c("test") == 4UL, ""); + static_assert(strlen_c("another\0test") == 7UL, ""); + + } + + namespace test_lambda_init_capture + { + + int + test() + { + auto x = 0; + const auto lambda1 = [a = x](int b){ return a + b; }; + const auto lambda2 = [a = lambda1(x)](){ return a; }; + return lambda2(); + } + + } + + namespace test_digit_separators + { + + constexpr auto ten_million = 100'000'000; + static_assert(ten_million == 100000000, ""); + + } + + namespace test_return_type_deduction + { + + auto f(int& x) { return x; } + decltype(auto) g(int& x) { return x; } + + template < typename T1, typename T2 > + struct is_same + { + static constexpr auto value = false; + }; + + template < typename T > + struct is_same + { + static constexpr auto value = true; + }; + + int + test() + { + auto x = 0; + static_assert(is_same::value, ""); + static_assert(is_same::value, ""); + return x; + } + + } + +} // namespace cxx14 + +#endif // __cplusplus >= 201402L + + + + +// If the compiler admits that it is not ready for C++17, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201703L && !defined _MSC_VER + +#error "This is not a C++17 compiler" + +#else + +#include +#include +#include + +namespace cxx17 +{ + + namespace test_constexpr_lambdas + { + + constexpr int foo = [](){return 42;}(); + + } + + namespace test::nested_namespace::definitions + { + + } + + namespace test_fold_expression + { + + template + int multiply(Args... args) + { + return (args * ... * 1); + } + + template + bool all(Args... args) + { + return (args && ...); + } + + } + + namespace test_extended_static_assert + { + + static_assert (true); + + } + + namespace test_auto_brace_init_list + { + + auto foo = {5}; + auto bar {5}; + + static_assert(std::is_same, decltype(foo)>::value); + static_assert(std::is_same::value); + } + + namespace test_typename_in_template_template_parameter + { + + template typename X> struct D; + + } + + namespace test_fallthrough_nodiscard_maybe_unused_attributes + { + + int f1() + { + return 42; + } + + [[nodiscard]] int f2() + { + [[maybe_unused]] auto unused = f1(); + + switch (f1()) + { + case 17: + f1(); + [[fallthrough]]; + case 42: + f1(); + } + return f1(); + } + + } + + namespace test_extended_aggregate_initialization + { + + struct base1 + { + int b1, b2 = 42; + }; + + struct base2 + { + base2() { + b3 = 42; + } + int b3; + }; + + struct derived : base1, base2 + { + int d; + }; + + derived d1 {{1, 2}, {}, 4}; // full initialization + derived d2 {{}, {}, 4}; // value-initialized bases + + } + + namespace test_general_range_based_for_loop + { + + struct iter + { + int i; + + int& operator* () + { + return i; + } + + const int& operator* () const + { + return i; + } + + iter& operator++() + { + ++i; + return *this; + } + }; + + struct sentinel + { + int i; + }; + + bool operator== (const iter& i, const sentinel& s) + { + return i.i == s.i; + } + + bool operator!= (const iter& i, const sentinel& s) + { + return !(i == s); + } + + struct range + { + iter begin() const + { + return {0}; + } + + sentinel end() const + { + return {5}; + } + }; + + void f() + { + range r {}; + + for (auto i : r) + { + [[maybe_unused]] auto v = i; + } + } + + } + + namespace test_lambda_capture_asterisk_this_by_value + { + + struct t + { + int i; + int foo() + { + return [*this]() + { + return i; + }(); + } + }; + + } + + namespace test_enum_class_construction + { + + enum class byte : unsigned char + {}; + + byte foo {42}; + + } + + namespace test_constexpr_if + { + + template + int f () + { + if constexpr(cond) + { + return 13; + } + else + { + return 42; + } + } + + } + + namespace test_selection_statement_with_initializer + { + + int f() + { + return 13; + } + + int f2() + { + if (auto i = f(); i > 0) + { + return 3; + } + + switch (auto i = f(); i + 4) + { + case 17: + return 2; + + default: + return 1; + } + } + + } + + namespace test_template_argument_deduction_for_class_templates + { + + template + struct pair + { + pair (T1 p1, T2 p2) + : m1 {p1}, + m2 {p2} + {} + + T1 m1; + T2 m2; + }; + + void f() + { + [[maybe_unused]] auto p = pair{13, 42u}; + } + + } + + namespace test_non_type_auto_template_parameters + { + + template + struct B + {}; + + B<5> b1; + B<'a'> b2; + + } + + namespace test_structured_bindings + { + + int arr[2] = { 1, 2 }; + std::pair pr = { 1, 2 }; + + auto f1() -> int(&)[2] + { + return arr; + } + + auto f2() -> std::pair& + { + return pr; + } + + struct S + { + int x1 : 2; + volatile double y1; + }; + + S f3() + { + return {}; + } + + auto [ x1, y1 ] = f1(); + auto& [ xr1, yr1 ] = f1(); + auto [ x2, y2 ] = f2(); + auto& [ xr2, yr2 ] = f2(); + const auto [ x3, y3 ] = f3(); + + } + + namespace test_exception_spec_type_system + { + + struct Good {}; + struct Bad {}; + + void g1() noexcept; + void g2(); + + template + Bad + f(T*, T*); + + template + Good + f(T1*, T2*); + + static_assert (std::is_same_v); + + } + + namespace test_inline_variables + { + + template void f(T) + {} + + template inline T g(T) + { + return T{}; + } + + template<> inline void f<>(int) + {} + + template<> int g<>(int) + { + return 5; + } + + } + +} // namespace cxx17 + +#endif // __cplusplus < 201703L && !defined _MSC_VER + + + +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ax_cv_cxx_compile_cxx17=yes +else + ax_cv_cxx_compile_cxx17=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx17" >&5 +$as_echo "$ax_cv_cxx_compile_cxx17" >&6; } + if test x$ax_cv_cxx_compile_cxx17 = xyes; then + ac_success=yes + fi + + if test x$ac_success = xno; then + for alternative in ${ax_cxx_compile_alternatives}; do + switch="-std=gnu++${alternative}" + cachevar=`$as_echo "ax_cv_cxx_compile_cxx17_$switch" | $as_tr_sh` + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++17 features with $switch" >&5 +$as_echo_n "checking whether $CXX supports C++17 features with $switch... " >&6; } +if eval \${$cachevar+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_CXX="$CXX" + CXX="$CXX $switch" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +// If the compiler admits that it is not ready for C++11, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +// MSVC always sets __cplusplus to 199711L in older versions; newer versions +// only set it correctly if /Zc:__cplusplus is specified as well as a +// /std:c++NN switch: +// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ +#elif __cplusplus < 201103L && !defined _MSC_VER + +#error "This is not a C++11 compiler" + +#else + +namespace cxx11 +{ + + namespace test_static_assert + { + + template + struct check + { + static_assert(sizeof(int) <= sizeof(T), "not big enough"); + }; + + } + + namespace test_final_override + { + + struct Base + { + virtual ~Base() {} + virtual void f() {} + }; + + struct Derived : public Base + { + virtual ~Derived() override {} + virtual void f() override {} + }; + + } + + namespace test_double_right_angle_brackets + { + + template < typename T > + struct check {}; + + typedef check single_type; + typedef check> double_type; + typedef check>> triple_type; + typedef check>>> quadruple_type; + + } + + namespace test_decltype + { + + int + f() + { + int a = 1; + decltype(a) b = 2; + return a + b; + } + + } + + namespace test_type_deduction + { + + template < typename T1, typename T2 > + struct is_same + { + static const bool value = false; + }; + + template < typename T > + struct is_same + { + static const bool value = true; + }; + + template < typename T1, typename T2 > + auto + add(T1 a1, T2 a2) -> decltype(a1 + a2) + { + return a1 + a2; + } + + int + test(const int c, volatile int v) + { + static_assert(is_same::value == true, ""); + static_assert(is_same::value == false, ""); + static_assert(is_same::value == false, ""); + auto ac = c; + auto av = v; + auto sumi = ac + av + 'x'; + auto sumf = ac + av + 1.0; + static_assert(is_same::value == true, ""); + static_assert(is_same::value == true, ""); + static_assert(is_same::value == true, ""); + static_assert(is_same::value == false, ""); + static_assert(is_same::value == true, ""); + return (sumf > 0.0) ? sumi : add(c, v); + } + + } + + namespace test_noexcept + { + + int f() { return 0; } + int g() noexcept { return 0; } + + static_assert(noexcept(f()) == false, ""); + static_assert(noexcept(g()) == true, ""); + + } + + namespace test_constexpr + { + + template < typename CharT > + unsigned long constexpr + strlen_c_r(const CharT *const s, const unsigned long acc) noexcept + { + return *s ? strlen_c_r(s + 1, acc + 1) : acc; + } + + template < typename CharT > + unsigned long constexpr + strlen_c(const CharT *const s) noexcept + { + return strlen_c_r(s, 0UL); + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("1") == 1UL, ""); + static_assert(strlen_c("example") == 7UL, ""); + static_assert(strlen_c("another\0example") == 7UL, ""); + + } + + namespace test_rvalue_references + { + + template < int N > + struct answer + { + static constexpr int value = N; + }; + + answer<1> f(int&) { return answer<1>(); } + answer<2> f(const int&) { return answer<2>(); } + answer<3> f(int&&) { return answer<3>(); } + + void + test() + { + int i = 0; + const int c = 0; + static_assert(decltype(f(i))::value == 1, ""); + static_assert(decltype(f(c))::value == 2, ""); + static_assert(decltype(f(0))::value == 3, ""); + } + + } + + namespace test_uniform_initialization + { + + struct test + { + static const int zero {}; + static const int one {1}; + }; + + static_assert(test::zero == 0, ""); + static_assert(test::one == 1, ""); + + } + + namespace test_lambdas + { + + void + test1() + { + auto lambda1 = [](){}; + auto lambda2 = lambda1; + lambda1(); + lambda2(); + } + + int + test2() + { + auto a = [](int i, int j){ return i + j; }(1, 2); + auto b = []() -> int { return '0'; }(); + auto c = [=](){ return a + b; }(); + auto d = [&](){ return c; }(); + auto e = [a, &b](int x) mutable { + const auto identity = [](int y){ return y; }; + for (auto i = 0; i < a; ++i) + a += b--; + return x + identity(a + b); + }(0); + return a + b + c + d + e; + } + + int + test3() + { + const auto nullary = [](){ return 0; }; + const auto unary = [](int x){ return x; }; + using nullary_t = decltype(nullary); + using unary_t = decltype(unary); + const auto higher1st = [](nullary_t f){ return f(); }; + const auto higher2nd = [unary](nullary_t f1){ + return [unary, f1](unary_t f2){ return f2(unary(f1())); }; + }; + return higher1st(nullary) + higher2nd(nullary)(unary); + } + + } + + namespace test_variadic_templates + { + + template + struct sum; + + template + struct sum + { + static constexpr auto value = N0 + sum::value; + }; + + template <> + struct sum<> + { + static constexpr auto value = 0; + }; + + static_assert(sum<>::value == 0, ""); + static_assert(sum<1>::value == 1, ""); + static_assert(sum<23>::value == 23, ""); + static_assert(sum<1, 2>::value == 3, ""); + static_assert(sum<5, 5, 11>::value == 21, ""); + static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, ""); + + } + + // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae + // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function + // because of this. + namespace test_template_alias_sfinae + { + + struct foo {}; + + template + using member = typename T::member_type; + + template + void func(...) {} + + template + void func(member*) {} + + void test(); + + void test() { func(0); } + + } + +} // namespace cxx11 + +#endif // __cplusplus >= 201103L + + + + +// If the compiler admits that it is not ready for C++14, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201402L && !defined _MSC_VER + +#error "This is not a C++14 compiler" + +#else + +namespace cxx14 +{ + + namespace test_polymorphic_lambdas + { + + int + test() + { + const auto lambda = [](auto&&... args){ + const auto istiny = [](auto x){ + return (sizeof(x) == 1UL) ? 1 : 0; + }; + const int aretiny[] = { istiny(args)... }; + return aretiny[0]; + }; + return lambda(1, 1L, 1.0f, '1'); + } + + } + + namespace test_binary_literals + { + + constexpr auto ivii = 0b0000000000101010; + static_assert(ivii == 42, "wrong value"); + + } + + namespace test_generalized_constexpr + { + + template < typename CharT > + constexpr unsigned long + strlen_c(const CharT *const s) noexcept + { + auto length = 0UL; + for (auto p = s; *p; ++p) + ++length; + return length; + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("x") == 1UL, ""); + static_assert(strlen_c("test") == 4UL, ""); + static_assert(strlen_c("another\0test") == 7UL, ""); + + } + + namespace test_lambda_init_capture + { + + int + test() + { + auto x = 0; + const auto lambda1 = [a = x](int b){ return a + b; }; + const auto lambda2 = [a = lambda1(x)](){ return a; }; + return lambda2(); + } + + } + + namespace test_digit_separators + { + + constexpr auto ten_million = 100'000'000; + static_assert(ten_million == 100000000, ""); + + } + + namespace test_return_type_deduction + { + + auto f(int& x) { return x; } + decltype(auto) g(int& x) { return x; } + + template < typename T1, typename T2 > + struct is_same + { + static constexpr auto value = false; + }; + + template < typename T > + struct is_same + { + static constexpr auto value = true; + }; + + int + test() + { + auto x = 0; + static_assert(is_same::value, ""); + static_assert(is_same::value, ""); + return x; + } + + } + +} // namespace cxx14 + +#endif // __cplusplus >= 201402L + + + + +// If the compiler admits that it is not ready for C++17, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201703L && !defined _MSC_VER + +#error "This is not a C++17 compiler" + +#else + +#include +#include +#include + +namespace cxx17 +{ + + namespace test_constexpr_lambdas + { + + constexpr int foo = [](){return 42;}(); + + } + + namespace test::nested_namespace::definitions + { + + } + + namespace test_fold_expression + { + + template + int multiply(Args... args) + { + return (args * ... * 1); + } + + template + bool all(Args... args) + { + return (args && ...); + } + + } + + namespace test_extended_static_assert + { + + static_assert (true); + + } + + namespace test_auto_brace_init_list + { + + auto foo = {5}; + auto bar {5}; + + static_assert(std::is_same, decltype(foo)>::value); + static_assert(std::is_same::value); + } + + namespace test_typename_in_template_template_parameter + { + + template typename X> struct D; + + } + + namespace test_fallthrough_nodiscard_maybe_unused_attributes + { + + int f1() + { + return 42; + } + + [[nodiscard]] int f2() + { + [[maybe_unused]] auto unused = f1(); + + switch (f1()) + { + case 17: + f1(); + [[fallthrough]]; + case 42: + f1(); + } + return f1(); + } + + } + + namespace test_extended_aggregate_initialization + { + + struct base1 + { + int b1, b2 = 42; + }; + + struct base2 + { + base2() { + b3 = 42; + } + int b3; + }; + + struct derived : base1, base2 + { + int d; + }; + + derived d1 {{1, 2}, {}, 4}; // full initialization + derived d2 {{}, {}, 4}; // value-initialized bases + + } + + namespace test_general_range_based_for_loop + { + + struct iter + { + int i; + + int& operator* () + { + return i; + } + + const int& operator* () const + { + return i; + } + + iter& operator++() + { + ++i; + return *this; + } + }; + + struct sentinel + { + int i; + }; + + bool operator== (const iter& i, const sentinel& s) + { + return i.i == s.i; + } + + bool operator!= (const iter& i, const sentinel& s) + { + return !(i == s); + } + + struct range + { + iter begin() const + { + return {0}; + } + + sentinel end() const + { + return {5}; + } + }; + + void f() + { + range r {}; + + for (auto i : r) + { + [[maybe_unused]] auto v = i; + } + } + + } + + namespace test_lambda_capture_asterisk_this_by_value + { + + struct t + { + int i; + int foo() + { + return [*this]() + { + return i; + }(); + } + }; + + } + + namespace test_enum_class_construction + { + + enum class byte : unsigned char + {}; + + byte foo {42}; + + } + + namespace test_constexpr_if + { + + template + int f () + { + if constexpr(cond) + { + return 13; + } + else + { + return 42; + } + } + + } + + namespace test_selection_statement_with_initializer + { + + int f() + { + return 13; + } + + int f2() + { + if (auto i = f(); i > 0) + { + return 3; + } + + switch (auto i = f(); i + 4) + { + case 17: + return 2; + + default: + return 1; + } + } + + } + + namespace test_template_argument_deduction_for_class_templates + { + + template + struct pair + { + pair (T1 p1, T2 p2) + : m1 {p1}, + m2 {p2} + {} + + T1 m1; + T2 m2; + }; + + void f() + { + [[maybe_unused]] auto p = pair{13, 42u}; + } + + } + + namespace test_non_type_auto_template_parameters + { + + template + struct B + {}; + + B<5> b1; + B<'a'> b2; + + } + + namespace test_structured_bindings + { + + int arr[2] = { 1, 2 }; + std::pair pr = { 1, 2 }; + + auto f1() -> int(&)[2] + { + return arr; + } + + auto f2() -> std::pair& + { + return pr; + } + + struct S + { + int x1 : 2; + volatile double y1; + }; + + S f3() + { + return {}; + } + + auto [ x1, y1 ] = f1(); + auto& [ xr1, yr1 ] = f1(); + auto [ x2, y2 ] = f2(); + auto& [ xr2, yr2 ] = f2(); + const auto [ x3, y3 ] = f3(); + + } + + namespace test_exception_spec_type_system + { + + struct Good {}; + struct Bad {}; + + void g1() noexcept; + void g2(); + + template + Bad + f(T*, T*); + + template + Good + f(T1*, T2*); + + static_assert (std::is_same_v); + + } + + namespace test_inline_variables + { + + template void f(T) + {} + + template inline T g(T) + { + return T{}; + } + + template<> inline void f<>(int) + {} + + template<> int g<>(int) + { + return 5; + } + + } + +} // namespace cxx17 + +#endif // __cplusplus < 201703L && !defined _MSC_VER + + + _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : - ax_cv_cxx_compile_cxx11=yes + eval $cachevar=yes else - ax_cv_cxx_compile_cxx11=no + eval $cachevar=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CXX="$ac_save_CXX" fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11" >&5 -$as_echo "$ax_cv_cxx_compile_cxx11" >&6; } - if test x$ax_cv_cxx_compile_cxx11 = xyes; then - ac_success=yes - fi +eval ac_res=\$$cachevar + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + if eval test x\$$cachevar = xyes; then + CXX_DIALECT="$switch" + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi + ac_success=yes + break + fi + done + fi if test x$ac_success = xno; then - for alternative in ${ax_cxx_compile_alternatives}; do - switch="-std=gnu++${alternative}" - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 -$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } + for alternative in ${ax_cxx_compile_alternatives}; do + for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" MSVC; do + if test x"$switch" = xMSVC; then + switch=-std:c++${alternative} + cachevar=`$as_echo "ax_cv_cxx_compile_cxx17_${switch}_MSVC" | $as_tr_sh` + else + cachevar=`$as_echo "ax_cv_cxx_compile_cxx17_$switch" | $as_tr_sh` + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++17 features with $switch" >&5 +$as_echo_n "checking whether $CXX supports C++17 features with $switch... " >&6; } if eval \${$cachevar+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_CXX="$CXX" - CXX="$CXX $switch" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + CXX="$CXX $switch" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -6535,337 +7865,501 @@ namespace cxx11 -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - eval $cachevar=yes -else - eval $cachevar=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CXX="$ac_save_CXX" -fi -eval ac_res=\$$cachevar - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - if eval test x\$$cachevar = xyes; then - CXX_DIALECT="$switch" - CXX="$CXX $switch" - if test -n "$CXXCPP" ; then - CXXCPP="$CXXCPP $switch" - fi - ac_success=yes - break - fi - done - fi - if test x$ac_success = xno; then - for alternative in ${ax_cxx_compile_alternatives}; do - for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" MSVC; do - if test x"$switch" = xMSVC; then - switch=-std:c++${alternative} - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_${switch}_MSVC" | $as_tr_sh` - else - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 -$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } -if eval \${$cachevar+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_save_CXX="$CXX" - CXX="$CXX $switch" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ +// If the compiler admits that it is not ready for C++14, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201402L && !defined _MSC_VER + +#error "This is not a C++14 compiler" + +#else + +namespace cxx14 +{ + + namespace test_polymorphic_lambdas + { + + int + test() + { + const auto lambda = [](auto&&... args){ + const auto istiny = [](auto x){ + return (sizeof(x) == 1UL) ? 1 : 0; + }; + const int aretiny[] = { istiny(args)... }; + return aretiny[0]; + }; + return lambda(1, 1L, 1.0f, '1'); + } + + } + + namespace test_binary_literals + { + + constexpr auto ivii = 0b0000000000101010; + static_assert(ivii == 42, "wrong value"); + + } + + namespace test_generalized_constexpr + { + + template < typename CharT > + constexpr unsigned long + strlen_c(const CharT *const s) noexcept + { + auto length = 0UL; + for (auto p = s; *p; ++p) + ++length; + return length; + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("x") == 1UL, ""); + static_assert(strlen_c("test") == 4UL, ""); + static_assert(strlen_c("another\0test") == 7UL, ""); + + } + + namespace test_lambda_init_capture + { + + int + test() + { + auto x = 0; + const auto lambda1 = [a = x](int b){ return a + b; }; + const auto lambda2 = [a = lambda1(x)](){ return a; }; + return lambda2(); + } + + } + + namespace test_digit_separators + { + + constexpr auto ten_million = 100'000'000; + static_assert(ten_million == 100000000, ""); + + } + + namespace test_return_type_deduction + { + + auto f(int& x) { return x; } + decltype(auto) g(int& x) { return x; } + + template < typename T1, typename T2 > + struct is_same + { + static constexpr auto value = false; + }; + + template < typename T > + struct is_same + { + static constexpr auto value = true; + }; + + int + test() + { + auto x = 0; + static_assert(is_same::value, ""); + static_assert(is_same::value, ""); + return x; + } + + } +} // namespace cxx14 -// If the compiler admits that it is not ready for C++11, why torture it? +#endif // __cplusplus >= 201402L + + + + +// If the compiler admits that it is not ready for C++17, why torture it? // Hopefully, this will speed up the test. #ifndef __cplusplus #error "This is not a C++ compiler" -// MSVC always sets __cplusplus to 199711L in older versions; newer versions -// only set it correctly if /Zc:__cplusplus is specified as well as a -// /std:c++NN switch: -// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ -#elif __cplusplus < 201103L && !defined _MSC_VER +#elif __cplusplus < 201703L && !defined _MSC_VER -#error "This is not a C++11 compiler" +#error "This is not a C++17 compiler" #else -namespace cxx11 +#include +#include +#include + +namespace cxx17 { - namespace test_static_assert + namespace test_constexpr_lambdas { - template - struct check - { - static_assert(sizeof(int) <= sizeof(T), "not big enough"); - }; + constexpr int foo = [](){return 42;}(); } - namespace test_final_override + namespace test::nested_namespace::definitions { - struct Base + } + + namespace test_fold_expression + { + + template + int multiply(Args... args) { - virtual ~Base() {} - virtual void f() {} - }; + return (args * ... * 1); + } - struct Derived : public Base + template + bool all(Args... args) { - virtual ~Derived() override {} - virtual void f() override {} - }; + return (args && ...); + } } - namespace test_double_right_angle_brackets + namespace test_extended_static_assert { - template < typename T > - struct check {}; + static_assert (true); - typedef check single_type; - typedef check> double_type; - typedef check>> triple_type; - typedef check>>> quadruple_type; + } + + namespace test_auto_brace_init_list + { + auto foo = {5}; + auto bar {5}; + + static_assert(std::is_same, decltype(foo)>::value); + static_assert(std::is_same::value); } - namespace test_decltype + namespace test_typename_in_template_template_parameter { - int - f() + template typename X> struct D; + + } + + namespace test_fallthrough_nodiscard_maybe_unused_attributes + { + + int f1() { - int a = 1; - decltype(a) b = 2; - return a + b; + return 42; + } + + [[nodiscard]] int f2() + { + [[maybe_unused]] auto unused = f1(); + + switch (f1()) + { + case 17: + f1(); + [[fallthrough]]; + case 42: + f1(); + } + return f1(); } } - namespace test_type_deduction + namespace test_extended_aggregate_initialization { - template < typename T1, typename T2 > - struct is_same + struct base1 { - static const bool value = false; + int b1, b2 = 42; }; - template < typename T > - struct is_same + struct base2 { - static const bool value = true; + base2() { + b3 = 42; + } + int b3; }; - template < typename T1, typename T2 > - auto - add(T1 a1, T2 a2) -> decltype(a1 + a2) + struct derived : base1, base2 { - return a1 + a2; + int d; + }; + + derived d1 {{1, 2}, {}, 4}; // full initialization + derived d2 {{}, {}, 4}; // value-initialized bases + + } + + namespace test_general_range_based_for_loop + { + + struct iter + { + int i; + + int& operator* () + { + return i; + } + + const int& operator* () const + { + return i; + } + + iter& operator++() + { + ++i; + return *this; + } + }; + + struct sentinel + { + int i; + }; + + bool operator== (const iter& i, const sentinel& s) + { + return i.i == s.i; } - int - test(const int c, volatile int v) + bool operator!= (const iter& i, const sentinel& s) { - static_assert(is_same::value == true, ""); - static_assert(is_same::value == false, ""); - static_assert(is_same::value == false, ""); - auto ac = c; - auto av = v; - auto sumi = ac + av + 'x'; - auto sumf = ac + av + 1.0; - static_assert(is_same::value == true, ""); - static_assert(is_same::value == true, ""); - static_assert(is_same::value == true, ""); - static_assert(is_same::value == false, ""); - static_assert(is_same::value == true, ""); - return (sumf > 0.0) ? sumi : add(c, v); + return !(i == s); + } + + struct range + { + iter begin() const + { + return {0}; + } + + sentinel end() const + { + return {5}; + } + }; + + void f() + { + range r {}; + + for (auto i : r) + { + [[maybe_unused]] auto v = i; + } } } - namespace test_noexcept + namespace test_lambda_capture_asterisk_this_by_value { - int f() { return 0; } - int g() noexcept { return 0; } + struct t + { + int i; + int foo() + { + return [*this]() + { + return i; + }(); + } + }; - static_assert(noexcept(f()) == false, ""); - static_assert(noexcept(g()) == true, ""); + } + + namespace test_enum_class_construction + { + + enum class byte : unsigned char + {}; + + byte foo {42}; } - namespace test_constexpr + namespace test_constexpr_if { - template < typename CharT > - unsigned long constexpr - strlen_c_r(const CharT *const s, const unsigned long acc) noexcept + template + int f () { - return *s ? strlen_c_r(s + 1, acc + 1) : acc; + if constexpr(cond) + { + return 13; + } + else + { + return 42; + } } - template < typename CharT > - unsigned long constexpr - strlen_c(const CharT *const s) noexcept + } + + namespace test_selection_statement_with_initializer + { + + int f() { - return strlen_c_r(s, 0UL); + return 13; } - static_assert(strlen_c("") == 0UL, ""); - static_assert(strlen_c("1") == 1UL, ""); - static_assert(strlen_c("example") == 7UL, ""); - static_assert(strlen_c("another\0example") == 7UL, ""); + int f2() + { + if (auto i = f(); i > 0) + { + return 3; + } + + switch (auto i = f(); i + 4) + { + case 17: + return 2; + + default: + return 1; + } + } } - namespace test_rvalue_references + namespace test_template_argument_deduction_for_class_templates { - template < int N > - struct answer + template + struct pair { - static constexpr int value = N; - }; + pair (T1 p1, T2 p2) + : m1 {p1}, + m2 {p2} + {} - answer<1> f(int&) { return answer<1>(); } - answer<2> f(const int&) { return answer<2>(); } - answer<3> f(int&&) { return answer<3>(); } + T1 m1; + T2 m2; + }; - void - test() + void f() { - int i = 0; - const int c = 0; - static_assert(decltype(f(i))::value == 1, ""); - static_assert(decltype(f(c))::value == 2, ""); - static_assert(decltype(f(0))::value == 3, ""); + [[maybe_unused]] auto p = pair{13, 42u}; } } - namespace test_uniform_initialization + namespace test_non_type_auto_template_parameters { - struct test - { - static const int zero {}; - static const int one {1}; - }; + template + struct B + {}; - static_assert(test::zero == 0, ""); - static_assert(test::one == 1, ""); + B<5> b1; + B<'a'> b2; } - namespace test_lambdas + namespace test_structured_bindings { - void - test1() + int arr[2] = { 1, 2 }; + std::pair pr = { 1, 2 }; + + auto f1() -> int(&)[2] { - auto lambda1 = [](){}; - auto lambda2 = lambda1; - lambda1(); - lambda2(); + return arr; } - int - test2() + auto f2() -> std::pair& { - auto a = [](int i, int j){ return i + j; }(1, 2); - auto b = []() -> int { return '0'; }(); - auto c = [=](){ return a + b; }(); - auto d = [&](){ return c; }(); - auto e = [a, &b](int x) mutable { - const auto identity = [](int y){ return y; }; - for (auto i = 0; i < a; ++i) - a += b--; - return x + identity(a + b); - }(0); - return a + b + c + d + e; + return pr; } - int - test3() + struct S { - const auto nullary = [](){ return 0; }; - const auto unary = [](int x){ return x; }; - using nullary_t = decltype(nullary); - using unary_t = decltype(unary); - const auto higher1st = [](nullary_t f){ return f(); }; - const auto higher2nd = [unary](nullary_t f1){ - return [unary, f1](unary_t f2){ return f2(unary(f1())); }; - }; - return higher1st(nullary) + higher2nd(nullary)(unary); + int x1 : 2; + volatile double y1; + }; + + S f3() + { + return {}; } + auto [ x1, y1 ] = f1(); + auto& [ xr1, yr1 ] = f1(); + auto [ x2, y2 ] = f2(); + auto& [ xr2, yr2 ] = f2(); + const auto [ x3, y3 ] = f3(); + } - namespace test_variadic_templates + namespace test_exception_spec_type_system { - template - struct sum; + struct Good {}; + struct Bad {}; - template - struct sum - { - static constexpr auto value = N0 + sum::value; - }; + void g1() noexcept; + void g2(); - template <> - struct sum<> - { - static constexpr auto value = 0; - }; + template + Bad + f(T*, T*); - static_assert(sum<>::value == 0, ""); - static_assert(sum<1>::value == 1, ""); - static_assert(sum<23>::value == 23, ""); - static_assert(sum<1, 2>::value == 3, ""); - static_assert(sum<5, 5, 11>::value == 21, ""); - static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, ""); + template + Good + f(T1*, T2*); + + static_assert (std::is_same_v); } - // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae - // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function - // because of this. - namespace test_template_alias_sfinae + namespace test_inline_variables { - struct foo {}; - - template - using member = typename T::member_type; - - template - void func(...) {} + template void f(T) + {} - template - void func(member*) {} + template inline T g(T) + { + return T{}; + } - void test(); + template<> inline void f<>(int) + {} - void test() { func(0); } + template<> int g<>(int) + { + return 5; + } } -} // namespace cxx11 +} // namespace cxx17 -#endif // __cplusplus >= 201103L +#endif // __cplusplus < 201703L && !defined _MSC_VER @@ -6902,19 +8396,19 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu - if test x$ax_cxx_compile_cxx11_required = xtrue; then + if test x$ax_cxx_compile_cxx17_required = xtrue; then if test x$ac_success = xno; then - as_fn_error $? "*** A compiler with support for C++11 language features is required." "$LINENO" 5 + as_fn_error $? "*** A compiler with support for C++17 language features is required." "$LINENO" 5 fi fi if test x$ac_success = xno; then - HAVE_CXX11=0 - { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++11 support was found" >&5 -$as_echo "$as_me: No compiler with C++11 support was found" >&6;} + HAVE_CXX17=0 + { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++17 support was found" >&5 +$as_echo "$as_me: No compiler with C++17 support was found" >&6;} else - HAVE_CXX11=1 + HAVE_CXX17=1 -$as_echo "#define HAVE_CXX11 1" >>confdefs.h +$as_echo "#define HAVE_CXX17 1" >>confdefs.h fi diff --git a/gdbsupport/configure.ac b/gdbsupport/configure.ac index 2cb382bd4ec..a0986fab9cd 100644 --- a/gdbsupport/configure.ac +++ b/gdbsupport/configure.ac @@ -41,9 +41,9 @@ AC_PROG_RANLIB AC_USE_SYSTEM_EXTENSIONS ACX_LARGEFILE -# We require a C++11 compiler. Check if one is available, and if +# We require a C++17 compiler. Check if one is available, and if # necessary, set CXX_DIALECT to some -std=xxx switch. -AX_CXX_COMPILE_STDCXX(11, , mandatory) +AX_CXX_COMPILE_STDCXX(17, , mandatory) dnl Set up for gettext. ZW_GNU_GETTEXT_SISTER_DIR From patchwork Fri Oct 13 14:44:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lancelot SIX X-Patchwork-Id: 77663 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 C0C233856DC8 for ; Fri, 13 Oct 2023 14:45:16 +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 BE0A03856DDF for ; Fri, 13 Oct 2023 14:44:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BE0A03856DDF 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-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TFMw2iuc+MyM3lIsNiLE9Fq9LLmtsRjYYDDnqTLiqHqxgD9EkorVOdWiLcLzLg8OVBAVwl7sCrZuAP//dmZ8ZuNql7QotWBwm0sbLjYdXRqEhdcwWwehsbtwku4TzCDvFbaJ8P4+AgbpWgcu0NPOe6ppGdumBOjwzs6giFNjTZ1j424GFfzFh0195obNkQYfA85VcUidFEfqguXWI4jt/Pwt0JDeD7HEp/gKCuOLnh/FBLppncczJwZbLfwEpD74aDAAd50fJwcgZxmTqNpq3dlCX9L5RJoz2DMGkrB2A8Rx2wJ53wcEchouagdZYvH6EVf65Rta6Q4cd7f2coQumg== 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=aapZX7+VhI7PCMUpU1NwZ0REYtL5IBbueP2BITMkv4w=; b=hTgrOg+Fg3pqfAP5790ek0VqS8vamDTCVPQtXM30HefB4lmtly6q/GHhk6JELw4zfKiYiDqsXu/YkWSQMKWkrYYL4BPOgNy0XyxKis0v5FzmyNeXBYTPtUx8+pFlj3I0KyktivzKZAD9tOfdVZRXl9FmY2KxPwGfe372akIIPSACsgacv2lbyAL0RreslPlKIZc20UWnprleDI9k34OrHFa2PJVshTto2wvU1Jm279TcGIUy0LoLeLXXWXFOxrAEK8jk8lq8tmfs9JlL0/TzLftwqBpSAUedGYKUf1HLw4xTTca6pbcFklUExM3GblEU6bRJApMGbpKF2JjqcswiNg== 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 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=aapZX7+VhI7PCMUpU1NwZ0REYtL5IBbueP2BITMkv4w=; b=EMYUzZFVXBgG3jJ3Y3EIBarSTxR09/jwy15+GTrqUJbVkozFrJY7sN1txnJRQue6tsiy9oXXZgOsYxHdIc72ELahAo5qAWdnw/IivHPX9yrlab6DdZ8RAGcGt1IatCwF+DWdGnvh2PvvH2TnPIYWQP+47teAePWvUGbKyU1AUrk= Received: from DM6PR11CA0008.namprd11.prod.outlook.com (2603:10b6:5:190::21) by SA0PR12MB4576.namprd12.prod.outlook.com (2603:10b6:806:93::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.45; Fri, 13 Oct 2023 14:44:56 +0000 Received: from DS1PEPF00017096.namprd05.prod.outlook.com (2603:10b6:5:190:cafe::fc) by DM6PR11CA0008.outlook.office365.com (2603:10b6:5:190::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.30 via Frontend Transport; Fri, 13 Oct 2023 14:44:56 +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 DS1PEPF00017096.mail.protection.outlook.com (10.167.18.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Fri, 13 Oct 2023 14:44:56 +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.27; Fri, 13 Oct 2023 09:44:54 -0500 From: Lancelot Six To: CC: Lancelot Six Subject: [PATCH 03/11] gdb: Use C++17's std::make_unique instead of gdb::make_unique Date: Fri, 13 Oct 2023 14:44:10 +0000 Message-ID: <20231013144418.3180617-4-lancelot.six@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231013144418.3180617-1-lancelot.six@amd.com> References: <20231013144418.3180617-1-lancelot.six@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF00017096:EE_|SA0PR12MB4576:EE_ X-MS-Office365-Filtering-Correlation-Id: a970dd61-6d3e-4f57-d377-08dbcbfaf7bb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rcuVxXpn4y8U5L+b6C6Zc/XcBXLIe++o4EmJsoR44dvfMf4Yl+yKM838//mnvH+nK5ApU0klWwmrZtBNtiVYJB31CMiDpmwtGYFRWixcGkw0iGhG0unaC9iS1PLksr4UaAy1XGL87sHb6e4av+2Gtxy0O8c4ctiwBTdObK0LxSBiXvLJoCSEOetqPWX8F0Cn8i9p7ilLuA05pjOGQGjFZiNx/I0xZDQv/bhwPXeqKNAG3wOHKnt4U/NbeGB0XIuxUu3J71ww1JBPirt4RjX8zdB486jNSHN5+yM3u8Mf4MesKIjAMY3/1Yedro5XSCZ+IdslA0FF32gEMSPXljvyegP6JeSLqsb41Opk0TWtssd52KpFIgYmFkAe/dS6wJl3XKKFRxOuXIXojWGGFS49foIs9Sx5sJYsgneYXa8SR3nV2mdePBgXvcO8QPgnSA/INSt+aBtCbW/zK+cmn7+Gh+9XwdXE4zUy5gg2mt0waq00vORbXg2/l6vuZ1bfsXJGs2thqHEOnoc1zZJP5soYGu29zKkguuXVyDCyhcA5W0FYgZgT2R65C5/JCM2SdRR6k1+Wv5ucwJa8hskcoEqR7kemBw7D9JxeM9tGbQwrtIuZqAOPtolTV3Yrr7r/LmE4hCQ3YmZiyB3mIGNQ5d0WBGHgZiquPTnrEf0kJxC3Elw6twhq2P3FZvb1F8zUnvpDOGTU2ijRy+MomZhr5qDVFPoF2NhvqcFcsTnGWjO2GlshRMbqk9eXn4fhcP3ONN0il/yKXbFjGGIY+fjxRtWfQQ== 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)(39860400002)(396003)(230922051799003)(1800799009)(186009)(82310400011)(451199024)(64100799003)(36840700001)(40470700004)(46966006)(1076003)(2616005)(40460700003)(356005)(36756003)(86362001)(81166007)(40480700001)(82740400003)(36860700001)(16526019)(47076005)(26005)(426003)(336012)(30864003)(44832011)(83380400001)(2906002)(7696005)(6666004)(478600001)(8676002)(6916009)(4326008)(8936002)(316002)(41300700001)(70206006)(70586007)(5660300002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2023 14:44:56.0195 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a970dd61-6d3e-4f57-d377-08dbcbfaf7bb 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: DS1PEPF00017096.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4576 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 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 --- gdb/addrmap.c | 3 ++- gdb/break-catch-load.c | 3 ++- gdb/compile/compile-c-support.c | 3 ++- gdb/cp-name-parser.y | 3 ++- gdb/cp-support.c | 3 ++- gdb/dwarf2/frame.c | 3 ++- gdb/dwarf2/read-debug-names.c | 3 ++- gdb/dwarf2/read-gdb-index.c | 3 ++- gdb/dwarf2/read.c | 3 ++- gdb/gdb_bfd.c | 2 +- gdb/gdbtypes.c | 3 ++- gdb/mi/mi-main.c | 3 ++- gdb/mi/mi-out.c | 7 ++++--- gdb/nat/linux-btrace.c | 5 +++-- gdb/python/py-mi.c | 3 ++- gdb/python/py-varobj.c | 3 ++- gdb/ui-out.c | 4 ++-- gdb/unittests/parallel-for-selftests.c | 5 +++-- gdb/varobj.c | 3 ++- gdbsupport/gdb_unique_ptr.h | 13 ------------- 20 files changed, 41 insertions(+), 37 deletions(-) diff --git a/gdb/addrmap.c b/gdb/addrmap.c index d16775d49d4..757947abaf4 100644 --- a/gdb/addrmap.c +++ b/gdb/addrmap.c @@ -21,6 +21,7 @@ #include "gdbsupport/gdb_obstack.h" #include "addrmap.h" #include "gdbsupport/selftest.h" +#include /* Make sure splay trees can actually hold the values we want to store in them. */ @@ -428,7 +429,7 @@ test_addrmap () /* Create mutable addrmap. */ auto_obstack temp_obstack; - auto map = gdb::make_unique (); + 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 94d8b420d32..cac914d3fac 100644 --- a/gdb/break-catch-load.c +++ b/gdb/break-catch-load.c @@ -28,6 +28,7 @@ #include "solist.h" #include "target.h" #include "valprint.h" +#include /* An instance of this type is used to represent an solib catchpoint. A breakpoint is really of this type iff its ops pointer points to @@ -230,7 +231,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..20a7bb4e0d4 100644 --- a/gdb/compile/compile-c-support.c +++ b/gdb/compile/compile-c-support.c @@ -30,6 +30,7 @@ #include "gdbsupport/gdb-dlfcn.h" #include "gdbsupport/preprocessor.h" #include "gdbarch.h" +#include /* See compile-internal.h. */ @@ -118,7 +119,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..061882363be 100644 --- a/gdb/cp-name-parser.y +++ b/gdb/cp-name-parser.y @@ -45,6 +45,7 @@ #include "cp-support.h" #include "c-support.h" #include "parser-defs.h" +#include #define GDB_YY_REMAP_PREFIX cpname #include "yy-remap.h" @@ -2038,7 +2039,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..579f09303c8 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -44,6 +44,7 @@ #include "run-on-main-thread.h" #include "typeprint.h" #include "inferior.h" +#include #define d_left(dc) (dc)->u.s_binary.left #define d_right(dc) (dc)->u.s_binary.right @@ -675,7 +676,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..6f52a1abe0e 100644 --- a/gdb/dwarf2/frame.c +++ b/gdb/dwarf2/frame.c @@ -49,6 +49,7 @@ #include #include +#include struct comp_unit; @@ -2126,7 +2127,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 2e5067efb3d..535028b1597 100644 --- a/gdb/dwarf2/read-debug-names.c +++ b/gdb/dwarf2/read-debug-names.c @@ -26,6 +26,7 @@ #include "mapped-index.h" #include "read.h" #include "stringify.h" +#include /* A description of the mapped .debug_names. Uninitialized map has CU_COUNT 0. */ @@ -462,7 +463,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 b96eaa96e23..da3bf0633fc 100644 --- a/gdb/dwarf2/read-gdb-index.c +++ b/gdb/dwarf2/read-gdb-index.c @@ -27,6 +27,7 @@ #include "gdbsupport/gdb-checked-static-cast.h" #include "mapped-index.h" #include "read.h" +#include /* When true, do not reject deprecated .gdb_index sections. */ static bool use_deprecated_index_sections = false; @@ -828,7 +829,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 d4aec19d31d..5bbf208ed5a 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -95,6 +95,7 @@ #include "split-name.h" #include "gdbsupport/parallel-for.h" #include "gdbsupport/thread-pool.h" +#include /* When == 1, print basic high level tracing messages. When > 1, be more verbose. @@ -4535,7 +4536,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 217753cf914..fc0c5bab6ed 100644 --- a/gdb/gdb_bfd.c +++ b/gdb/gdb_bfd.c @@ -302,7 +302,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..534b7a2bfa2 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -45,6 +45,7 @@ #include "gmp-utils.h" #include "rust-lang.h" #include "ada-lang.h" +#include /* The value of an invalid conversion badness. */ #define INVALID_CONVERSION 100 @@ -5833,7 +5834,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 944c9116731..d750371f917 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -63,6 +63,7 @@ #include #include #include +#include enum { @@ -1933,7 +1934,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..95f8069674c 100644 --- a/gdb/mi/mi-out.c +++ b/gdb/mi/mi-out.c @@ -23,6 +23,7 @@ #include "mi-out.h" #include +#include #include "interps.h" #include "ui-out.h" @@ -340,13 +341,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..aa02f193399 100644 --- a/gdb/nat/linux-btrace.c +++ b/gdb/nat/linux-btrace.c @@ -27,6 +27,7 @@ #include "gdbsupport/filestuff.h" #include "gdbsupport/scoped_fd.h" #include "gdbsupport/scoped_mmap.h" +#include #include @@ -468,7 +469,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 +618,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..a43fac98c43 100644 --- a/gdb/python/py-mi.c +++ b/gdb/python/py-mi.c @@ -27,6 +27,7 @@ #include "mi/mi-parse.h" #include "mi/mi-console.h" #include "mi/mi-interp.h" +#include /* A ui_out subclass that creates a Python object based on the data that is passed in. */ @@ -290,7 +291,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..f72f1400d1d 100644 --- a/gdb/python/py-varobj.c +++ b/gdb/python/py-varobj.c @@ -18,6 +18,7 @@ #include "varobj.h" #include "varobj-iter.h" #include "valprint.h" +#include /* A dynamic varobj iterator "class" for python pretty-printed varobjs. This inherits struct varobj_iter. */ @@ -170,5 +171,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/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..5e2f8b5f735 100644 --- a/gdb/unittests/parallel-for-selftests.c +++ b/gdb/unittests/parallel-for-selftests.c @@ -27,6 +27,7 @@ #include "defs.h" #include "gdbsupport/selftest.h" #include "gdbsupport/parallel-for.h" +#include #if CXX_STD_THREAD @@ -160,7 +161,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 +179,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..5d1ae343fca 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -33,6 +33,7 @@ #include "gdbarch.h" #include #include "observable.h" +#include #if HAVE_PYTHON #include "python/python.h" @@ -259,7 +260,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 Fri Oct 13 14:44:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lancelot SIX X-Patchwork-Id: 77671 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 9A2EF385B513 for ; Fri, 13 Oct 2023 14:47:07 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2048.outbound.protection.outlook.com [40.107.243.48]) by sourceware.org (Postfix) with ESMTPS id AB5E3385C6EF for ; Fri, 13 Oct 2023 14:45:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AB5E3385C6EF 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-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l9fYznCqNRWLGuAdeFpKzSjrDuSwdY5f+zBT8ABPdAdsOyKEC3zBIKGVMDqhHcPAsMVrHtHwxjAs+sL0NmAjbCIOdM4QxNLamCvBy8jgM0r6jD1gsAYDJfPFToKlaykgoavxGrNqR7mj4Z0KfgadKr0AHat/kk8K1BPKt9KuW2DDIj4CjU7Y3e9l5u9H7K2vpIqz7UYWZvyq4j3lTuCVBEgqYxU6kzXMOhwlhSnTG+n5ZFBsWxNsM8AXk7OIQ45cxoIE6tmwu4DI0NHCZu+hLXjpLMjLQo0oNnAWCeFB/iY9ZIF2FPyTWHrIyREvg43dwldT4BMZGtGipG6/vLnG0g== 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=R/bCcCW3gL/XJ/pG5SOzpfL14yCxdKtWKP5irkTidFw=; b=h3k4XkPrY8PkW8YrlCTeJSELDEcT7zYW2NNTxqmZxzgDjmZZMRYm4ncmSPc8XZMuvrbcy/Ncqfg+pgEg39W9wJNr/kXBVPdHC2Mxrzd2s/BAOGQHA9OsE3UsPgWVm9Yap+jjNRR9lfKZ8+GkSvHTcB5RbjfbfC9bCZVXyGn5hltO8TfXXswri83llBMrXMHbNAO9uiE5R8dMOmS1SPGhAJIBvDwCholWon787pgBOpJC6TpiO6y4uMSSxJSfpuhpLM2Cd0YIOJ0G0P1xcGLB7TxFnftNIROvuTUmH3l12YEk0c/NT7ReypfpRSWF6ZJC/aFe4p6Mcr0uOs4byNJrrw== 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 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=R/bCcCW3gL/XJ/pG5SOzpfL14yCxdKtWKP5irkTidFw=; b=H4sTXfZwTBPhS5O5RXrIXE5O12bo8gd6qQ2sLo7T3NY59UOEcLeEJ1dLQtV8JFs93FYXk4J6FdGZNzwyQtSQgU0T1IWT+//KPQYtJowEULkBg+4MzQn2CKdcr7VzceGncCa/SgbOKg1sy+BSX3jOX2A+mYJWSwwp2AQ2WMYvp7w= Received: from DM6PR11CA0035.namprd11.prod.outlook.com (2603:10b6:5:190::48) by DS7PR12MB6286.namprd12.prod.outlook.com (2603:10b6:8:95::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.44; Fri, 13 Oct 2023 14:44:56 +0000 Received: from DS1PEPF00017096.namprd05.prod.outlook.com (2603:10b6:5:190:cafe::bd) by DM6PR11CA0035.outlook.office365.com (2603:10b6:5:190::48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.30 via Frontend Transport; Fri, 13 Oct 2023 14:44:56 +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 DS1PEPF00017096.mail.protection.outlook.com (10.167.18.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Fri, 13 Oct 2023 14:44:56 +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.27; Fri, 13 Oct 2023 09:44:55 -0500 From: Lancelot Six To: CC: Lancelot Six Subject: [PATCH 04/11] gdb: Replace gdb::optional with std::optional Date: Fri, 13 Oct 2023 14:44:11 +0000 Message-ID: <20231013144418.3180617-5-lancelot.six@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231013144418.3180617-1-lancelot.six@amd.com> References: <20231013144418.3180617-1-lancelot.six@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF00017096:EE_|DS7PR12MB6286:EE_ X-MS-Office365-Filtering-Correlation-Id: 8f3bfcef-a4d9-4f9a-cee5-08dbcbfaf818 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3edsG1sSOugbGdB7W7G9eYJVlsjbXSFzZz5IzEMVvGCflRXbTk9U//uuvcstQi4V+pIL6Gt6X2ISpvO8btFiXuitGsxw34sdm13V6SAt0V6DP/0fjZMqkRF7qIAeCFyrY1q1KP5wIYukMNt0KyDntB5uOoI2TlQFdoC0o4Dsl1hFM8hnQ7cxyCS+vFOfydtJxzlWj0AfSIoAeLeHdmzpfu9cHBkDMVpLgegwWdkc7m5ACpmQQ1r4OXyHZOEbwdBjhnDw6K8MsPLRsKtyHLF3UCHgVTZfmOpTqQi1NJXvprK548TA1lP1n255mHn0esumHQf6NUVYWGieBksoZGpEzp8nlrSaKGEV17C14WrbWQI03qF6r8YxoePKjow970pn79YLpV469JVN4KmO0HA2igpvVQ2VZEq1aTAXR3IoOsqIdtohq7vqG3SLWUOF/qCS0kH1lpApLgM+QRLt7pk0bHGF/hKd1ooU9PDT0z/R5xHG990pk3wi1e/wDwbMvQ6qdTT4eqOaaNwNS10MpCoyWM/fZLd9OQfeCgBX5ETyj4EP5xV/ZV03+Bc4f0LcyTuMa7DpD1tlMHjkskgD+ZGsXJRdydHGl8DWepma+lsPgM1tAw1mo/qHL+WfftlvyMkUeG0M9hJ856kSvo3lUb8+O8BrPAZLjkv3ajM902uBtjAu89f+o6WuqA0VeTKuMMnWkpk0jkilRkuZDby3o6Oaxlc45dp3mvTyD1JnZCXWJAWcjox0DtEfY1E+9wV2mTN7qsS2oxeEnSiq0jkFKr6oxVEgUKfeU8xhD/yJ+aLaLEAOT4ynGBg/p2hPtQSkpxO4yNpkbXMZ3q1yXQEX4eDQww== 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)(136003)(39860400002)(376002)(230922051799003)(64100799003)(186009)(451199024)(82310400011)(1800799009)(36840700001)(46966006)(40470700004)(8936002)(8676002)(4326008)(5660300002)(44832011)(6916009)(40480700001)(70206006)(70586007)(41300700001)(316002)(40460700003)(66899024)(47076005)(81166007)(356005)(82740400003)(1076003)(36756003)(336012)(16526019)(26005)(426003)(2616005)(86362001)(6666004)(30864003)(478600001)(2906002)(83380400001)(7696005)(36860700001)(403724002)(36900700001)(579004)(559001)(357404004); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2023 14:44:56.6288 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8f3bfcef-a4d9-4f9a-cee5-08dbcbfaf818 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: DS1PEPF00017096.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6286 X-Spam-Status: No, score=-11.5 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 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 --- 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 | 2 +- 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 | 4 ++-- 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, 413 insertions(+), 412 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 22c81262876..a19d6d0fc95 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 b6aa42a4fd0..03264f744a2 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 dfa816990ff..4c0f7816d61 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 a0ad1fb7a82..58c550af183 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 2edcbf6d490..1cc2dfbe66e 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 ()) @@ -6780,8 +6780,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"); @@ -6854,7 +6854,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); @@ -6889,7 +6890,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 @@ -9954,7 +9955,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: @@ -10932,7 +10933,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 8cadd637151..49952eaca6a 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 588e9e2a345..af0a360d8ca 100644 --- a/gdb/darwin-nat.c +++ b/gdb/darwin-nat.c @@ -1967,7 +1967,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 0c15d8b02db..d57f3683a9a 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 6ea4217fb22..a6d770c9ee5 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -1473,7 +1473,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; }; @@ -1496,7 +1496,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 da3bf0633fc..dd011900d2b 100644 --- a/gdb/dwarf2/read-gdb-index.c +++ b/gdb/dwarf2/read-gdb-index.c @@ -182,7 +182,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, @@ -204,7 +204,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 5bbf208ed5a..e40353975c1 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -77,7 +77,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" @@ -4080,7 +4080,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) @@ -4088,7 +4088,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 (); } @@ -4121,7 +4121,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" @@ -7981,7 +7981,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" @@ -10785,7 +10785,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; @@ -10991,7 +10991,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; @@ -16187,8 +16187,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) @@ -17565,7 +17565,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 (); @@ -17618,7 +17618,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. @@ -21389,7 +21389,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 1d9432c5c11..0cbe2bb3e69 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -747,7 +747,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 3d6fa896a9c..ee78768f8a6 100644 --- a/gdb/event-top.c +++ b/gdb/event-top.c @@ -692,7 +692,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 3442302a0be..7b74b46ee7c 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 65f3bab32a7..0fbba5fc8fc 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 28f9e3bc028..bfdd9d51deb 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); #if GDB_SELF_TEST 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 48f32bb3a0b..403aed7c838 100644 --- a/gdb/gdbthread.h +++ b/gdb/gdbthread.h @@ -210,10 +210,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. */ @@ -645,7 +645,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. */ @@ -1042,7 +1042,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 534b7a2bfa2..284793c055d 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1046,7 +1046,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); @@ -1062,7 +1062,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 ()) @@ -1113,7 +1113,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); @@ -1129,7 +1129,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 ()) @@ -1192,11 +1192,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; @@ -1244,7 +1244,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) @@ -2535,7 +2535,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; @@ -2758,7 +2758,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 cf8cd527955..3901a1aae66 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 efe57cceae3..c9575e17749 100644 --- a/gdb/inferior.c +++ b/gdb/inferior.c @@ -731,10 +731,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 4fde96800fb..0fe9fd0c6dc 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" @@ -711,7 +711,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 (); @@ -4399,7 +4399,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 (); @@ -4772,7 +4772,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 @@ -6722,7 +6722,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 ()) @@ -8930,7 +8930,7 @@ normal_stop () else if (last.kind () != TARGET_WAITKIND_NO_RESUMED) 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 f91b2b62c1b..5f2a484a032 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 287df2c8c81..986110b9b6a 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 9148dda4aad..42991c71266 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -4003,7 +4003,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; @@ -4424,7 +4424,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 770fe924427..e9c3a1a7436 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 f7b8a594097..6dcc56cd562 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 0d3c8235c2c..a0e41006c56 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 f9af61f0a57..353c0c6d593 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 d750371f917..3fa36fc77ed 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 @@ -2097,7 +2097,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); @@ -2114,7 +2114,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; @@ -2132,7 +2132,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 (); @@ -2143,7 +2143,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); @@ -2514,7 +2514,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 acb05e9b535..5cf2d159096 100644 --- a/gdb/observable.h +++ b/gdb/observable.h @@ -124,7 +124,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 7c75bb5693d..c8f138f3b3e 100644 --- a/gdb/ppc-linux-tdep.c +++ b/gdb/ppc-linux-tdep.c @@ -1609,7 +1609,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 5e9c8a5b222..5afbc565cf7 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' @@ -2521,7 +2521,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 0e8a08f99d3..f8b88bf8754 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 a43fac98c43..c338636b3c1 100644 --- a/gdb/python/py-mi.c +++ b/gdb/python/py-mi.c @@ -146,7 +146,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 d3dea088c3b..5fc883745db 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -121,9 +121,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); /* The interface between gdb proper and loading of python scripts. */ @@ -1191,7 +1191,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) @@ -1268,7 +1268,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 abab79f3132..7a7d7617bc9 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 5acac2b8e47..c2802183fbe 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -596,7 +596,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); @@ -850,7 +850,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 961061e02a9..b405cb6abf7 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -915,7 +915,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; @@ -4074,7 +4074,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') @@ -11767,7 +11767,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); @@ -12732,7 +12732,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) { @@ -13999,7 +13999,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); @@ -14540,7 +14540,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) @@ -14740,7 +14740,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) @@ -14780,7 +14780,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 fd6b1e7a454..320e1bf2034 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); @@ -442,7 +442,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. */ @@ -472,7 +472,7 @@ solib_aix_current_sos (void) struct so_list *start = NULL, *last = NULL; int ix; - gdb::optional> &library_list + std::optional> &library_list = solib_aix_get_library_list (current_inferior (), NULL); if (!library_list.has_value ()) return NULL; diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c index c29b2b81b11..7b0adc1137e 100644 --- a/gdb/solib-dsbt.c +++ b/gdb/solib-dsbt.c @@ -281,7 +281,7 @@ static void dsbt_get_initial_loadmaps (void) { struct dsbt_info *info = get_dsbt_info (); - 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 7bc6ca45c37..2d7e9453827 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -453,7 +453,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 ()); @@ -586,7 +586,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. */ @@ -631,7 +631,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; @@ -1219,7 +1219,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); @@ -2426,7 +2426,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) { @@ -2637,7 +2637,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); @@ -2750,9 +2750,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 ca9478f2ec3..fe766544211 100644 --- a/gdb/solib-target.c +++ b/gdb/solib-target.c @@ -233,7 +233,7 @@ solib_target_current_sos (void) struct so_list *new_solib, *start = NULL, *last = NULL; /* 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 77b357cb42b..0d80bfc99d0 100644 --- a/gdb/source-cache.c +++ b/gdb/source-cache.c @@ -269,7 +269,7 @@ source_cache::ensure (struct symtab *s) if (!already_styled) #endif /* HAVE_SOURCE_HIGHLIGHT */ { - gdb::optional ext_contents; + std::optional ext_contents; ext_contents = ext_lang_colorize (fullname, contents); if (ext_contents.has_value ()) contents = std::move (*ext_contents); diff --git a/gdb/stack.c b/gdb/stack.c index 0b35d62f82f..efb36d0ea4f 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) { @@ -2503,8 +2503,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 5eb1638b781..a6236804b08 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 46547f8b0ae..7f67159b516 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 365743384e1..d61d5bb7815 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 { @@ -2601,7 +2601,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 @@ -2610,8 +2610,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 @@ -2621,7 +2621,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. */ @@ -2910,7 +2910,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 6853c143231..73df178e69d 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -2264,7 +2264,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) { @@ -2313,7 +2313,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) { @@ -2322,11 +2322,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) @@ -3008,7 +3008,7 @@ target_supports_multi_process (void) /* See target.h. */ -gdb::optional +std::optional target_get_osdata (const char *type) { struct target_ops *t; @@ -3250,7 +3250,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) { @@ -3421,13 +3421,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 446c0a9fdbf..1d7926bb962 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. */ @@ -994,7 +994,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); @@ -2199,7 +2199,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 @@ -2462,7 +2462,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 c8145da59bc..f97f2768fb2 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. */ @@ -486,7 +486,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); @@ -1089,8 +1089,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; @@ -1520,7 +1520,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 2c548688570..b1b31ad378c 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 c1ed491c558..ebd8bf0e2d1 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 a191d26a007..94a7cafa65b 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 b446afd72d8..e4d50d081c9 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 Fri Oct 13 14:44:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lancelot SIX X-Patchwork-Id: 77667 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 63BD8385697F for ; Fri, 13 Oct 2023 14:46: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-dm6nam11on2061.outbound.protection.outlook.com [40.107.223.61]) by sourceware.org (Postfix) with ESMTPS id 07C28385696A for ; Fri, 13 Oct 2023 14:45:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 07C28385696A 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-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ApR8eh+V7uTv4RgH2MzMEkv1epLMPiC8ox7rwLAbvnDtHAAUSn4E6dNAMdt+J7mi9JYOmzXAVPmdBBuXn5eYenl3e3hj/2tfuFhHMov+HBMZ0n7dvqjUwbOFy2mztodsSpjqHqvlmIWj11Y5zNZa8vmH0v2y60+2WS62dFu6z9hOFDij3kR90UmRqUDbrjNpBbabm9y52vtKuI4FRg1LemBsRHpgjFXUJrPzGc1Ms47V6P74irqXqleeEPNeiC6nVuf5YN3SiuM5i9TTdpKkKoj0f9IJHa/kxnwCyeCOs2vqGDkH1vH0ypfdlUAG+2SK1idPwgD0ArsVHCexHexuCg== 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=FkKwFK5M15g9XkwqMB+2vKRft39xZxTRhniHt4j1hAY=; b=cjEgJrMBA27NAElswOjizEFzThFiIqxFxUBCPLc9liZkvrzMtTMhojkd4N6SUGQC5lMcfqR1rAf+oR1d22DfCBuprqoQwBwPdpYhm9WdydY3GVKN/y8tVfitzbQ3sXK5MFUQcqvk9LAZXLSmc86UkAnxixUQESXzSVUusYlQINQt+khUbHn66uf+Q91vBn3e0uy47UqWQYZgriHeamoSBNgwjq5CG5ZpFU7yfJIA0mZXYYv2Hd8uzmTz2/8suYILEflQSddtKgGt9vL//cqfavVUyMsRx6TKD4pNcq/J96mEJ8ivmEJtK571Evbw2kA9N+sR4dQxy2XfF025TrFkoA== 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 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=FkKwFK5M15g9XkwqMB+2vKRft39xZxTRhniHt4j1hAY=; b=1z+dLuOlafWLh6MnDsDMz2DOXljnexp569KicG1LOSml0I0eSI+FBmaZmVOGbf+4LdmzynvESctqZk91lEHHPaOJY/0yaGguhP6vuifjdvOWHf4lPomI38QloD8wW5nzhuxbAxC9mq6VfNOMChRSCWWs+21VqtahlKeTl7Qgeu8= Received: from DM6PR11CA0012.namprd11.prod.outlook.com (2603:10b6:5:190::25) by PH0PR12MB8175.namprd12.prod.outlook.com (2603:10b6:510:291::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.42; Fri, 13 Oct 2023 14:44:57 +0000 Received: from DS1PEPF00017096.namprd05.prod.outlook.com (2603:10b6:5:190:cafe::46) by DM6PR11CA0012.outlook.office365.com (2603:10b6:5:190::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.27 via Frontend Transport; Fri, 13 Oct 2023 14:44:57 +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 DS1PEPF00017096.mail.protection.outlook.com (10.167.18.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Fri, 13 Oct 2023 14:44:57 +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.27; Fri, 13 Oct 2023 09:44:55 -0500 From: Lancelot Six To: CC: Lancelot Six Subject: [PATCH 05/11] gdbsupport: remove gdb::optional Date: Fri, 13 Oct 2023 14:44:12 +0000 Message-ID: <20231013144418.3180617-6-lancelot.six@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231013144418.3180617-1-lancelot.six@amd.com> References: <20231013144418.3180617-1-lancelot.six@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF00017096:EE_|PH0PR12MB8175:EE_ X-MS-Office365-Filtering-Correlation-Id: 9dd42192-8d63-43ae-69b4-08dbcbfaf854 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aW3TChXZB7j1NbPJFiv8kFFattBJ1AkYMHvkWsPQHCkcLJ7DIOzrNXBmVo3buSHsOHOFa1cja3j20HYHMH14EmTVKQqb1tjer7NJllrld0ihpUQ+CEzol7L+eBx1RP9MR7DdZT4b3551cuZkfgVnjSBS2fYscBRVtQHwUl5r4f4ylaA83mso3/euFMXgGn8hkVj78GiWdeHhErDHDIUARyEIU1hG7g3XOMteaj1m7FSHoZr5g8AR2Ci3wAQ3KTalgWNpyyky3KunJHK9QYZ8HQ8Wvxn9kykN7jiABJT1kWJy0XQjbQD5QpLNRlOu9tsWgVogMGflEv33nbn5tMO4KMbUIoJXx1XGXyfG5wFgH1DdD1l3IudP+KBZvNTxxuOT8h9F/KmvlW8odlAb+9Ug2V7Xg5x5D+HcLxqzUP9He9xWwqqpsfByFOzqo/6yTD2F6IB6dG5Q9ZGnnjyl17adl/dBOzpuueSKsdwdNum6WR4e1dr/dRgrHYjxxNyUrnxcHNh81aoG0JQpNAzK3UJ7vSzOGIP8F0Cb/GcHp698kIQgOAU2XJ6Z5qH2JJPg6H7Mc7EYUa+0GA8DRM7GF5vn84QRmn/kvFBBDYr4JMcV8qKTMgen0eC3vj3zxWPbSgZszuskRjmV1o1mydscTZ1AnDeYpfcseGA/WyNUFpqFKP0Eq2+/zLJ9lIP5cgHl9RpUsZhrkZN/ZQXoojbTaYuPPw1url7g93sp883PJPevMoFgViFhUpBfZT4JIIF3l5/oUz553iAE0z7tO3dZcRMnQA== 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)(136003)(376002)(39860400002)(230922051799003)(64100799003)(186009)(1800799009)(82310400011)(451199024)(46966006)(36840700001)(40470700004)(36860700001)(47076005)(426003)(336012)(83380400001)(26005)(16526019)(356005)(36756003)(1076003)(2616005)(7696005)(6666004)(81166007)(478600001)(82740400003)(86362001)(40480700001)(6916009)(70206006)(41300700001)(316002)(2906002)(8676002)(40460700003)(4326008)(70586007)(8936002)(44832011)(5660300002)(30864003)(2004002)(36900700001)(559001)(579004); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2023 14:44:57.0820 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9dd42192-8d63-43ae-69b4-08dbcbfaf854 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: DS1PEPF00017096.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8175 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 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 --- 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 9c0a0bff2cd..413ce1ea68a 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 Fri Oct 13 14:44:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lancelot SIX X-Patchwork-Id: 77670 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 4C3D1385697F for ; Fri, 13 Oct 2023 14:46:29 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2046.outbound.protection.outlook.com [40.107.94.46]) by sourceware.org (Postfix) with ESMTPS id 2D301385C6DD for ; Fri, 13 Oct 2023 14:45:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2D301385C6DD 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-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mKudPe5rAVkCLJam8Ho7rYIEFvbgEwCug3fsk4DmOC4mJB5dFyMJb2LqrCw/zxUe0pIqTO56bD0+WVnxNlMoFHc5YD/UvUAALkLj/q12t9B23sbv6ZA3XjhrqSmdmOaLsGZDhj/1oLfNbg/CIlltu9hXKCZQD34YsU0DBG4C+iXSay+zN/1HeonPPlsZ1+8pClaKLJX8JWAWZqs5jgBb96wj6C6pCbcarGuy5ITomGSHx0HNpVdQSey9O7lCSy/YAV//+nQmfl/5JV2V+HXLmrLjOfHvkrawH2sfMWg2KOJntvmARmcQ5uP2i7GGHuxXn69z7bEpt5CvVpS/GPOaFg== 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=dx0N0ZEZr/TB6h/jCHUuJZP5p+9EXsap/L0EtXufk4k=; b=ElikNT1uMgVrFtJ5Io0ISXNIgT8G0ZN5TLWRcX+LQ0mzKjmVfEgqFaUPG+2s+JZXohZEDt16x8V2j+aOGw8HaaDwHoKaOI8JskflWGdG/kdb4s9m/OY/4TaWU1HRCroE5K8YJPzP7hKDZDp7UV44IZIzsJpZ5dSei1Gmgkt3BaiGOG3NQFLo12Y9K8FaMvL900G+1rwGybuNSzEq7fE49UsXH2vMWWD1DWeT6ooaHIK11h3lG/mt+myRy4AczJbP6NP6PyaOiIjRWite6ozO6RP6QW1kvBVH+jfPjbCOZyFjdfFc4h9WVTYgPNc4X/JBl56y50valNQJ7MFXq5ii3A== 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 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=dx0N0ZEZr/TB6h/jCHUuJZP5p+9EXsap/L0EtXufk4k=; b=cDJR7RuxYpotBe3AEaImAN2QJDGQZMq57eZOJceu9hMhMPLRO6LCf8xPNlUzTaymReP6rgkVBUnWbjY+QRGKQ51K9GV2GzZcYkHICO0k0cxqzvMI3sVO4isU+W0YglfINXBKYBuCsaI2YXALowu5cXj3oJtCPHI1FcQb/ebTCcA= Received: from DM6PR11CA0007.namprd11.prod.outlook.com (2603:10b6:5:190::20) by SJ2PR12MB7865.namprd12.prod.outlook.com (2603:10b6:a03:4cc::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.38; Fri, 13 Oct 2023 14:44:58 +0000 Received: from DS1PEPF00017096.namprd05.prod.outlook.com (2603:10b6:5:190:cafe::76) by DM6PR11CA0007.outlook.office365.com (2603:10b6:5:190::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.28 via Frontend Transport; Fri, 13 Oct 2023 14:44:58 +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 DS1PEPF00017096.mail.protection.outlook.com (10.167.18.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Fri, 13 Oct 2023 14:44:57 +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.27; Fri, 13 Oct 2023 09:44:56 -0500 From: Lancelot Six To: CC: Lancelot Six Subject: [PATCH 06/11] gdb: Use std::string_view instead of gdb::string_view Date: Fri, 13 Oct 2023 14:44:13 +0000 Message-ID: <20231013144418.3180617-7-lancelot.six@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231013144418.3180617-1-lancelot.six@amd.com> References: <20231013144418.3180617-1-lancelot.six@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF00017096:EE_|SJ2PR12MB7865:EE_ X-MS-Office365-Filtering-Correlation-Id: f116f087-304e-4758-b1d8-08dbcbfaf8de X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rTymkXdaGAc5zsBAwmk/fwiqddXU5N8IR/7uv6H6NBychgP9HCDG99UQtYYC5wM2WJ4Lhdctocte1Gk0dgJpvpHtff5hBI1nK992OUNSICavJhoJAwqQYBiI3xqwsbRZvHwuEymEnCTMJGXezfK7QbjHJ04TqGEhuIrps9gTd80+OEKpbU5O4FBfuahip6TKBM0M33IDHPGMtV6oFAO1hO6VUw8bY8/QgcRTEc7Phm7/ryzJRHhTbi7L84105XtqXwMM06jwhMo6Gc2hCqQRwKOqxMRL0G3WCyauhWJMp6Q7V5uI0SWPanWSKRyZHb1Qyhr1nJHYO3CVaGp40P0Sa7aY38PyatEf01Y/34gi58A+kSRrf2Eqra2v76C/LQfTxTWpJvvpptlISbNjT1YXpBtO8RnNra0tKkjzg/0uvk001Ota0dmc3E0h7w1bUIlp6sQ3nwlWquEtFpFMKIl+zWIsETQgkaG+y922H90jN9Ynfh3Pkg5PRkCk/KN1EwDEs5o/rrelJW/iahTFJr1o0PaufvbODhhVM0QzMl6LQGalt7W3kjgPQ7KBAUKg6f68zBL5b1Nj6Oaj9AOtk2VXdeaqDkvG5XuWAzCJR/fkgsEI6AgzURjDDLwAYAR7WMm0dxGmkcWD87oRqxvoPrg85ADxY4ogH+p8BG9/8IB4lyKwwROQyEdHj0U1X4XmEqVJ/BQ/Zz39IhutHSGPX2i0jB7SimJdvK7AS/leUUXAzZkdHJmp5yvEJky8INzCZtBqD4UZhS9M7BZd0nDFkJ0J+Qh0LtpxqlqnJD2q6wNIslY= 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)(346002)(376002)(136003)(39860400002)(230922051799003)(186009)(64100799003)(82310400011)(451199024)(1800799009)(40470700004)(36840700001)(46966006)(1076003)(2906002)(30864003)(40460700003)(16526019)(426003)(15188155005)(336012)(2616005)(86362001)(6666004)(7696005)(16799955002)(478600001)(36860700001)(36756003)(26005)(82740400003)(356005)(83380400001)(40480700001)(47076005)(81166007)(44832011)(966005)(41300700001)(5660300002)(316002)(6916009)(70206006)(8676002)(8936002)(70586007)(4326008)(36900700001)(579004)(19623215001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2023 14:44:57.9257 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f116f087-304e-4758-b1d8-08dbcbfaf8de 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: DS1PEPF00017096.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB7865 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 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 The implementation and tests of gdb::string_view are unchanged, they will be removed in a following patch. Change-Id: Ibb806a7e9c79eb16a55c87c6e41ad396fecf0207 --- gdb/ada-lang.c | 8 +++--- gdb/amdgpu-tdep.c | 50 ++++++++++++++++++------------------ gdb/cli/cli-script.c | 4 +-- gdb/dbxread.c | 18 ++++++------- gdb/debuginfod-support.c | 6 ++--- 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 | 2 +- gdb/elfread.c | 8 +++--- 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 | 20 +++++++-------- 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 | 2 +- gdb/tui/tui-win.c | 6 ++--- gdb/xcoffread.c | 18 ++++++------- gdbsupport/common-utils.h | 8 +++--- gdbsupport/format.h | 4 +-- gdbsupport/gdb_string_view.h | 2 +- 30 files changed, 123 insertions(+), 123 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 58c70160d31..3e394619399 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -1035,7 +1035,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 +13250,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 +13269,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 +13326,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..48dc8db6bcc 100644 --- a/gdb/amdgpu-tdep.c +++ b/gdb/amdgpu-tdep.c @@ -237,7 +237,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 +270,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 +297,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 +326,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 +349,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 +365,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 +373,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 +394,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 +412,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 +439,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 +452,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 +467,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 +513,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 +567,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 +596,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 +620,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 +648,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..0e202ff5d96 100644 --- a/gdb/debuginfod-support.c +++ b/gdb/debuginfod-support.c @@ -246,11 +246,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 +266,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 e40353975c1..1846f7160cc 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -16884,7 +16884,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 7900dfbc388..e153dfcedd3 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -46,7 +46,7 @@ #include "auxv.h" #include "mdebugread.h" #include "ctfread.h" -#include "gdbsupport/gdb_string_view.h" +#include #include "gdbsupport/scoped_fd.h" #include "debuginfod-support.h" #include "dwarf2/public.h" @@ -197,7 +197,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) @@ -505,7 +505,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) @@ -519,7 +519,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/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 6dcc56cd562..c71f5a6dcd3 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 b24d0e8fb23..27cefb9604b 100644 --- a/gdb/solib-rocm.c +++ b/gdb/solib-rocm.c @@ -451,8 +451,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 (); @@ -460,7 +460,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); @@ -476,7 +476,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; } @@ -484,7 +484,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) { @@ -496,15 +496,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); } } @@ -514,7 +514,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 7f67159b516..408f8041bf0 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 d61d5bb7815..52fd9e23e6c 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..83218dc4797 100644 --- a/gdb/tui/tui-io.c +++ b/gdb/tui/tui-io.c @@ -1197,7 +1197,7 @@ tui_getc_1 (FILE *fp) Compare keyname instead. */ if (ch >= KEY_MAX) { - auto name = gdb::string_view (keyname (ch)); + auto name = std::string_view (keyname (ch)); /* 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..5330bbe361e 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 @@ -61,7 +61,7 @@ struct format_piece 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 Fri Oct 13 14:44:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lancelot SIX X-Patchwork-Id: 77664 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 D317738582A4 for ; Fri, 13 Oct 2023 14:45:27 +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-sn1nam02on2084.outbound.protection.outlook.com [40.107.96.84]) by sourceware.org (Postfix) with ESMTPS id E8746385772B for ; Fri, 13 Oct 2023 14:45:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E8746385772B 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-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Bd8h9J+n8XkNWtsUOo+UMiQwL6eCLXL+lvGCKB8ke54Gosxg3YPWJgXEpGfMBr1suqv8mrcVvmOrRF+MsEBmRAhFtT93QL+RcPWaL5qiC451uBYTJ6b8epCHtF5mzcSyR1H+LnJir9n2PU2ksHFAZm0jEHUe5EziBe5nA88ufleKAVIrOiyz5JnoXWRTIQVhVs/rJGBFHT//miwAteJhyUqzGBiYeJd9PQRasuHP6dxulADLvAOYJov63csA2Xn8WAfZzvntqxW335gbNTkTQO1miI6LiLPyC5sF3kVlg//ZDu5wone+AZ88HIPOJF3xN8TQZpH4BjLDOZymaW+gIw== 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=XnPbv+N8k82+O45WB4aF16C0DR/jN1onhxpSKqmwXu8=; b=AEgh3HwP3opb+uivHAmIeiInqciU+Evg8m2UNAyQBTY/51WyQ7LT0vMr0Lsc05sdAf4uaW19ogcu/KiIWlOmHlPo5s2Yx9DZg5vx63B6k62if2H9cJsOJaVl6zOMyGRlrPmU+Youc1Fw55igb4x1n6+SATdX8NRSGBSzXNnbBhOs/LcjKkWLxtYcOSjZp7PrDlD+MIvgXB9EW9TgtJ+T149qyjy22kKYG/jxB5ROEzf0h5Jvd+ZEPGfa6rqy6XZ0YiPJGua7PI7SAlSG6WCReh1frmmwU7l7UcgU/hxO4fnpU16iKxdJd83mwexki6oufGR/WFl/ySjgt3uWRtF1kw== 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 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=XnPbv+N8k82+O45WB4aF16C0DR/jN1onhxpSKqmwXu8=; b=oyCS0ZfsktTYUy4D38sOoqDrlq45pSjBntNX0js6zaWHl04H/dOJ4VtDNwzQPWt65iYxM+pPSGYT5hxwHKqhzqy9LCz0AQjmZvXWe7s3Ih/vro9bz86wk619KYqxlEuW3osqGPgT0WEP4S+kTOVOwRgac2364g3MZHW+3FW50G0= Received: from DM6PR11CA0015.namprd11.prod.outlook.com (2603:10b6:5:190::28) by PH0PR12MB7931.namprd12.prod.outlook.com (2603:10b6:510:289::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.44; Fri, 13 Oct 2023 14:44:59 +0000 Received: from DS1PEPF00017096.namprd05.prod.outlook.com (2603:10b6:5:190:cafe::ab) by DM6PR11CA0015.outlook.office365.com (2603:10b6:5:190::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.27 via Frontend Transport; Fri, 13 Oct 2023 14:44:58 +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 DS1PEPF00017096.mail.protection.outlook.com (10.167.18.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Fri, 13 Oct 2023 14:44:58 +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.27; Fri, 13 Oct 2023 09:44:56 -0500 From: Lancelot Six To: CC: Lancelot Six Subject: [PATCH 07/11] gdb: Remove uses of gdb::to_string (const std::string_view &) Date: Fri, 13 Oct 2023 14:44:14 +0000 Message-ID: <20231013144418.3180617-8-lancelot.six@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231013144418.3180617-1-lancelot.six@amd.com> References: <20231013144418.3180617-1-lancelot.six@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF00017096:EE_|PH0PR12MB7931:EE_ X-MS-Office365-Filtering-Correlation-Id: 9988dbcb-0e77-4e86-97b6-08dbcbfaf966 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UtI6FbQobh5qQlHoF02a8/vQ+g1igUYuf2atZnM9FjKv0xOt1JqYWPUdvirx44zr0X86eW9g2udM60lY9jepQoRlIh2HMyHJPC2RDqsbZ6TW4oynjz1JX34MGRI3hdpsY6XTvHSSaLM1+9FTF+Pn0Dbkng5eWaKgjd6ju6CjoDYnXv7sUYkkqUkAt72ca3/O1UNo5u6YSaJ9TfqK+fp5dot/dJD3xRgIOgjxQxPk6ZYEh2vcYMNoKh+3621v+0w12VMagmu4A28zZ+jESzuurJofXDQ2fV+cCrxVuRRgCywZqN8rZyYjbN3ki+xtBKhwF+E4S3bUducFHXBbd6Frw/KiV/3CtLAQAV/GV/6ZPc4CET7Cf4FAKtabh7L638vjJsclaGQbeNBD5k1BNKbpc4Fe3dldgFOhl5YP5C7YFoYVc8Cy2iFKdluwyu/kN+DxpaSX74JtUd1eGILtf4WqK/olsWHJhcylSdNYrwMDlMHfgAvyYaf6wOs+g0UaMf8rNx1Sy6D6d9Sc1fUXFZH1NFwYmAy1Ss3vtQqvlxxAAa58PsZnHyADj+/CJECIS1JeqGoDgKIhk4TpXY/0kqK1d0sok4h3DeuDKp4P7ybUMS6ZbvVb6ZmljyHQ+mxYk2XJFizHs9QPwBWSf0+ltNzgwOLB8GvzyyIr2Nkaa3UjP73dyDw/wPWwNPrZLIYTBGaAUmIiVFykYIrG9iheDGU/1B5prdSSC5dZ3Gb8zsKwCQiN/pa0HQ48y0JbLahk7BV4jU2OLoXtdSZ6H1hFh2Vm+Q== 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)(451199024)(1800799009)(82310400011)(186009)(64100799003)(40470700004)(36840700001)(46966006)(40460700003)(2616005)(26005)(16526019)(316002)(6916009)(70586007)(70206006)(1076003)(82740400003)(356005)(8676002)(36860700001)(8936002)(4326008)(40480700001)(36756003)(336012)(2906002)(426003)(6666004)(7696005)(83380400001)(86362001)(81166007)(478600001)(5660300002)(47076005)(41300700001)(44832011)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2023 14:44:58.8476 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9988dbcb-0e77-4e86-97b6-08dbcbfaf966 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: DS1PEPF00017096.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7931 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 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 --- gdb/ada-lang.c | 20 +++++++++----------- gdb/amdgpu-tdep.c | 18 +++++++++--------- gdb/debuginfod-support.c | 3 +-- gdb/dwarf2/read.c | 2 +- gdb/solib-rocm.c | 8 ++++---- 5 files changed, 24 insertions(+), 27 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 3e394619399..ff7222c7eed 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -1040,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, @@ -1081,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 (); } @@ -1135,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; } } @@ -13255,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; @@ -13276,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 48dc8db6bcc..15f32885b07 100644 --- a/gdb/amdgpu-tdep.c +++ b/gdb/amdgpu-tdep.c @@ -401,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); } @@ -445,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 { @@ -456,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); } @@ -470,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 ()) { @@ -533,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 @@ -579,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) @@ -592,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)); @@ -631,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) @@ -644,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 0e202ff5d96..eb88c406ad6 100644 --- a/gdb/debuginfod-support.c +++ b/gdb/debuginfod-support.c @@ -264,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 1846f7160cc..0973fb6fe13 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -16886,7 +16886,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/solib-rocm.c b/gdb/solib-rocm.c index 27cefb9604b..c39b5b8bdeb 100644 --- a/gdb/solib-rocm.c +++ b/gdb/solib-rocm.c @@ -454,7 +454,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 (), @@ -477,7 +477,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 @@ -563,7 +563,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; } @@ -580,7 +580,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 Fri Oct 13 14:44:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lancelot SIX X-Patchwork-Id: 77672 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 C3C10385697F for ; Fri, 13 Oct 2023 14:47:40 +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-dm6nam04on2080.outbound.protection.outlook.com [40.107.102.80]) by sourceware.org (Postfix) with ESMTPS id E0AB4385C6E6 for ; Fri, 13 Oct 2023 14:45:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E0AB4385C6E6 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-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G1nioMTh2df04MAYKhATaBv5gDQ+W71kZf5PeqaO5SSdoqn4Cpfmtezd9s3WWyNvi8ucVHuJ69JKZa+q7Sv5bKTaIz6rbbAN/IuVUFOdWufvrrrlDtkdpWWQhiovgl5VYLVsSS/YHdo7LchYj+rwKC8BPxF03MuTI6zFXJUqnK83rm9jQkooLHmjbn5uzPX6rCM8J/meQ+Ijn7pzdvmU7+pO6RK8kOTTyknimx93tY2gMhVYSRgnnz64lau3VFpWEeCnNuFN2bcRUCdYxfelVpPR9W0aePjGfypV1sjxlSXmsWhSy+T2aj+ltIDknDxFSTWgqp9RhvdjXkjyAgpwow== 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=hQ+5sXNTqAsHjr3Dt+hSln57TV0VLxvKAIhYgfETIT0=; b=HCOSq5FG5iPXJky3Q1Qkt2Sg0FYJa40tootq+XR8U8y5oxG0sO8HzdTn0HI5FLKtuGILe6BA7h3hrxsYePAavkTk1nDrH2mln5JsbgoVSexdqIaf1oPYCpn3gWGX6EKdHrJmCl8KesMKtEPHD2nMtnWm6j47gjQyA5LJ8tI9Rc8J9qDT5tnjRZHDth6mxASjYQ4RaAPe2cQxfHj9088VEZ0g+VZYHTKnhVeWwGJEGoUMrnk5967QrV4wjyrk3SmniHNRa/Xwv8E1Vy+XOLEYtCJR9FQaFfaYIyZqRlkTEG6u7TuV4tyjQknMwzawLKeudyjKBZ2BHR0Y1o0sC1419g== 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 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=hQ+5sXNTqAsHjr3Dt+hSln57TV0VLxvKAIhYgfETIT0=; b=io1OH2Tp2HRTrtAfM31psuVQn4nHLEpZB4f/zUnKZRJv0jIDecukSx2VVEqMq6luBU4ZZA2jsGTJ51+Wd0QnEevN1LJrQTKhLiXPzyn9ocKS2sIg9+O1FuX5FwpW8QymJWGlw8nmwMcvScxbfd90+elh6N1LsKQU+x+UIri8Oqc= Received: from DM6PR11CA0028.namprd11.prod.outlook.com (2603:10b6:5:190::41) by MW6PR12MB8898.namprd12.prod.outlook.com (2603:10b6:303:246::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.45; Fri, 13 Oct 2023 14:44:59 +0000 Received: from DS1PEPF00017096.namprd05.prod.outlook.com (2603:10b6:5:190:cafe::4e) by DM6PR11CA0028.outlook.office365.com (2603:10b6:5:190::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.29 via Frontend Transport; Fri, 13 Oct 2023 14:44:59 +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 DS1PEPF00017096.mail.protection.outlook.com (10.167.18.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Fri, 13 Oct 2023 14:44:59 +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.27; Fri, 13 Oct 2023 09:44:56 -0500 From: Lancelot Six To: CC: Lancelot Six Subject: [PATCH 08/11] gdbsupport: Remove gdb::string_view Date: Fri, 13 Oct 2023 14:44:15 +0000 Message-ID: <20231013144418.3180617-9-lancelot.six@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231013144418.3180617-1-lancelot.six@amd.com> References: <20231013144418.3180617-1-lancelot.six@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF00017096:EE_|MW6PR12MB8898:EE_ X-MS-Office365-Filtering-Correlation-Id: 21452df6-751b-4ad1-932b-08dbcbfaf9c3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 01qBbonOujqNEWeOFvsZcRDkBAeXqMy1fOd+TjAhwwz9LeCzHT3Ts/EjPt+5h2OWTLQoEKeLhdprabCKNOTo0rGv+GFYb/PljFJf2IPgNVsL1VxRtK0WOXt9H0FI0Ok9YBHYbOMFhEoK9UXFrgm6GdpsKgO0Qc86sWTiw88tVy8bYfvc/VHabb1+x04PxtQ850Rdc+uB0OmzWQj+9L1PtMpr0Mnv4aNR6stB0vjOXzcUvl0RhXyJJReDR32WxMiQXzw4acF/Gdhl3u3hg3B/cVD1HXmeGKsWQsySEsVirK8uaCOqgtqmb7c1qXrfcJ0t4Qrz6vyoIZuKmwkUfJD7ZAKkQL5LKwzDLiKGk85lWyEX/Qsw0vvtx1B7hJy99VCFclF25p26YL2BclegqZLWSpjZsMdNkoOOjKJUB4VlB6t3o49ZnSn5ii2gLNr+CXHsQAwkeYcVSMs+RRBnHVH3crg9X//LY1MZNVwkHdys6mLjFrR3GoxDK8Ttil9g7fbe2a+FckIr3e5utH+hke2gIGkFMJ2eDLhc4uOGiXaluAx3DkHGtpjcMAPfJ/ju0yQxp7qgfUGn1IZdQAh6Pf0SWWakcpMzg2RUu0x2f0mHSMzERfXea8mO6Xb3JSN2uVaOh3yqCaSlJig8VPCd6jRsJQM+Ita/J8+7O5nWkvi9URi0nAigiDtQaqLQzSsKqnXBZxacdsdVLiNBoucfpACZFBPpyrqXG2UC4mkZ8oZIqEdK3CwGXUfU7yO+Wmsydtq7aDtxm27Xos3t/KCn2kGmmw== 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)(376002)(39860400002)(136003)(230922051799003)(1800799009)(186009)(82310400011)(451199024)(64100799003)(46966006)(36840700001)(40470700004)(2616005)(40460700003)(1076003)(36756003)(82740400003)(86362001)(356005)(40480700001)(36860700001)(7696005)(81166007)(47076005)(83380400001)(426003)(336012)(26005)(30864003)(44832011)(2906002)(6666004)(478600001)(16526019)(6916009)(8676002)(4326008)(316002)(8936002)(70206006)(41300700001)(5660300002)(70586007)(2004002)(36900700001)(579004)(559001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2023 14:44:59.4101 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 21452df6-751b-4ad1-932b-08dbcbfaf9c3 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: DS1PEPF00017096.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB8898 X-Spam-Status: No, score=-11.5 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 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. Change-Id: Idf5479b09e0ac536917b3f0e13aca48424b90df0 --- 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 413ce1ea68a..1266686134d 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 Fri Oct 13 14:44:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lancelot SIX X-Patchwork-Id: 77666 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 C057238560AA for ; Fri, 13 Oct 2023 14:45:51 +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-bn1nam02on2055.outbound.protection.outlook.com [40.107.212.55]) by sourceware.org (Postfix) with ESMTPS id F133E3855591 for ; Fri, 13 Oct 2023 14:45:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F133E3855591 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-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RZtGCGj/W2uq0wHtKKy24p79r0luAMG3FkoMepPNMriAN2dk3cgre1a5q3UOX7gDpCFIgIdnoVBAzIodHzdUXHBSkVUz3I5YuYpxGz5M2uALrpP06LmvoPEiryEBKIUTPnrmrMVZ949DcJpDemb9aIm1bebWa3zDLLMtQIQjCW5ekMybL2rFfxCJRZWhPxEH9KjnYX2KbzA+xY9N+8lqnT2fEfl2xeRzs4untvBvLTXO9+rSdI7gEKjNWcOyR6r7o2dKyhuYqP8iwV649At0MvicRPo40WEpJ3U5Z0Omr8Vuf/es8NFzjzS5KnbzzBRDWK//0C+AZ9DIrlqJmAkQJw== 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=d6cg6jI5IW/GESbdd3kCMjTxAzQuhX/aW5phA8GQMeg=; b=E9wVdZfBPZKnBQPpplUQSMmnp8GWuOnTknBJZ9VQnM4IYStlzAL7pEsAUCGKxDmEnPibxAxwppBWL/oIL6+ytt9Zf/TKuGQzkouz+A3xUV/Gz/PZnaI/7DAUD1rX9KIXMg2n3c2dlONLzkib09FSIZD+1AuWAntnxE51XipRlOF9N2dYxmIGALKL463+xTpXxbLQZj6mWNLHMiwa9bZy736k62AmRIY4cGOLsvSKHEDd43TaIqcnwaBSC/ZQJUquyBuB+mYud7GmQlBVe4oPdw/c0r07FjPcpeygLGny1BJZDW/yJz2YKFd63e92E684DS3DlgRAcQPxO76UzNeEcA== 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 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=d6cg6jI5IW/GESbdd3kCMjTxAzQuhX/aW5phA8GQMeg=; b=pC+rqoK1G7iewD0011YXiqZeNKeaOtKqQ0lyM4pNakAV2VxeV6Nqxs7sGweCsaddn5LdWYBhiQ43+UUvumhIZCwvqprg2kzhYitwDASs5I8eCiqxcw6oCF57ZSzEjaI9QoqUWryYMi6EwKUUHEiqIZY2O8XEQSTl5czmL+HDx0I= Received: from DM6PR11CA0035.namprd11.prod.outlook.com (2603:10b6:5:190::48) by MW6PR12MB7070.namprd12.prod.outlook.com (2603:10b6:303:238::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.45; Fri, 13 Oct 2023 14:45:00 +0000 Received: from DS1PEPF00017096.namprd05.prod.outlook.com (2603:10b6:5:190:cafe::bd) by DM6PR11CA0035.outlook.office365.com (2603:10b6:5:190::48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.30 via Frontend Transport; Fri, 13 Oct 2023 14:45:00 +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 DS1PEPF00017096.mail.protection.outlook.com (10.167.18.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Fri, 13 Oct 2023 14:45:00 +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.27; Fri, 13 Oct 2023 09:44:57 -0500 From: Lancelot Six To: CC: Lancelot Six Subject: [PATCH 09/11] gdbsupport: Replace gdb::invoke_result with std::invoke_result Date: Fri, 13 Oct 2023 14:44:16 +0000 Message-ID: <20231013144418.3180617-10-lancelot.six@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231013144418.3180617-1-lancelot.six@amd.com> References: <20231013144418.3180617-1-lancelot.six@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF00017096:EE_|MW6PR12MB7070:EE_ X-MS-Office365-Filtering-Correlation-Id: 190e89fb-ce02-4e55-db79-08dbcbfafa4d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sjR4ZBENLupGjVE/l6PBCeQWriyjnv1qv5G5n0yPVtEJp8S2aWY+a2Mvc7+BUHOvnR26Cvivtreuq2K/Pqp7B8ZKK0QFQagHzPhZcuDt1s/u4I5z2uD8ZpXdSk1JZXVC+DC9DTSK82qXkj+OcVdBDNvS5qTbIB53FDuYshdM49R1UDZaDMRhrQZih3FefZaOl3WrDVGgRTHC/qnZ4rkoV2u+xfHOp0kFvKQbNRS/eilYd1HAP+AkvOFjDp0wSZfRkrCUYf+wqocZQEaoyttXOXZj4VJ/oWFoKVB/Gi5N5RGzkanUF/5Nt1iPfxL6gyIunt90zlWNjV+gQKWCQq9AjZ0vralLcUznHy/uYB/lR0mJPzg/XxFKOL9iiMczZg2VohPu6rFBrEhRwr4f66aptjH3ObCae8J33vUUVZQ3dhjLvHoR4rrYdnx6CkPgOel1N4on0JoCjznsmC1DtQ5Faw7Fqw9aQlfWobY2eACO6ptIoz6RR+XSTwI9TXrCjGtNITqa5MfmUaKiT+ZbQlTojxxXqwN0DSLevPfR91iLRVlOHXOzUI4PwvIQhKYi9LnvSsqfnc/4jYXSUnT4ZeMCZDyuQ8N/oo5DDqW6trW4rD5/2eZJYVrO5fTXNHgnOBlHe1X5GYPhcp1llmRo2loTweTGzmpR/t7ORaqR6fInta4p7BRNxdL8ZJplSCEpU+OWKnWIJkYIqqgU3Xfp5M3KLZATFX0eNgqeWdjYRuKcEChj350yijm1uFbz33OnpXZVm25UuJ3bXKOw2opTYORGeQ== 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)(136003)(39860400002)(376002)(230922051799003)(64100799003)(186009)(451199024)(82310400011)(1800799009)(36840700001)(46966006)(40470700004)(8936002)(8676002)(4326008)(5660300002)(44832011)(6916009)(40480700001)(70206006)(70586007)(41300700001)(316002)(40460700003)(47076005)(81166007)(356005)(82740400003)(1076003)(36756003)(336012)(16526019)(26005)(426003)(2616005)(86362001)(6666004)(478600001)(2906002)(83380400001)(7696005)(36860700001)(2004002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2023 14:45:00.3944 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 190e89fb-ce02-4e55-db79-08dbcbfafa4d 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: DS1PEPF00017096.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB7070 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 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 --- 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 Fri Oct 13 14:44:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lancelot SIX X-Patchwork-Id: 77668 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 8C0B63857707 for ; Fri, 13 Oct 2023 14:46:07 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2040.outbound.protection.outlook.com [40.107.95.40]) by sourceware.org (Postfix) with ESMTPS id 5BCD6385C6FC for ; Fri, 13 Oct 2023 14:45:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5BCD6385C6FC 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-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GogUF52Mt4aCxJuHgjeTnLvym/qNXo4WqefgGRKhTNoLioZYqey6rm0vzw/qtaqdENphxA5U+W+Y3Z1Fs3FGgjG4v7x/zkrqJHpvjWYNT9iDrXen19KzfXEVYM2WgR/usyXZh2hlK/Mh/Fi5euzVD8PYGnHztgyHwVS973C4IHYh+uTCI95C9kwanS2czr0bNdaT0J5tVd4dNHLDVAt2BlOjx1j39s/T59CF19JYNLKQUqO4K2/Fs3SfYptKkHQHsbYjXV6iNmc8q8TTXTGWzVarUkbQWk75HgYiKT9HxJfyeXWsphARJCtLsAhbarzqPfEZoys3nXvypCWQv9EsyQ== 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=kb31PWc9ZHKc+cmgohWCAMmv1P2QBNAQHtGUNM/QtyU=; b=EF7rATzDPMGceW7H0UzQPKgPGNa5tz2g3KE6qWvePo8HFAIn9l9hCT2qEMvrkbn4L2y9LcCNkv+nIveJokeWF5VjBajc/FGwlzbW4mRIocyfChFH5OUlHUz1wrYyPXEjoVzRnnKEoDu4AROViuI8z+IdRohP9F2giGY4AqtEJZPg8KEmR5LZNgFwI8IxIX33BXtl7JYTW2i3kjZtmBbfNrU6zjLGJxvdsevxK7+6B7Oo0ZnJQlSb3Y9Z9cJDo8OulUa+207x0GDIKHIDMEGwwGG0YF6BxoFPE/fXCo0OpYhSZFrYYjq+nVge3RmveHkOD8YinsDu7fxJht34s2F8tw== 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 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=kb31PWc9ZHKc+cmgohWCAMmv1P2QBNAQHtGUNM/QtyU=; b=MPfR2rz4Dm/wEtIFYbU2/SXeM2O7qHxgQ/5kwivzEMhG+U2hUm+9wGQEKOVMApFBFxoXVF7aFxmoWGMe5V4+SjBA0SJZ3CrcWO6H2Dq5w05D15/ePrGSGA3vL2sEhKyTN1RsgD+68siXs52YkD0snvI7ckZAL/jEbgVKTbKAT/M= Received: from DM6PR11CA0018.namprd11.prod.outlook.com (2603:10b6:5:190::31) by DM4PR12MB6446.namprd12.prod.outlook.com (2603:10b6:8:be::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.44; Fri, 13 Oct 2023 14:45:01 +0000 Received: from DS1PEPF00017096.namprd05.prod.outlook.com (2603:10b6:5:190:cafe::67) by DM6PR11CA0018.outlook.office365.com (2603:10b6:5:190::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.27 via Frontend Transport; Fri, 13 Oct 2023 14:45:01 +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 DS1PEPF00017096.mail.protection.outlook.com (10.167.18.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Fri, 13 Oct 2023 14:45:01 +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.27; Fri, 13 Oct 2023 09:44:57 -0500 From: Lancelot Six To: CC: Lancelot Six Subject: [PATCH 10/11] gdb/disasm.h: Mark callbacks noexcept unconditionally Date: Fri, 13 Oct 2023 14:44:17 +0000 Message-ID: <20231013144418.3180617-11-lancelot.six@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231013144418.3180617-1-lancelot.six@amd.com> References: <20231013144418.3180617-1-lancelot.six@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF00017096:EE_|DM4PR12MB6446:EE_ X-MS-Office365-Filtering-Correlation-Id: 995f8489-640f-498f-7320-08dbcbfafac7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rHKO8j+hE+awJrQFZTZSF00JCOQ6hxtd2/ICSi36z6IumJCQIrvYmYTnC9TRMb+1AUb7bo9YwbJnxotMXQ137IfcxTXWNZ/uNU1EdZlI0SlWObXGNGBVnqq2sFM3W6QOOa1Nwxbb6pa6bWqt/wCHqznsON+ndzEwYOmDw+i7YVM1A4GxdpwsKhZ9I0b9cKepJtxAhQq+YFlLyEPODsZ+eJ87GNfvN26FNALCMeqfZ+6qO8K2d3KUR9I12ranIxEHMrWAQyFFsraYieYR+MEf/HnMdLxRvUh03a2H2eGutNxfJaKQaxbWi9dBW6KidD25oGMzTu8lSY4eDzL5wqPg1NpVUlilsyRV4v/wvdySporKjIhY1p/h0PDJHVyW2dCatDeS43bMc7tdrVmzd9lRvefjfd+EbzLQ2Lvu5UL+3O8F2LWWABSGVSN0VG8EIuF5xzD9Oa+DgW+g4ENxuWfhfoGy8HE4VMoUYxOuX4fjsmVS1ptlsW6SpN5SvoH/shHrC6KiVbX8v1HOtYJhfn90glaSKRnQwle22N5fRYNRr2FU6Lnxzqyr+NfHLwseCEAM8RQ1jiZyisZ1HhcfO0UCSyEuRaf3b7gVLbyzATn4yvYwbcr4VU4h3fAyFiRFcpvcaEg0MpiVQnp14O5JLHazNEHUVm43j2BG14lSb1FTJu9zw39TDuKeorao4qGGC0ExuMQr7htuE2DZaFIQOmxdi0ljMZnJx4sdp685MWf/4IVpbLIWbpz0tM8gC4+jVZtgESiAweCF55xef4eM7ACmkw== 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)(346002)(396003)(136003)(376002)(230922051799003)(451199024)(82310400011)(64100799003)(186009)(1800799009)(40470700004)(46966006)(36840700001)(40460700003)(82740400003)(5660300002)(356005)(41300700001)(8676002)(44832011)(81166007)(4326008)(8936002)(40480700001)(2906002)(86362001)(36860700001)(426003)(2616005)(336012)(1076003)(16526019)(478600001)(47076005)(7696005)(6666004)(36756003)(26005)(316002)(70206006)(70586007)(6916009)(83380400001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2023 14:45:01.0976 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 995f8489-640f-498f-7320-08dbcbfafac7 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: DS1PEPF00017096.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6446 X-Spam-Status: No, score=-11.5 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 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 GBD, update gdb/disasm.h to define callback function types noexcept unconditionally. The pre-C++17 configuration is not supported anymore. Change-Id: I0a38e22b7912c70a11425363a991f0b01614343e --- 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 Fri Oct 13 14:44:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lancelot SIX X-Patchwork-Id: 77665 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 BEE8F3857713 for ; Fri, 13 Oct 2023 14:45:45 +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-dm6nam11on2042.outbound.protection.outlook.com [40.107.223.42]) by sourceware.org (Postfix) with ESMTPS id CDF993857703 for ; Fri, 13 Oct 2023 14:45:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CDF993857703 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-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IJqc818gY6LbbbbUrnsKKfXmrQqu2QeuPlN+KOZrKTLqkcSS3o1ooeMGhDzfuN32JPgBYGVZ3tj75i7xNWmnEcT7gxeF2G8aZhA3iUZINWSNtSFeIA9dky3d29l6varmwYJbp439IUzVuai2rYM000RcBQzMZ/y0x8mjzPMKv7qOCBMdpBBiq/G964xUXUabHERkZKY0nvdx62ucYLWHWHiNLEhc4FA78ntXpkDjUXYSWF8k5/R8Hl123Z1OJdks1nnqzU+Yy9NLQycDB31sHr3qzl4X+R8aEF1VV+I7I8e/ssilyFQ0OHanvKexwjy4i6Tj/JhXTOTEh3ovH5p5Gg== 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=xwqRpZ9+aWM1tTs3zjfI1DXn5aRx531Ace789KEJ4Fo=; b=RbG/lyZnOL+F57zXnSq7BBrbZVIfNh7UswIc4LRXJqtMe33ML/RvrNy8yCHtsTxFaI5X6PWUE9Bi7PadyL2ZUhGadZbs6ug9H2TCr10ZBVssDu5zSnQvUWHjIUcYEwMaJh1e3pAL+q79GEgQrbY7fi2DC8yJHv35X4mjx7uG1I8gzVbk0Iaovn8pZlaLmGe6bnwJhrpmT+LtIKgqeC7cQwMg7nh8Y35Bk8sluRBazFSVs9PyoC83vj4CuZtkkloZfWAbssymBQ3ODmnw1u/CXyz27AjyEGROVZ5vDQph5kz6wykWWRcekKHB3doxpuPP0MTSp+lpSilQ8XaHPxojmQ== 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 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=xwqRpZ9+aWM1tTs3zjfI1DXn5aRx531Ace789KEJ4Fo=; b=KJ0psF4b5VKYSnhQp+qZfp13LPMl61vlE2XFiX7XCnwEvUiBCurtVTzNgN1/rFGma4To+W5hGdEOo5MuoS6CotkAfYGJv5zoWRAFnqMD4U4HdlGlE5kQT+dmu1glrM+yYuu6hbS+gc8QOXcqREx/3d6bGKXbg87P+aUjBg6w5lU= Received: from DM6PR11CA0031.namprd11.prod.outlook.com (2603:10b6:5:190::44) by IA1PR12MB7735.namprd12.prod.outlook.com (2603:10b6:208:421::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.40; Fri, 13 Oct 2023 14:45:01 +0000 Received: from DS1PEPF00017096.namprd05.prod.outlook.com (2603:10b6:5:190:cafe::25) by DM6PR11CA0031.outlook.office365.com (2603:10b6:5:190::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.30 via Frontend Transport; Fri, 13 Oct 2023 14:45:01 +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 DS1PEPF00017096.mail.protection.outlook.com (10.167.18.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Fri, 13 Oct 2023 14:45:01 +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.27; Fri, 13 Oct 2023 09:44:57 -0500 From: Lancelot Six To: CC: Lancelot Six Subject: [PATCH 11/11] gdb: Use initializers in lambda captures unconditionally Date: Fri, 13 Oct 2023 14:44:18 +0000 Message-ID: <20231013144418.3180617-12-lancelot.six@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231013144418.3180617-1-lancelot.six@amd.com> References: <20231013144418.3180617-1-lancelot.six@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF00017096:EE_|IA1PR12MB7735:EE_ X-MS-Office365-Filtering-Correlation-Id: 97ac8a36-3f89-4cbb-0de3-08dbcbfafb03 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2XY0s0l+fJSwyKHT2KoGq0mLFbFOXR0Dy1rck+YDv1PIHIQaBSG8pzNUUnOoH0fFq/2ov0tdS6bT7QuVN6NubC4VvE8VPSIbYp2OK4JHt9oGQVlqT+9jwpNcvVleW7G+y5ss6kMSQigibiPYB1PxlkR+zI/fk/SkHE+GXAa2X/+zwg66kFzbaEY77Tc10E4EUq4XjDfhy9XhyoZab9EFJwMNZTqqItLWx8SQWLZNHoovaTbUnHUGdJTsrS2MRjMsuXydbv+RtuqttJsG0O7Z45adLftA/z/aVI9jOna0jJCsUK/E+zfyPoyDE+Oa1hAEQCvtEa3XohOdjCdLEuSKlN5CDCO814h3sav31ImnO0EhRmlrprDczqskVUebgJCraii2g44M2Br8AP9U8jBgXsTG8Hf4JQZKzDRhPH8pNLeuQASWkK24gALmxBskifZ2ivz3RXbWPeBtxrKAYI1SbyST1a5D4e31VyzsAamjR/8k9jWtV8mgnMQUEq3izvBt1CF8N91bpzq0m5Lq8IuBnrV171QqbcxvcYMZAjuqZw0aFlROitfkVaHTElEpNcE99ruTl2hjSOHHTShDqkDCZD1if2mqCvKlSrZEyzzVoqzD21WRXhwYAhN8CkpzGYb8i/QXKgjH72OA473rp26OYNIgIqPaBxMkZyRkzfQyBbmwiQhrSIxRNgg42bZ7s5LSndM6H4knBlmNBGflwKtE98QnbPDsfoxWiuRWH6hHasP3SmNZIV51EqD/Q9xPOpDDfzVQ5vIG/rDL6c3va3p2Qw== 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)(376002)(396003)(136003)(39860400002)(230922051799003)(1800799009)(64100799003)(186009)(451199024)(82310400011)(36840700001)(40470700004)(46966006)(2616005)(82740400003)(40460700003)(1076003)(44832011)(86362001)(40480700001)(356005)(36860700001)(36756003)(336012)(6916009)(47076005)(83380400001)(2906002)(81166007)(6666004)(8936002)(426003)(7696005)(478600001)(16526019)(26005)(4326008)(41300700001)(316002)(8676002)(70206006)(70586007)(5660300002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2023 14:45:01.4882 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 97ac8a36-3f89-4cbb-0de3-08dbcbfafb03 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: DS1PEPF00017096.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7735 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 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 --- 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 579f09303c8..882acfb62a2 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -1658,13 +1658,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); });