From patchwork Wed Jul 3 06:11:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter0x44 X-Patchwork-Id: 1956006 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; secure) header.d=disroot.org header.i=@disroot.org header.a=rsa-sha256 header.s=mail header.b=LZyfgKH6; 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 4WDV2t1RT1z1xpP for ; Wed, 3 Jul 2024 16:18:28 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1B9693882667 for ; Wed, 3 Jul 2024 06:18:27 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) by sourceware.org (Postfix) with ESMTPS id 84F8C386103B for ; Wed, 3 Jul 2024 06:17:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 84F8C386103B Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=disroot.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=disroot.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 84F8C386103B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=178.21.23.139 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719987488; cv=none; b=wot9iGryiB3wTVlyEtBwEUOl5X7ZN+SN3O9gd2SxnKWWmV4EJqYGMIL6Q+O0YTMJO9O+ERg+dOiGY6pMKcU4m2WwNejJVrQT8G2I5yt0w0ImhU4bP3huXe15FNQ3A3k2vXmJtCE9pT/7v5642RV+1n/AIfnLtANBKh0COt7E8B8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719987488; c=relaxed/simple; bh=jhddIunwMBrH4WZpOMnCDx5sB0bt77mNh8hfD1Y+SZU=; h=From:DKIM-Signature:To:Subject:Date:Message-Id:MIME-Version; b=YjNzMk7kItz4ySRKeCdjP9frwQrVrab0VwTDB8hN9dzb2NEBUsuIpxjpQaYfRZBPJ0/Bo9d1DEdtO7oT8/kFPopj4RtUiP1TgHT5+T+6/omyxk0hqp8zZha6p5lWy0eJ6GosTC4AkdpC6aQ430ph3obNpjzPeOJ31sLCauJ+di4= ARC-Authentication-Results: i=1; server2.sourceware.org X-Virus-Scanned: SPAM Filter at disroot.org From: Peter Damianov DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1719987475; bh=jhddIunwMBrH4WZpOMnCDx5sB0bt77mNh8hfD1Y+SZU=; h=From:To:Cc:Subject:Date; b=LZyfgKH6WT338umQi59tosPHogfTWkIf1nlaOAbF+jEdzzu+QnaGkXtw1TWIvz7k8 0c5n0SK5XzTt1AgdtWVwjSdncLxVGhW2Itl94Y2V3+p6Ox6fOvO5OPkH0D+1D/Z1So /vWifTs6M/f6iwd3zhQiDwXv3vEFRCK61hHw/SBQENOJmPYHm4qzFakLbHl7n2YkKP d/xOpMQJI4f9JrbBEQxBJp8e1D4igI3TjRWzNKTUWs/tdB64eopWxwaHdB8H0z7Ae/ MDSuJM8o5c1V06wyax8DF3ytY5QWg14V9kPgE82hjGBli2PzhkEO6m4GZj+VD4Lzdf CQyULfcps/4ag== To: gcc-patches@gcc.gnu.org Cc: Peter Damianov Subject: [PATCH] diagnostics: Follow DECL_ABSTRACT_ORIGIN links in lhd_decl_printable_name [PR102061] Date: Tue, 2 Jul 2024 23:11:43 -0700 Message-Id: <20240703061142.23604-1-peter0x44@disroot.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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: 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 Currently, if a warning references a cloned function, the name of the cloned function will be emitted in the "In function 'xyz'" part of the diagnostic, which users aren't supposed to see. This patch follows the DECL_ABSTRACT_ORIGIN links until encountering the original function. gcc/ChangeLog: PR diagnostics/102061 * langhooks.cc (lhd_decl_printable_name): Follow DECL_ABSTRACT_ORIGIN links to the source Signed-off-by: Peter Damianov --- I would add a testcase but I'm not familiar with that process, and would need some help. I also did not bootstrap or test this patch, I'm posting to see if the CI will do it for me. I used "while" because I'm not sure if there can be clones of clones or not. The second check is because I see comments elsewhere that say: "DECL_ABSTRACT_ORIGIN can point to itself", so I want to avoid a potential infinite loop. gcc/langhooks.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gcc/langhooks.cc b/gcc/langhooks.cc index 61f2b676256..89a89b74535 100644 --- a/gcc/langhooks.cc +++ b/gcc/langhooks.cc @@ -223,6 +223,8 @@ lhd_get_alias_set (tree ARG_UNUSED (t)) const char * lhd_decl_printable_name (tree decl, int ARG_UNUSED (verbosity)) { + while (DECL_ABSTRACT_ORIGIN(decl) && DECL_ABSTRACT_ORIGIN(decl) != decl) + decl = DECL_ABSTRACT_ORIGIN(decl); gcc_assert (decl && DECL_NAME (decl)); return IDENTIFIER_POINTER (DECL_NAME (decl)); }