From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gproxy2-pub.mail.unifiedlayer.com (gproxy2-pub.mail.unifiedlayer.com [69.89.18.3]) by sourceware.org (Postfix) with ESMTPS id 7D818385840C for ; Thu, 9 Feb 2023 21:38:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7D818385840C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw14.mail.unifiedlayer.com (unknown [10.0.90.129]) by progateway4.mail.pro1.eigbox.com (Postfix) with ESMTP id D4CBD10047E1A for ; Thu, 9 Feb 2023 21:38:40 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QEcqpLOqDGAj8QEcqphq2m; Thu, 09 Feb 2023 21:38:40 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=UdyU9IeN c=1 sm=1 tr=0 ts=63e567e0 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10:nop_charset_1 a=m04uMKEZRckA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=DAtK919lk117L9zkXUQA:9 a=QEXdDO2ut3YA:10:nop_charset_2 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Gz3onojrYctupTxch/h3VQ6scj0RJd6tp1bDNUGX9D8=; b=RFSj5cSsarFVGFEip92O4wWjXG 6+mPrfY//WFemg8MGTNKS1fxV4Q5cMXagF3twi28ks+oidnIQyGUWVf8jE5kc2DWTicTW5Mg+AxrQ eorBkt0iIkttzT5YE1mDkZAap; Received: from 75-166-130-93.hlrn.qwest.net ([75.166.130.93]:52822 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pQEcq-001ZcE-BK for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:40 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:26 -0700 Subject: [PATCH 05/47] Turn deprecated_set_value_type into a method MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230209-submit-value-fixups-2023-v1-5-55dc2794dbb9@tromey.com> References: <20230209-submit-value-fixups-2023-v1-0-55dc2794dbb9@tromey.com> In-Reply-To: <20230209-submit-value-fixups-2023-v1-0-55dc2794dbb9@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.130.93 X-Source-L: No X-Exim-ID: 1pQEcq-001ZcE-BK X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-130-93.hlrn.qwest.net ([192.168.0.21]) [75.166.130.93]:52822 X-Source-Auth: tom+tromey.com X-Email-Count: 6 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3025.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,JMQ_SPF_NEUTRAL,RCVD_IN_BL_SPAMCOP_NET,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,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 List-Id: This changes deprecated_set_value_type to be a method of value. Much of this patch was written by script. --- gdb/ada-lang.c | 6 +++--- gdb/ada-valprint.c | 2 +- gdb/eval.c | 2 +- gdb/gnu-v2-abi.c | 3 +-- gdb/i386-tdep.c | 2 +- gdb/objc-lang.c | 2 +- gdb/valops.c | 19 +++++++++---------- gdb/value.c | 11 ++--------- gdb/value.h | 13 ++++++------- 9 files changed, 25 insertions(+), 35 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index da49149c56d..c5b5b14163b 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -2924,7 +2924,7 @@ ada_value_assign (struct value *toval, struct value *fromval) memcpy (value_contents_raw (val).data (), value_contents (fromval).data (), type->length ()); - deprecated_set_value_type (val, type); + val->deprecated_set_type (type); return val; } @@ -3033,7 +3033,7 @@ ada_value_subscript (struct value *arr, int arity, struct value **ind) than as an access. Another symptom of the same issue would be that an expression trying to dereference the element would also be improperly rejected. */ - deprecated_set_value_type (elt, saved_elt_type); + elt->deprecated_set_type (saved_elt_type); } elt_type = ada_check_typedef (elt->type ()); @@ -9334,7 +9334,7 @@ coerce_for_assign (struct type *type, struct value *val) if (type2->target_type ()->length () != type->target_type ()->length ()) error (_("Incompatible types in assignment")); - deprecated_set_value_type (val, type); + val->deprecated_set_type (type); } return val; } diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index 1f22ab61ce2..761d3150937 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -1029,7 +1029,7 @@ ada_value_print_inner (struct value *val, struct ui_file *stream, int recurse, if (type != saved_type) { val = value_copy (val); - deprecated_set_value_type (val, type); + val->deprecated_set_type (type); } if (is_fixed_point_type (type)) diff --git a/gdb/eval.c b/gdb/eval.c index c24ff258b43..6fa359966ec 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -2183,7 +2183,7 @@ eval_op_objc_msgcall (struct type *expect_type, struct expression *exp, /* Function objc_msg_lookup returns a pointer. */ struct type *tem_type = called_method->type (); tem_type = lookup_pointer_type (lookup_function_type (tem_type)); - deprecated_set_value_type (called_method, tem_type); + called_method->deprecated_set_type (tem_type); called_method = call_function_by_hand (called_method, NULL, args); } diff --git a/gdb/gnu-v2-abi.c b/gdb/gnu-v2-abi.c index c28df183c8b..b27649051a4 100644 --- a/gdb/gnu-v2-abi.c +++ b/gdb/gnu-v2-abi.c @@ -174,8 +174,7 @@ gnuv2_virtual_fn_field (struct value **arg1p, struct fn_field * f, int j, else error (_("I'm confused: virtual function table has bad type")); /* Reinstantiate the function pointer with the correct type. */ - deprecated_set_value_type (vfn, - lookup_pointer_type (TYPE_FN_FIELD_TYPE (f, j))); + vfn->deprecated_set_type (lookup_pointer_type (TYPE_FN_FIELD_TYPE (f, j))); *arg1p = arg1; return vfn; diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index f8907f5c4f4..f82641debee 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -3087,7 +3087,7 @@ i386_return_value (struct gdbarch *gdbarch, struct value *function, = i386_return_value (gdbarch, function, inner_type, regcache, read_value, writebuf); if (read_value != nullptr) - deprecated_set_value_type (*read_value, type); + (*read_value)->deprecated_set_type (type); return result; } diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c index e17a4c406c0..f43d158a770 100644 --- a/gdb/objc-lang.c +++ b/gdb/objc-lang.c @@ -212,7 +212,7 @@ value_nsstring (struct gdbarch *gdbarch, const char *ptr, int len) else type = lookup_pointer_type(sym->type ()); - deprecated_set_value_type (nsstringValue, type); + nsstringValue->deprecated_set_type (type); return nsstringValue; } diff --git a/gdb/valops.c b/gdb/valops.c index a56afce0235..1cac2496183 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -319,14 +319,14 @@ value_cast_pointers (struct type *type, struct value *arg2, { struct value *v = value_addr (v2); - deprecated_set_value_type (v, type); + v->deprecated_set_type (type); return v; } } /* No superclass found, just change the pointer type. */ arg2 = value_copy (arg2); - deprecated_set_value_type (arg2, type); + arg2->deprecated_set_type (type); set_value_enclosing_type (arg2, type); set_value_pointed_to_offset (arg2, 0); /* pai: chk_val */ return arg2; @@ -429,7 +429,7 @@ value_cast (struct type *type, struct value *arg2) if (arg2->type () != type) { arg2 = value_copy (arg2); - deprecated_set_value_type (arg2, type); + arg2->deprecated_set_type (type); } return arg2; } @@ -494,8 +494,7 @@ value_cast (struct type *type, struct value *arg2) range_type->target_type (), low_bound, new_length + low_bound - 1); - deprecated_set_value_type (arg2, - create_array_type (NULL, + arg2->deprecated_set_type (create_array_type (NULL, element_type, range_type)); return arg2; @@ -649,7 +648,7 @@ value_cast (struct type *type, struct value *arg2) return value_cast_pointers (to_type, arg2, 0); arg2 = value_copy (arg2); - deprecated_set_value_type (arg2, to_type); + arg2->deprecated_set_type (to_type); set_value_enclosing_type (arg2, to_type); set_value_pointed_to_offset (arg2, 0); /* pai: chk_val */ return arg2; @@ -1574,7 +1573,7 @@ value_addr (struct value *arg1) = lookup_pointer_type (enclosing_type->target_type ()); arg2 = value_copy (arg1); - deprecated_set_value_type (arg2, type_ptr); + arg2->deprecated_set_type (type_ptr); set_value_enclosing_type (arg2, enclosing_type_ptr); return arg2; @@ -1622,7 +1621,7 @@ value_ref (struct value *arg1, enum type_code refcode) return arg1; arg2 = value_addr (arg1); - deprecated_set_value_type (arg2, lookup_reference_type (type, refcode)); + arg2->deprecated_set_type (lookup_reference_type (type, refcode)); return arg2; } @@ -2110,7 +2109,7 @@ struct_field_searcher::search (struct value *arg1, LONGEST offset, else { v2 = value_copy (arg1); - deprecated_set_value_type (v2, basetype); + v2->deprecated_set_type (basetype); set_value_embedded_offset (v2, boffset); } @@ -3981,7 +3980,7 @@ value_full_object (struct value *argp, value_rtti_type used for its computation. */ new_val = value_at_lazy (real_type, value_address (argp) - top + (using_enc ? 0 : value_embedded_offset (argp))); - deprecated_set_value_type (new_val, argp->type ()); + new_val->deprecated_set_type (argp->type ()); set_value_embedded_offset (new_val, (using_enc ? top + value_embedded_offset (argp) : top)); diff --git a/gdb/value.c b/gdb/value.c index e2e641386a3..bde8f3da4d2 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -894,12 +894,6 @@ allocate_optimized_out_value (struct type *type) /* Accessor methods. */ -void -deprecated_set_value_type (struct value *value, struct type *type) -{ - value->m_type = type; -} - LONGEST value_offset (const struct value *value) { @@ -1599,8 +1593,7 @@ make_cv_value (int cnst, int voltl, struct value *v) struct type *m_enclosing_type = value_enclosing_type (v); struct value *cv_val = value_copy (v); - deprecated_set_value_type (cv_val, - make_cv_type (cnst, voltl, val_type, NULL)); + cv_val->deprecated_set_type (make_cv_type (cnst, voltl, val_type, NULL)); set_value_enclosing_type (cv_val, make_cv_type (cnst, voltl, m_enclosing_type, NULL)); @@ -3672,7 +3665,7 @@ readjust_indirect_value_type (struct value *value, struct type *enc_type, original_value_address); /* Re-adjust type. */ - deprecated_set_value_type (value, resolved_original_target_type); + value->deprecated_set_type (resolved_original_target_type); /* Add embedding info. */ set_value_enclosing_type (value, enc_type); diff --git a/gdb/value.h b/gdb/value.h index f4a488c9263..cb92b872bc6 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -163,6 +163,12 @@ struct value struct type *type () const { return m_type; } + /* This is being used to change the type of an existing value, that + code should instead be creating a new value with the changed type + (but possibly shared content). */ + void deprecated_set_type (struct type *type) + { m_type = type; } + /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -334,13 +340,6 @@ struct value extern struct gdbarch *get_value_arch (const struct value *value); -/* This is being used to change the type of an existing value, that - code should instead be creating a new value with the changed type - (but possibly shared content). */ - -extern void deprecated_set_value_type (struct value *value, - struct type *type); - /* Only used for bitfields; number of bits contained in them. */ extern LONGEST value_bitsize (const struct value *); -- 2.39.1