From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 4Tr2KgrwVGoyPAYAWB0awg (envelope-from ) for ; Mon, 13 Jul 2026 10:02:50 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=LMQ9cx5E; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id ABB951E09B; Mon, 13 Jul 2026 10:02:50 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id C88191E033 for ; Mon, 13 Jul 2026 10:02:49 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9C4424BA23C7 for ; Mon, 13 Jul 2026 14:02:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9C4424BA23C7 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=LMQ9cx5E Received: from CH5PR02CU005.outbound.protection.outlook.com (mail-northcentralusazlp170120005.outbound.protection.outlook.com [IPv6:2a01:111:f403:c105::5]) by sourceware.org (Postfix) with ESMTPS id 10D4A4BA2E31 for ; Mon, 13 Jul 2026 14:00:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 10D4A4BA2E31 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=amd.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 10D4A4BA2E31 Authentication-Results: sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:c105::5 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1783951260; cv=pass; b=L30W0LCJngLSrJHif9Teh9e+mTFOM7vHJYINFgVwT3JMxTBA7o10khWRQ38eOUCVwqw+zPpqK1o+jR+iyKqLBo8k7ei0oTKXmzPqWjOvmxk4sU8+VeffherIeSyjzI1QQ3cTi/fCgR5bS5NR3wjd20+bV7sKNmrVH4PzDXufdkY= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1783951260; c=relaxed/simple; bh=4n1Lmmkt55Wijcdn5jysuOlFmn8XLL2B53xILhznyuI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=NHN1cpxbaXcM91oTkGA9L7OOCGVti/dOav4EOGm0Bhm3azIYtge4X+dzYuJfaTWI4s7vUyi6LNOzxksU/MRzTgpqEflsF8kaD6pshMSRLj4Xcp5wItYpbvJ4tsoJj89GuCxOpsR7FUHdqvAtLlz38hRT3t51nldz3vIEd3EeDuo= ARC-Authentication-Results: i=2; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=LMQ9cx5E DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 10D4A4BA2E31 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QUWgiUlavVFzPaUngXV600cdhQyO/5o4jKfygEZ1OJP7jio8EMCt8SQVCBGt/7YWKIjpfJ60n+qNJH3R4csCBp9Aup6pQOFJTxHwGQT5nHMyItd3BU7lVEHiWlAu54ZfvxmkQb3JpZ3sMvERZaioFg7XCJl2j7XqurRbTDMDEz2hFneZwm4VI8G/rXctia668tUooPnO//kDqAvDB5ChF5lAW29LAi0ZdGiN+gPODYbU/mzZA11BJUXXJciAPFYWD02IHYPqn4ZoUr1YYY5tmMwtwuDkUZfChsa4eW+3+UJR/lMijv0GbaSlhWeT+UbJHLMOGdrEOso9qcR4K/03uA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=v4U1hm1jWA8rtK5SMRp6o99KHVACtUXgXiHtRIfIdwE=; b=vz5/RsbDm8iPbB5yyA6EHzKJeVshID73ueyAQq0lXqcVvGL9jH4b/9aOqLmeSxoAKuJWg8pHio5+52EYHKJHoRIVD8/hCVmrf/ROUvN2YI4+bvoAsSmdZgM4Wt4vofawtBTItizQYVqTr5VHosh2BuG+OzWYrqMU3Cn4si3aFl1I+yoXBSRSeaX8Z3KogWQ9d2aMMgnGY8N6Ya3wI2074QYKmkqpXwvUfg/1evxB2Gye9efOuzo+0xRjCmNtYkplBN3CaQ4XBK6HEXrVQV/iEP0Cw+mA4MoVQuzN8NKD7yUKfsSr1Pmc+Wcj12/XYAkkxS62yrQl1LtbJ/Yk2Od/Hg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=sourceware.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=v4U1hm1jWA8rtK5SMRp6o99KHVACtUXgXiHtRIfIdwE=; b=LMQ9cx5EeM1vO0cOEw64Tp7zJVa7bhHBJQBXTsu9I9lOl7A06+pUAzJQ41xfp1UxRuEY0iepYWFjoq/DUAkH6VO8ictL1p8BwkM1ikp1kFzafNj2vpcdTxixekP9NJCSgH+L7raCiQn+WZPu/M9ogmOJIK5jOY6NTjzzZ7V+zo0= Received: from CH0P221CA0012.NAMP221.PROD.OUTLOOK.COM (2603:10b6:610:11c::16) by CY1PR12MB9627.namprd12.prod.outlook.com (2603:10b6:930:104::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.181.8; Mon, 13 Jul 2026 14:00:50 +0000 Received: from CH1PEPF0000AD7C.namprd04.prod.outlook.com (2603:10b6:610:11c:cafe::6b) by CH0P221CA0012.outlook.office365.com (2603:10b6:610:11c::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.202.19 via Frontend Transport; Mon, 13 Jul 2026 14:00:50 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CH1PEPF0000AD7C.mail.protection.outlook.com (10.167.244.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.9 via Frontend Transport; Mon, 13 Jul 2026 14:00:50 +0000 Received: from ctr-rack32-mi300x-1.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Mon, 13 Jul 2026 09:00:42 -0500 From: Tankut Baris Aktemur To: Subject: [PATCH 09/16] gdb: convert TYPE_CONST macro to type::is_const Date: Mon, 13 Jul 2026 09:00:08 -0500 Message-ID: <20260713-users-aktemur-type-instance-flags-v1-9-779cad0c85ec@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260713-users-aktemur-type-instance-flags-v1-0-779cad0c85ec@amd.com> References: <20260713-users-aktemur-type-instance-flags-v1-0-779cad0c85ec@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.15.0 Content-Transfer-Encoding: 8bit X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD7C:EE_|CY1PR12MB9627:EE_ X-MS-Office365-Filtering-Correlation-Id: 3e415929-b10a-4315-df8a-08dee0e72559 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|23010399003|36860700016|82310400026|376014|1800799024|3023799007|18002099003|11063799006|22082099003|56012099006|6133799003; X-Microsoft-Antispam-Message-Info: LaJDhPW+0sFL+sECKV16S6a9GV92a7OjdqCb7LVj3GxEsffSptNN0yPVymADiG9Y1Rpgu7CGjlSDHmcyIOXNcm1pTdKD3vunQIsvDBGS4NslMy1Cm14Wrzix7q22LGMqLFBW3Uhftf08UNvgrXbVD3oUac+PfsnWPHEpQzid9+VWfpDUF+4cvXUbXozyYeE7eUJSpl74tF2FmKRLXDkc2uRCd/eEcY1JMM4BnKKCbEoMLnYlweNIEsqiluOdO2DYAVigCEEcv1evX1EhNJsDni1yOYX9hKaWfSzk54f9nNa5QlkjfpuLoojlIwq+vUZRCnyBI1BDijoZG2L3NBN8qHrrfb8dGgrBoMZVizbY8ALSOCvQj7OUrnUKZNMBzZIGgfWAlSwS/1iilq86aCBBNsJUjnb3nJSHyFwrz3nPIn/hyCKb7WGAz4Aq3FEUG5Z+e91+uvKAC0GYLeJ98JH3g24Tc49N/qa3Sb40T/y9rZCZWNzqUthew61jK/fuqq3h/76CoL5fSO4GgFIUwdURDJaQmTsVjSfZBFpt77DaSIYfvCKu+hp/ULtZMyzvI7rvGd76gAuj6e88ebgdJSmoVzgLstrDLI96H/6IEocgAwW57DSVrL0KrCNdgfHWsiSxvuKzuu6NOx7TfNj+p0FdeOB1I8YJzjS4UAd2YFz6jawUYmVvVRgvZcf4+CF1fqSUwSLUpDA6I2uflf8HCDiJzQ== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:satlexmb07.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(23010399003)(36860700016)(82310400026)(376014)(1800799024)(3023799007)(18002099003)(11063799006)(22082099003)(56012099006)(6133799003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2TUwK2n9PpiTwfrkEtAksBNfpJh93ZpXIXt5strmLBR1Ch/vd4NtBgxOxdZKe75A9To3OSKAvspiVG79b4pt/V+i8t/Y9uFI7su2XG02vJ8JiLqTw5srybRDAjTHwiddJx6KUK+Sxem+OW06K3ONtKd9QW38CHEy4tmzFPzhI+eht6HpVvQQkwUKDi0NCY5HLIx2uOSdQhC7B4cTSabXpIPTAisLU5weyPOSETbDnV4PemGC/dQPVhiX5CIAI5vhE14dUYzIxTda03UYRE3Ciic/sy3uzWpfFdNliMAC7jLKoA9N447KINAQpIAG5JwSlHP1yhpdtg9tw4ukOrVbQhYa7TSIpdSXNbMfDFjcdHh3FNwW5do+39TY0omfkLZmWVQCaNFujznUQ63juYfelZrIplwaU5kssPh6nblyoSE5xOCAUPj0dz5UfH1DrCKe X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2026 14:00:50.1365 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3e415929-b10a-4315-df8a-08dee0e72559 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD7C.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB9627 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Convert the TYPE_CONST macro to a method of the type class. This is a refactoring. --- gdb/c-typeprint.c | 4 ++-- gdb/compile/compile-c-types.c | 4 ++-- gdb/compile/compile-cplus-types.c | 6 +++--- gdb/ctfread.c | 4 ++-- gdb/dwarf2/read.c | 8 ++++---- gdb/gdbtypes.c | 12 +++++------- gdb/gdbtypes.h | 7 ++++++- gdb/m2-typeprint.c | 2 +- gdb/m2-valprint.c | 2 +- gdb/opencl-lang.c | 2 +- gdb/python/py-type.c | 4 ++-- gdb/type-stack.c | 2 +- gdb/valops.c | 6 +++--- 13 files changed, 33 insertions(+), 30 deletions(-) diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index e3096a7859b..34cf038fb0d 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -311,7 +311,7 @@ cp_type_print_method_args (struct type *mtype, gdb_assert (args[0].type ()->code () == TYPE_CODE_PTR); domain = args[0].type ()->target_type (); - if (TYPE_CONST (domain)) + if (domain->is_const ()) gdb_printf (stream, " const"); if (TYPE_VOLATILE (domain)) @@ -449,7 +449,7 @@ c_type_print_modifier (struct type *type, struct ui_file *stream, /* We don't print `const' qualifiers for references --- since all operators affect the thing referenced, not the reference itself, every reference is `const'. */ - if (TYPE_CONST (type) && !TYPE_IS_REFERENCE (type)) + if (type->is_const () && !TYPE_IS_REFERENCE (type)) { if (need_pre_space) gdb_printf (stream, " "); diff --git a/gdb/compile/compile-c-types.c b/gdb/compile/compile-c-types.c index af9dea730eb..2e5ca12a61b 100644 --- a/gdb/compile/compile-c-types.c +++ b/gdb/compile/compile-c-types.c @@ -247,7 +247,7 @@ convert_qualified (compile_c_instance *context, struct type *type) unqual_converted = context->convert_type (unqual); - if (TYPE_CONST (type)) + if (type->is_const ()) quals |= GCC_QUALIFIER_CONST; if (TYPE_VOLATILE (type)) quals |= GCC_QUALIFIER_VOLATILE; @@ -278,7 +278,7 @@ convert_type_basic (compile_c_instance *context, struct type *type) { /* If we are converting a qualified type, first convert the unqualified type and then apply the qualifiers. */ - if (TYPE_CONST (type) || TYPE_VOLATILE (type) || TYPE_RESTRICT (type)) + if (type->is_const () || TYPE_VOLATILE (type) || TYPE_RESTRICT (type)) return convert_qualified (context, type); switch (type->code ()) diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c index ff25fc62c8b..90ef1bda2cb 100644 --- a/gdb/compile/compile-cplus-types.c +++ b/gdb/compile/compile-cplus-types.c @@ -669,7 +669,7 @@ compile_cplus_convert_method (compile_cplus_instance *instance, gcc_type class_type = instance->convert_type (parent_type); gcc_cp_qualifiers_flags quals = 0; - if (TYPE_CONST (method_type)) + if (method_type->is_const ()) quals |= GCC_CP_QUALIFIER_CONST; if (TYPE_VOLATILE (method_type)) quals |= GCC_CP_QUALIFIER_VOLATILE; @@ -1066,7 +1066,7 @@ compile_cplus_convert_qualified (compile_cplus_instance *instance, gcc_cp_qualifiers_flags quals = (enum gcc_cp_qualifiers) 0; gcc_type unqual_converted = instance->convert_type (unqual); - if (TYPE_CONST (type)) + if (type->is_const ()) quals |= GCC_CP_QUALIFIER_CONST; if (TYPE_VOLATILE (type)) quals |= GCC_CP_QUALIFIER_VOLATILE; @@ -1126,7 +1126,7 @@ convert_type_cplus_basic (compile_cplus_instance *instance, { /* If we are converting a qualified type, first convert the unqualified type and then apply the qualifiers. */ - if (TYPE_CONST (type) || TYPE_VOLATILE (type) || TYPE_RESTRICT (type)) + if (type->is_const () || TYPE_VOLATILE (type) || TYPE_RESTRICT (type)) return compile_cplus_convert_qualified (instance, type); switch (type->code ()) diff --git a/gdb/ctfread.c b/gdb/ctfread.c index 5f8c54a34df..b40d3de6763 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -757,7 +757,7 @@ add_array_cv_type (struct ctf_context *ccp, } el_type = inner_array->target_type (); - cnst |= TYPE_CONST (el_type); + cnst |= el_type->is_const (); voltl |= TYPE_VOLATILE (el_type); inner_array->set_target_type (make_cv_type (cnst, voltl, el_type)); @@ -857,7 +857,7 @@ read_volatile_type (struct ctf_context *ccp, ctf_id_t tid, ctf_id_t btid) if (ctf_type_kind (dict, btid) == CTF_K_ARRAY) return add_array_cv_type (ccp, tid, base_type, 0, 1); - cv_type = make_cv_type (TYPE_CONST (base_type), 1, base_type); + cv_type = make_cv_type (base_type->is_const (), 1, base_type); return set_tid_type (ccp, tid, cv_type); } diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index ce4d6ca8675..067561b6e48 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -5178,7 +5178,7 @@ dwarf2_compute_name (const char *name, if (type->num_fields () > 0 && type->field (0).is_artificial () && type->field (0).type ()->code () == TYPE_CODE_PTR - && TYPE_CONST (type->field (0).type ()->target_type ())) + && type->field (0).type ()->target_type ()->is_const ()) buf.puts (" const"); } } @@ -12176,7 +12176,7 @@ add_array_cv_type (struct die_info *die, struct dwarf2_cu *cu, } el_type = inner_array->target_type (); - cnst |= TYPE_CONST (el_type); + cnst |= el_type->is_const (); voltl |= TYPE_VOLATILE (el_type); inner_array->set_target_type (make_cv_type (cnst, voltl, el_type)); @@ -12222,7 +12222,7 @@ read_tag_volatile_type (struct die_info *die, struct dwarf2_cu *cu) if (base_type->code () == TYPE_CODE_ARRAY) return add_array_cv_type (die, cu, base_type, 0, 1); - cv_type = make_cv_type (TYPE_CONST (base_type), 1, base_type); + cv_type = make_cv_type (base_type->is_const (), 1, base_type); return set_die_type (die, cv_type, cu); } @@ -12521,7 +12521,7 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu) expects. GCC marks THIS as const in method definitions, but not in the class specifications (GCC PR 43053). */ if (cu->lang () == language_cplus - && !TYPE_CONST (arg_type) + && !arg_type->is_const () && ftype->field (iparams).is_artificial ()) { int is_this = 0; diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 0ece07cee9b..6726857f047 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -4314,7 +4314,7 @@ rank_one_type_parm_ptr (struct type *parm, struct type *arg, struct value *value if (types_equal (t1, t2)) { /* Make sure they are CV equal. */ - if (TYPE_CONST (t1) != TYPE_CONST (t2)) + if (t1->is_const () != t2->is_const ()) rank.subrank |= CV_CONVERSION_CONST; if (TYPE_VOLATILE (t1) != TYPE_VOLATILE (t2)) rank.subrank |= CV_CONVERSION_VOLATILE; @@ -4700,7 +4700,7 @@ rank_one_type (struct type *parm, struct type *arg, struct value *value) lvalue references. */ if (parm->code () == TYPE_CODE_RVALUE_REF) rank.subrank = REFERENCE_CONVERSION_RVALUE; - else if (TYPE_CONST (parm->target_type ())) + else if (parm->target_type ()->is_const ()) rank.subrank = REFERENCE_CONVERSION_CONST_LVALUE; else return INCOMPATIBLE_TYPE_BADNESS; @@ -4727,7 +4727,7 @@ rank_one_type (struct type *parm, struct type *arg, struct value *value) } /* Make sure they are CV equal, too. */ - if (TYPE_CONST (t1) != TYPE_CONST (t2)) + if (t1->is_const () != t2->is_const ()) rank.subrank |= CV_CONVERSION_CONST; if (TYPE_VOLATILE (t1) != TYPE_VOLATILE (t2)) rank.subrank |= CV_CONVERSION_VOLATILE; @@ -5021,10 +5021,8 @@ recursive_dump_type (struct type *type, int spaces) gdb_printf ("%*stype_chain %s\n", spaces, "", host_address_to_string (type->chain)); gdb_printf ("%*sinstance_flags [", spaces, ""); - if (TYPE_CONST (type)) - { - gdb_puts (" TYPE_CONST"); - } + if (type->is_const ()) + gdb_puts (" TYPE_CONST"); if (TYPE_VOLATILE (type)) { gdb_puts (" TYPE_VOLATILE"); diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 605e1eb958a..b08512c32a2 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -165,7 +165,6 @@ struct type_instance_flags bool is_atomic : 1; }; -#define TYPE_CONST(t) (((t)->instance_flags ()).is_const) #define TYPE_VOLATILE(t) (((t)->instance_flags ()).is_volatile) #define TYPE_RESTRICT(t) (((t)->instance_flags ()).is_restrict) #define TYPE_ATOMIC(t) (((t)->instance_flags ()).is_atomic) @@ -1203,6 +1202,12 @@ struct type return this->m_instance_flags.is_nottext; } + /* Return if this type is const. */ + bool is_const () + { + return this->m_instance_flags.is_const; + } + /* Get the bounds bounds of this type. The type must be a range type. */ range_bounds *bounds () const { diff --git a/gdb/m2-typeprint.c b/gdb/m2-typeprint.c index 59616e7f2d6..30b40105405 100644 --- a/gdb/m2-typeprint.c +++ b/gdb/m2-typeprint.c @@ -244,7 +244,7 @@ static void m2_pointer (struct type *type, struct ui_file *stream, int show, int level, const struct type_print_options *flags) { - if (TYPE_CONST (type)) + if (type->is_const ()) gdb_printf (stream, "[...] : "); else gdb_printf (stream, "POINTER TO "); diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c index eb2be9d33a8..ee0ab9fda6a 100644 --- a/gdb/m2-valprint.c +++ b/gdb/m2-valprint.c @@ -356,7 +356,7 @@ m2_language::value_print_inner (struct value *val, struct ui_file *stream, break; case TYPE_CODE_PTR: - if (TYPE_CONST (type)) + if (type->is_const ()) print_variable_at_address (type, valaddr, stream, recurse, options); else if (options->format && options->format != 's') value_print_scalar_formatted (val, options, 0, stream); diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index 8576f4224a2..96119785f92 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -292,7 +292,7 @@ create_value (struct gdbarch *gdbarch, struct value *val, enum noside noside, if (dst_type == NULL) dst_type = init_vector_type (elm_type, n); - make_cv_type (TYPE_CONST (type), TYPE_VOLATILE (type), dst_type); + make_cv_type (type->is_const (), TYPE_VOLATILE (type), dst_type); if (noside == EVAL_AVOID_SIDE_EFFECTS) ret = value::allocate (dst_type); diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index 7831e838481..5b98ec1fa7f 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -733,7 +733,7 @@ typy_volatile (PyObject *self, PyObject *args) try { - type = make_cv_type (TYPE_CONST (type), 1, type); + type = make_cv_type (type->is_const (), 1, type); } catch (const gdb_exception &except) { @@ -894,7 +894,7 @@ typy_lookup_type (struct demangle_component *demangled, rtype = make_cv_type (1, TYPE_VOLATILE (type), type); break; case DEMANGLE_COMPONENT_VOLATILE: - rtype = make_cv_type (TYPE_CONST (type), 1, type); + rtype = make_cv_type (type->is_const (), 1, type); break; } } diff --git a/gdb/type-stack.c b/gdb/type-stack.c index 50912d110f6..5626d8f9075 100644 --- a/gdb/type-stack.c +++ b/gdb/type-stack.c @@ -178,7 +178,7 @@ type_stack::follow_types (struct type *follow_type) TYPE_VOLATILE (follow_type), follow_type); if (make_volatile) - follow_type = make_cv_type (TYPE_CONST (follow_type), + follow_type = make_cv_type (follow_type->is_const (), make_volatile, follow_type); if (make_harvard_aspace != HARVARD_ASPACE_NONE) diff --git a/gdb/valops.c b/gdb/valops.c index ab6fd5079e1..8b777c5cee2 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -3650,7 +3650,7 @@ value_struct_elt_for_reference (struct type *domain, int offset, { for (j = 0; j < len; ++j) { - if (TYPE_CONST (intype) != TYPE_FN_FIELD_CONST (f, j)) + if (intype->is_const () != TYPE_FN_FIELD_CONST (f, j)) continue; if (TYPE_VOLATILE (intype) != TYPE_FN_FIELD_VOLATILE (f, j)) continue; @@ -3873,7 +3873,7 @@ value_rtti_indirect_type (struct value *v, int *full, { /* Copy qualifiers to the referenced object. */ target_type = target->type (); - real_type = make_cv_type (TYPE_CONST (target_type), + real_type = make_cv_type (target_type->is_const (), TYPE_VOLATILE (target_type), real_type); if (TYPE_IS_REFERENCE (type)) real_type = lookup_reference_type (real_type, type->code ()); @@ -3883,7 +3883,7 @@ value_rtti_indirect_type (struct value *v, int *full, internal_error (_("Unexpected value type.")); /* Copy qualifiers to the pointer/reference. */ - real_type = make_cv_type (TYPE_CONST (type), TYPE_VOLATILE (type), + real_type = make_cv_type (type->is_const (), TYPE_VOLATILE (type), real_type); } -- 2.34.1