From patchwork Sun Sep 25 21:11:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 58010 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 982A9385780D for ; Sun, 25 Sep 2022 21:12:05 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from outbound-ss-761.bluehost.com (outbound-ss-761.bluehost.com [74.220.211.250]) by sourceware.org (Postfix) with ESMTPS id A8D3B3858C52 for ; Sun, 25 Sep 2022 21:11:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A8D3B3858C52 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 progateway8.mail.pro1.eigbox.com (Postfix) with ESMTP id 4E97C1003FCDF for ; Sun, 25 Sep 2022 21:11:23 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id cYuIohcDqlpGecYuIoUct3; Sun, 25 Sep 2022 21:11:23 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=I/ag+Psg c=1 sm=1 tr=0 ts=6330c3fb a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=xOM3xZuef0cA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=aMK3Kd9coWiZCahmXAwA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=MqhCUd+yzIflpiFRESZ5ZJ2EcwSjTG4pwfaYe3yY4w0=; b=gTjVSbi3qBgzwKM2W60ADQ3VyW P4xgAqXktH5DBcnUKVaUWHSpa+OQl3CbaXfgWNiGsghm47DmkLrTvAIIhC2DcAgUlFLrgf+5Dtn2J R/x1f8MUEs2pFM8ef6Yeoa59J; Received: from 71-211-160-49.hlrn.qwest.net ([71.211.160.49]:47276 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1ocYuH-000IXM-S5; Sun, 25 Sep 2022 15:11:21 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Subject: [PATCH 2/2] More uses of checked_static_cast Date: Sun, 25 Sep 2022 15:11:07 -0600 Message-Id: <20220925211107.709402-3-tom@tromey.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20220925211107.709402-1-tom@tromey.com> References: <20220925211107.709402-1-tom@tromey.com> MIME-Version: 1.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: 71.211.160.49 X-Source-L: No X-Exim-ID: 1ocYuH-000IXM-S5 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-160-49.hlrn.qwest.net (localhost.localdomain) [71.211.160.49]:47276 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3028.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tom Tromey Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" This patch changes a few more uses of static_cast to use checked_static_cast. In this patch, cast-to-references are converted by moving the dereference outside of the cast, as checked_static_cast only handles pointers. --- gdb/dwarf2/read.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index d34ba69c373..c2b40bff976 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -3155,8 +3155,8 @@ dwarf2_gdb_index::expand_matching_symbols const block_enum block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK; mapped_index &index - = (static_cast - (*per_objfile->per_bfd->index_table.get ())); + = *(gdb::checked_static_cast + (per_objfile->per_bfd->index_table.get ())); const char *match_name = name.ada ().lookup_name ().c_str (); auto matcher = [&] (const char *symname) @@ -4005,8 +4005,8 @@ dw2_expand_marked_cus offset_type vec_len, vec_idx; bool global_seen = false; mapped_index &index - = (static_cast - (*per_objfile->per_bfd->index_table.get ())); + = *(gdb::checked_static_cast + (per_objfile->per_bfd->index_table.get ())); offset_view vec (index.constant_pool.slice (index.symbol_vec_index (idx))); vec_len = vec[0]; @@ -4225,8 +4225,8 @@ dwarf2_gdb_index::expand_symtabs_matching } mapped_index &index - = (static_cast - (*per_objfile->per_bfd->index_table.get ())); + = *(gdb::checked_static_cast + (per_objfile->per_bfd->index_table.get ())); bool result = dw2_expand_symtabs_matching_symbol (index, *lookup_name, @@ -5208,8 +5208,8 @@ dwarf2_debug_names_index::expand_matching_symbols dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); mapped_debug_names &map - = (static_cast - (*per_objfile->per_bfd->index_table.get ())); + = *(gdb::checked_static_cast + (per_objfile->per_bfd->index_table.get ())); const block_search_flags block_flags = global ? SEARCH_GLOBAL_BLOCK : SEARCH_STATIC_BLOCK; @@ -5270,8 +5270,8 @@ dwarf2_debug_names_index::expand_symtabs_matching } mapped_debug_names &map - = (static_cast - (*per_objfile->per_bfd->index_table.get ())); + = *(gdb::checked_static_cast + (per_objfile->per_bfd->index_table.get ())); bool result = dw2_expand_symtabs_matching_symbol (map, *lookup_name,