From patchwork Wed Jun 12 14:02:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 1946948 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Tspf72BM; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4VznLN4cCmz20KL for ; Thu, 13 Jun 2024 00:02:52 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9FB34388211D for ; Wed, 12 Jun 2024 14:02:50 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) by sourceware.org (Postfix) with ESMTPS id 99ED6388458C for ; Wed, 12 Jun 2024 14:02:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 99ED6388458C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=linux.intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 99ED6388458C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718200949; cv=none; b=Jg6hz3ge90a5c8f6t3Pwv9D34ZArYWGZVADFOgRM7IKQ/vlMojv+LK0fE9cytiax74RzteZdIT2mLy4zFzpsBrrguEBHiNC/CVZhjpzDCLsBwC3ETgrJLbtj5wRx6CWVzN641QSV/y+RkEptW5w67iNP+YUtWHygg2YfJ508YpQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718200949; c=relaxed/simple; bh=SFwb971+h7qB7ss4Ux9hx25LskwP/csVcAZaTa1Rl3s=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=LVxC0bsQs7aAZTEpRwjN0aS/uLOaxIg8mpQdYhsCJa54L1OgbdGhsvRRRsykIDK4ycH+MBtfl/s5ESNVhZNLJ1OMm5bxujihUAKWov6wexOsj9c9i6F2C2NdEfDqhqCL0B5FsIAm102NKKbMpzKPXUg306B3iBVN5rk9ZZpU79A= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718200947; x=1749736947; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=SFwb971+h7qB7ss4Ux9hx25LskwP/csVcAZaTa1Rl3s=; b=Tspf72BMFnI8KBME5upXllTmmDF3Fnqq/UnrGasNj83pObAGnf+0CUDh srHJyZAFR5ui7sX69//WbjVzLqOgYvWkevV6haOzofCQk9hnkleMrvlof lD/3IXl98uh1NHZtEm2IhL2ErRTlVzF0rivn1SFCCyUVkFfh6H2VC8Hfc NeWdhTFUnDUwVe4Tp9WFLb9pfz43kfMh46gsPQ98vWBnllj2q1d6JynvA q3ZfY0uK00E0/2vPPM4lcTVoDlZ10a1kBhZ0MhyJw0PolFK0qVlDJM+d2 6hV7OMzv0MCWGPGJ2T81OfhiIyRNwGip2HL/AupQ2js3KvfY7eDi9SuWj w==; X-CSE-ConnectionGUID: 4GVdMfgWSrC2KwPIVI0+0w== X-CSE-MsgGUID: 2tGr4WHbTPCAqWHjsqfWnw== X-IronPort-AV: E=McAfee;i="6700,10204,11101"; a="14926118" X-IronPort-AV: E=Sophos;i="6.08,233,1712646000"; d="scan'208";a="14926118" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2024 07:02:21 -0700 X-CSE-ConnectionGUID: mTDNKn5GRQS4dcOxqU3kiw== X-CSE-MsgGUID: WDXKl9WfTWGzDheT1zBN5Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,233,1712646000"; d="scan'208";a="44708334" Received: from tassilo.jf.intel.com ([10.54.38.190]) by ORVIESA003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2024 07:02:21 -0700 From: Andi Kleen To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Andi Kleen Subject: [PATCH] Move cexpr_stree tree string build into utility function Date: Wed, 12 Jun 2024 07:02:12 -0700 Message-ID: <20240612140212.364672-1-ak@linux.intel.com> X-Mailer: git-send-email 2.45.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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 No semantics changes. gcc/cp/ChangeLog: * cp-tree.h (extract): Add new overload to return tree. * parser.cc (cp_parser_asm_string_expression): Use tree extract. * semantics.cc (cexpr_str::extract): Add new overload to return tree. --- gcc/cp/cp-tree.h | 1 + gcc/cp/parser.cc | 5 +---- gcc/cp/semantics.cc | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 62718ff126a2..416c60b7311e 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -9026,6 +9026,7 @@ public: bool type_check (location_t location); bool extract (location_t location, const char * & msg, int &len); + bool extract (location_t location, tree &str); tree message; private: tree message_data = NULL_TREE; diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 6cd7274046da..de5f0483c120 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -22862,12 +22862,9 @@ cp_parser_asm_string_expression (cp_parser *parser) cexpr_str cstr (string); if (!cstr.type_check (tok->location)) return error_mark_node; - const char *msg; - int len; - if (!cstr.extract (tok->location, msg, len)) + if (!cstr.extract (tok->location, string)) return error_mark_node; parens.require_close (parser); - string = build_string (len, msg); return string; } else if (!cp_parser_is_string_literal (tok)) diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index 20f4675833e2..08f5f245e7d1 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -11728,6 +11728,20 @@ cexpr_str::type_check (location_t location) return true; } +/* Extract constant string at LOCATON into output string STR. + Returns true if successful, otherwise false. */ + +bool +cexpr_str::extract (location_t location, tree &str) +{ + const char *msg; + int len; + if (!extract (location, msg, len)) + return false; + str = build_string (len, msg); + return true; +} + /* Extract constant string at LOCATION into output string MSG with LEN. Returns true if successful, otherwise false. */