From patchwork Mon Jul 8 22:59:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 1958135 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=gzGfCr8c; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WJ02x4mXSz1xpd for ; Tue, 9 Jul 2024 09:00:37 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 54C3B386182F for ; Mon, 8 Jul 2024 23:00:35 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 5F65F38654B4 for ; Mon, 8 Jul 2024 22:59:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5F65F38654B4 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5F65F38654B4 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720479598; cv=none; b=Q3kQ0ZyD+xOCU8ZsKSZ1H8TdpoAi6nM/Tu/liosnw4984/5NlbKJMeFYI+xCjvEsPj/6fT79EEINJVQkbCAFBe+7BzugOAUdE9IBOd2he2rtv0wzPGCSiQ1kMxGA6JH1DW262x6Zf+pr3iVXgvurN9NimCCqiN1IditDnVvcbiw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720479598; c=relaxed/simple; bh=85Z6QVTiXsfR68BxXeIClGaXwUydUzu86bCkSAxScoQ=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=mKSMHFR9a2MF5J1P8boliNR5fUQcZJAZ77ec5Grj0fbx61AvvPtEJ/9UsMtWxBYck8yxw8pkKr4GwBa1Ap4080HCmUjcJKDx3hII0NNk4wmP4H1qUASJRCMlewROi7oxTgOddUkGDaJ5UprbiQ/UuEK5GRmlb/UP4DJcqDaF8D8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720479593; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=IiVq9jAQh9OfGdDTNmMHWO9pMENc28iEltT0j+CY7aY=; b=gzGfCr8c/XjvoohIGocA+QZkh8g9fQmUrd9SGAybb0iSRHrJqggv5/FjQXbQXFuuMfOBCD wIrSHeoBAoXq6aQOrxBWi6CNedt0RFcoSvnLY+gti0pj/RywKEVgr1570Rkr/YXD5I1SsW hIgY6kiYrsRHkjKyBGh0Hl0un5EIeSo= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-624-GjG9wuF6NHaBj_8uCcbcJg-1; Mon, 08 Jul 2024 18:59:51 -0400 X-MC-Unique: GjG9wuF6NHaBj_8uCcbcJg-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C90A019560AE for ; Mon, 8 Jul 2024 22:59:49 +0000 (UTC) Received: from t14s.localdomain.com (unknown [10.22.16.76]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BA4641955F40; Mon, 8 Jul 2024 22:59:48 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [pushed] c-format.cc: add ctors to format_check_results and format_check_context Date: Mon, 8 Jul 2024 18:59:46 -0400 Message-Id: <20240708225946.2206619-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org This is a minor cleanup I spotted whilst working on another patch. No functional change intended. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r15-1900-g113b5ce0610207. gcc/c-family/ChangeLog: * c-format.cc (format_check_results::format_check_results): New ctor. (struct format_check_context): Add ctor; add "m_" prefix to all fields. (check_format_info): Use above ctors. (check_format_arg): Update for "m_" prefix to format_check_context. Signed-off-by: David Malcolm --- gcc/c-family/c-format.cc | 63 +++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/gcc/c-family/c-format.cc b/gcc/c-family/c-format.cc index 7a5ffc25602c..5bfd2fc4469e 100644 --- a/gcc/c-family/c-format.cc +++ b/gcc/c-family/c-format.cc @@ -1021,6 +1021,20 @@ static int n_format_types = ARRAY_SIZE (format_types_orig); many leaves resulting from nested conditional expressions. */ struct format_check_results { + format_check_results (location_t format_string_loc_) + : number_non_literal (0), + number_extra_args (0), + extra_arg_loc (UNKNOWN_LOCATION), + number_dollar_extra_args (0), + number_wide (0), + number_non_char (0), + number_empty (0), + number_unterminated (0), + number_other (0), + format_string_loc (format_string_loc_) + { + } + /* Number of leaves of the format argument that could not be checked as they were not string literals. */ int number_non_literal; @@ -1050,10 +1064,21 @@ struct format_check_results struct format_check_context { - format_check_results *res; - function_format_info *info; - tree params; - vec *arglocs; + format_check_context (format_check_results *res, + function_format_info *info, + tree params, + vec *arglocs) + : m_res (res), + m_info (info), + m_params (params), + m_arglocs (arglocs) + { + } + + format_check_results *m_res; + function_format_info *m_info; + tree m_params; + vec *m_arglocs; }; /* Return the format name (as specified in the original table) for the format @@ -1539,10 +1564,8 @@ static void check_format_info (function_format_info *info, tree params, vec *arglocs) { - format_check_context format_ctx; unsigned HOST_WIDE_INT arg_num; tree format_tree; - format_check_results res; /* Skip to format argument. If the argument isn't available, there's no work for us to do; prototype checking will catch the problem. */ for (arg_num = 1; ; ++arg_num) @@ -1558,26 +1581,14 @@ check_format_info (function_format_info *info, tree params, if (format_tree == 0) return; - res.number_non_literal = 0; - res.number_extra_args = 0; - res.extra_arg_loc = UNKNOWN_LOCATION; - res.number_dollar_extra_args = 0; - res.number_wide = 0; - res.number_non_char = 0; - res.number_empty = 0; - res.number_unterminated = 0; - res.number_other = 0; - res.format_string_loc = input_location; - - format_ctx.res = &res; - format_ctx.info = info; - format_ctx.params = params; - format_ctx.arglocs = arglocs; + format_check_results res (input_location); + + format_check_context format_ctx (&res, info, params, arglocs); check_function_arguments_recurse (check_format_arg, &format_ctx, format_tree, arg_num, OPT_Wformat_); - location_t loc = format_ctx.res->format_string_loc; + location_t loc = format_ctx.m_res->format_string_loc; if (res.number_non_literal > 0) { @@ -1659,10 +1670,10 @@ check_format_arg (void *ctx, tree format_tree, unsigned HOST_WIDE_INT arg_num) { format_check_context *format_ctx = (format_check_context *) ctx; - format_check_results *res = format_ctx->res; - function_format_info *info = format_ctx->info; - tree params = format_ctx->params; - vec *arglocs = format_ctx->arglocs; + format_check_results *res = format_ctx->m_res; + function_format_info *info = format_ctx->m_info; + tree params = format_ctx->m_params; + vec *arglocs = format_ctx->m_arglocs; int format_length; HOST_WIDE_INT offset;