From patchwork Sun Jan 3 18:26:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 1421906 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (768-bit key; unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=VHEiVBbY; dkim-atps=neutral Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D86g20kFjz9sVt for ; Mon, 4 Jan 2021 05:27:10 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BCC803870855; Sun, 3 Jan 2021 18:26:39 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from gateway22.websitewelcome.com (gateway22.websitewelcome.com [192.185.47.168]) by sourceware.org (Postfix) with ESMTPS id 7C52C386F826 for ; Sun, 3 Jan 2021 18:26:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7C52C386F826 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway22.websitewelcome.com (Postfix) with ESMTP id 76C81EBD for ; Sun, 3 Jan 2021 12:26:34 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id w85KkwSqPHPnUw85Kk5pbW; Sun, 03 Jan 2021 12:26:34 -0600 X-Authority-Reason: nr=8 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=YCI72rZw8kJicRLbn2iO/QCrivJiHvT3O+yMaSA3lAQ=; b=VHEiVBbYSTaiqvjsv5tZ0YB+mz o9I+NacqivazragM22yCNorhD63AS9jS95gERKJbQYBwI2z2ofK5999URK7LmLbyx3ZZ87odbeZ2a +AL0Duso5HZRlZm/ldYYH/dQZ; Received: from 97-122-81-39.hlrn.qwest.net ([97.122.81.39]:39392 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1kw85K-00234L-8z; Sun, 03 Jan 2021 11:26:34 -0700 From: Tom Tromey To: gcc-patches@gcc.gnu.org Subject: [PATCH 06/10] libcc1: use variadic templates for "rpc" Date: Sun, 3 Jan 2021 11:26:27 -0700 Message-Id: <20210103182631.2316205-7-tom@tromey.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210103182631.2316205-1-tom@tromey.com> References: <20210103182631.2316205-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 - gcc.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.81.39 X-Source-L: No X-Exim-ID: 1kw85K-00234L-8z X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-81-39.hlrn.qwest.net (localhost.localdomain) [97.122.81.39]:39392 X-Source-Auth: tom+tromey.com X-Email-Count: 7 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3032.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_ASCII_DIVIDERS, RCVD_IN_ABUSEAT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tom Tromey Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" This changes libcc1 to use variadic templates for the "rpc" functions. This simplifies the code and removes some possibility for mistakes. libcc1/ChangeLog 2021-01-03 Tom Tromey * libcp1.cc (rpc): Use variadic template. Remove overloads. * libcc1.cc (rpc): Use variadic template. Remove overloads. --- libcc1/ChangeLog | 5 +++ libcc1/libcc1.cc | 81 +++--------------------------------------------- libcc1/libcp1.cc | 81 +++--------------------------------------------- 3 files changed, 13 insertions(+), 154 deletions(-) diff --git a/libcc1/libcc1.cc b/libcc1/libcc1.cc index 4fb3084c24c..82b1a6435b4 100644 --- a/libcc1/libcc1.cc +++ b/libcc1/libcc1.cc @@ -210,90 +210,17 @@ set_callbacks (struct gcc_c_context *s, self->oracle_datum = datum; } -// Instances of these rpc<> template functions are installed into the +// Instances of this rpc<> template function are installed into the // "c_vtable". These functions are parameterized by type and method // name and forward the call via the connection. -template -R rpc (struct gcc_c_context *s) +template +R rpc (struct gcc_c_context *s, Arg... rest) { libcc1 *self = (libcc1 *) s; R result; - if (!cc1_plugin::call (self->connection, NAME, &result)) - return 0; - return result; -} - -template -R rpc (struct gcc_c_context *s, A arg) -{ - libcc1 *self = (libcc1 *) s; - R result; - - if (!cc1_plugin::call (self->connection, NAME, &result, arg)) - return 0; - return result; -} - -template -R rpc (struct gcc_c_context *s, A1 arg1, A2 arg2) -{ - libcc1 *self = (libcc1 *) s; - R result; - - if (!cc1_plugin::call (self->connection, NAME, &result, arg1, arg2)) - return 0; - return result; -} - -template -R rpc (struct gcc_c_context *s, A1 arg1, A2 arg2, A3 arg3) -{ - libcc1 *self = (libcc1 *) s; - R result; - - if (!cc1_plugin::call (self->connection, NAME, &result, arg1, arg2, arg3)) - return 0; - return result; -} - -template -R rpc (struct gcc_c_context *s, A1 arg1, A2 arg2, A3 arg3, A4 arg4) -{ - libcc1 *self = (libcc1 *) s; - R result; - - if (!cc1_plugin::call (self->connection, NAME, &result, arg1, arg2, arg3, - arg4)) - return 0; - return result; -} - -template -R rpc (struct gcc_c_context *s, A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5) -{ - libcc1 *self = (libcc1 *) s; - R result; - - if (!cc1_plugin::call (self->connection, NAME, &result, arg1, arg2, arg3, - arg4, arg5)) - return 0; - return result; -} - -template -R rpc (struct gcc_c_context *s, A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5, - A6 arg6, A7 arg7) -{ - libcc1 *self = (libcc1 *) s; - R result; - - if (!cc1_plugin::call (self->connection, NAME, &result, arg1, arg2, arg3, - arg4, arg5, arg6, arg7)) + if (!cc1_plugin::call (self->connection, NAME, &result, rest...)) return 0; return result; } diff --git a/libcc1/libcp1.cc b/libcc1/libcp1.cc index 5fa6a6742f5..4fced736204 100644 --- a/libcc1/libcp1.cc +++ b/libcc1/libcp1.cc @@ -233,90 +233,17 @@ set_callbacks (struct gcc_cp_context *s, self->oracle_datum = datum; } -// Instances of these rpc<> template functions are installed into the +// Instances of this rpc<> template function are installed into the // "cp_vtable". These functions are parameterized by type and method // name and forward the call via the connection. -template -R rpc (struct gcc_cp_context *s) +template +R rpc (struct gcc_cp_context *s, Arg... rest) { libcp1 *self = (libcp1 *) s; R result; - if (!cc1_plugin::call (self->connection, NAME, &result)) - return 0; - return result; -} - -template -R rpc (struct gcc_cp_context *s, A arg) -{ - libcp1 *self = (libcp1 *) s; - R result; - - if (!cc1_plugin::call (self->connection, NAME, &result, arg)) - return 0; - return result; -} - -template -R rpc (struct gcc_cp_context *s, A1 arg1, A2 arg2) -{ - libcp1 *self = (libcp1 *) s; - R result; - - if (!cc1_plugin::call (self->connection, NAME, &result, arg1, arg2)) - return 0; - return result; -} - -template -R rpc (struct gcc_cp_context *s, A1 arg1, A2 arg2, A3 arg3) -{ - libcp1 *self = (libcp1 *) s; - R result; - - if (!cc1_plugin::call (self->connection, NAME, &result, arg1, arg2, arg3)) - return 0; - return result; -} - -template -R rpc (struct gcc_cp_context *s, A1 arg1, A2 arg2, A3 arg3, A4 arg4) -{ - libcp1 *self = (libcp1 *) s; - R result; - - if (!cc1_plugin::call (self->connection, NAME, &result, arg1, arg2, arg3, - arg4)) - return 0; - return result; -} - -template -R rpc (struct gcc_cp_context *s, A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5) -{ - libcp1 *self = (libcp1 *) s; - R result; - - if (!cc1_plugin::call (self->connection, NAME, &result, arg1, arg2, arg3, - arg4, arg5)) - return 0; - return result; -} - -template -R rpc (struct gcc_cp_context *s, A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5, - A6 arg6, A7 arg7) -{ - libcp1 *self = (libcp1 *) s; - R result; - - if (!cc1_plugin::call (self->connection, NAME, &result, arg1, arg2, arg3, - arg4, arg5, arg6, arg7)) + if (!cc1_plugin::call (self->connection, NAME, &result, rest...)) return 0; return result; }