From patchwork Thu Aug 29 16:03:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 96715 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 4AD49385EC25 for ; Thu, 29 Aug 2024 16:03:36 +0000 (GMT) X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 3FF8F385EC1B for ; Thu, 29 Aug 2024 16:03:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3FF8F385EC1B 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 3FF8F385EC1B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724947407; cv=none; b=isb+x9UXKkPe8/ZitsxLyarVp/UL+Ba/yrsKPQZX7wdfKAMj/dCCHPT10/6h9KOYbn8cAzolB7Cd4pSEkgT6+hLH9Pxzk9NmKGiyItxxJx1rQUGTmJUAO2QNsmetFqsn1foCyPMscaVqpfEfJ7YUUvW8lcOFhx9CDVTy+GeGKfw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724947407; c=relaxed/simple; bh=kehECS5xgqwoz7QKyW2bT9IPupoL8q8jcJ1UffZFPlU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Z5Deke21066+PnoMCpV7rlCtq1MwcnAZNyl/9ER5XXWnX2eEtQyeKCbt8YB7HKJ+ogTwyg5mDCJeFep/fPfAayxlvhBTP6xsizabGjV7m/U8YSCTLhuek9T7quhXO2gSUWs7ld0SC5nMEx9T0Yb/9kYd+N1wzDLHp06rVbW1PoE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724947406; 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: in-reply-to:in-reply-to:references:references; bh=Ezti1hNn7MochR9DE8/sHjOyrupIGGgeejPfLuWZif8=; b=apceoj4sXYG9vQX0g8PGLOZFxK6mzFUMvAq4iMlenOamMFxjeDOUvLL3JK3VS6W0n9kylA XCdJJ0PqYsVebNN/LGYEn0VjZVfeAj9vO58UyfAC1fzuuI7K+FhWnFOwf4qHBm3HRf1JF9 Mv+wuxzCcg6VQBaO1o+Y1hsd4E2qdLw= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-393-RFgRlFwbOVWqetTp33A0jg-1; Thu, 29 Aug 2024 12:03:25 -0400 X-MC-Unique: RFgRlFwbOVWqetTp33A0jg-1 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-7a80872dab0so129165985a.1 for ; Thu, 29 Aug 2024 09:03:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724947403; x=1725552203; h=mime-version:user-agent:message-id:in-reply-to:date:references :organization:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ezti1hNn7MochR9DE8/sHjOyrupIGGgeejPfLuWZif8=; b=odzXuC85HO1nfvrj/DD+QzGfY2yHk573DMSg/jIguX/zWJd8I0ImDfsBozuZ65jjLR be9yz4e3TUPiAheF1tgLHiN4tARmV6aITGJuvf7WG2ZlXvwtY2wjah1GjDw8Ue6aNCtp yYCYl/30vb1TfPLXNqbL0vs0iO5X3+XTIGpGsOwCQIvkANtwebacP6DxbHLjSymWSYWJ qVW+qMdB7A0Wi2bDl2xPw855ZCbyvPVLIups7ASb0BX5DbRTsXo2DBDsPd4niRS8Ga4R 2ddFyUrQ72IUtgPY6jN0P06+bHgTjU8+gsINxiVKH4JDUDb+xov2E+2jHEV18knT8hXM /ysg== X-Gm-Message-State: AOJu0Yy8HZq7WgqAfzJXqquf/Yg6RWFTZ2W198+lvyu+GEKYUoWUKOUJ q3Z/Qq5Kr3CBHWWohwmhyrkKffnHYY5YiZJc5hB3514+hgv3dlIhQ8m+uH/8FK8MO3OyH8eP9YE 9ILymok790NndurrnvZ9C3VHdxp1ed415PzHhlE4aZgkbbwXd18+eNLFD52Q+Aa0gSQ== X-Received: by 2002:a05:620a:31a4:b0:7a6:601c:c827 with SMTP id af79cd13be357-7a8085601fdmr495778585a.27.1724947402752; Thu, 29 Aug 2024 09:03:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHHr95bWurFlnTNr1oRGkgw4oU+IS8pGwTt4kAh6xzC0X+JSMWJHjLF4z6zFUbyXM1W17AoAg== X-Received: by 2002:a05:620a:31a4:b0:7a6:601c:c827 with SMTP id af79cd13be357-7a8085601fdmr495773085a.27.1724947402341; Thu, 29 Aug 2024 09:03:22 -0700 (PDT) Received: from localhost (88-120-130-27.subs.proxad.net. [88.120.130.27]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a806bf67a7sm63040685a.2.2024.08.29.09.03.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 09:03:22 -0700 (PDT) Received: by localhost (Postfix, from userid 1000) id 6A6DF503C602; Thu, 29 Aug 2024 18:03:20 +0200 (CEST) From: Dodji Seketeli To: dodji@redhat.com Cc: libabigail@sourceware.org Subject: [PATCH 12/27] ir: Fix name setting of a ptr-to-mbr-type Organization: Me, myself and I References: <20240829154711.1883174-1-dodji@redhat.com> X-Operating-System: AlmaLinux 9.4 X-URL: http://www.seketeli.net/~dodji Date: Thu, 29 Aug 2024 18:03:20 +0200 In-Reply-To: <20240829154711.1883174-1-dodji@redhat.com> (dodji@redhat.com's message of "Thu, 29 Aug 2024 17:46:29 +0200") Message-ID: <87ttf3l3jr.fsf@seketeli.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.0 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_H3, RCVD_IN_MSPIKE_WL, 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: libabigail@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libabigail-bounces~patchwork=sourceware.org@sourceware.org Hello, The name of a pointer to member type is currently set at the time of construction of the type. This can be problematic because at the time of construction of the type, the member type might not be yet fully constructed. That would result in a name (for the pointer to member type) that is incorrect and stays incorrect for the lifetime of the ptr-to-mbr-type. To be correct, the name of the pointer to member type must always reflect the current state of the member and containing types. This patch does just that. The patch turns decl_base::get_name into a virtual member function. It then creates a ptr_to_mbr_type::get_name virtual member function that dynamically overloads decl_base::get_name. Then, ptr_to_mbr_type::get_name just builds and returns the qualified name of the pointer to member type. * include/abg-ir.h (decl_base::{g,s}et_name): Make these member functions virtual. (ptr_to_mbr_type::get_name): Add new virtual overload. * src/abg-ir.cc (ptr_to_mbr_type::ptr_to_mbr_type): Do not set the name of the type here. Just say that it's not anonymous. (ptr_to_mbr_type::get_name): Define new (virtual) member function. Signed-off-by: Dodji Seketeli --- include/abg-ir.h | 7 +++++-- src/abg-ir.cc | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/include/abg-ir.h b/include/abg-ir.h index 3a82ec78..032dc04d 100644 --- a/include/abg-ir.h +++ b/include/abg-ir.h @@ -1680,13 +1680,13 @@ public: void set_location(const location& l); - const interned_string& + virtual const interned_string& get_name() const; const interned_string& get_qualified_parent_name() const; - void + virtual void set_name(const string& n); bool @@ -2475,6 +2475,9 @@ class ptr_to_mbr_type : public virtual type_base, size_t alignment_in_bits, const location& locus); + virtual const interned_string& + get_name() const; + virtual hash_t hash_value() const; diff --git a/src/abg-ir.cc b/src/abg-ir.cc index 9ff4d3eb..398b4efa 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -18390,10 +18390,18 @@ ptr_to_mbr_type::ptr_to_mbr_type(const environment& env, runtime_type_instance(this); ABG_ASSERT(member_type); ABG_ASSERT(containing_type); - interned_string name = ptr_to_mbr_declaration_name(this, "", - /*qualified=*/true, - /*internal=*/false); - set_name(name); + set_is_anonymous(false); +} + +/// Getter of the name of the current ptr-to-mbr-type. +/// +/// This just returns the qualified name. +/// +/// @return the (qualified) name of the the type. +const interned_string& +ptr_to_mbr_type::get_name() const +{ + return get_qualified_name(/*internal=*/false); } /// Return the hash value of the current IR node.