From patchwork Mon Feb 12 21:29:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 85634 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 575563858403 for ; Mon, 12 Feb 2024 21:29:45 +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.133.124]) by sourceware.org (Postfix) with ESMTPS id 40F1B3858C35 for ; Mon, 12 Feb 2024 21:29:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 40F1B3858C35 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 40F1B3858C35 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=1707773379; cv=none; b=OrdEx4C/F+l+kUDIZZyoauur9Njnx1+WA0yVOVHO+a6/u3x8sSoMMw7H2zkgXOElbU62/yAjm7cqRQ5+cHV3rd02ijc5yCYMs9Lw5pUE/7TaEmf2cMbJnfnERHQXaSZIgqK5xUcagWHunSdhcfcS3Mx81gz1MTczgDu9Iz9ff8M= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707773379; c=relaxed/simple; bh=FOCbETUDosS8SAEnnQcFgLGSStIornU3rRrjLKbK2WQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=e1VnQ+AB/Q84NS5IgaIRZzsfLFXDtO8T37ddVSprIFGXWIjHhWfRW41v4eqs9BTXjywRfzR8kzAaGB60CvZlJ1/VG6TcLmaq/gsQBqppyBUAqOLgtmp1Q/KIXaLmjSsqXWQTnYhcu/9MSyGGw8DCjmiXuC5fzagxXs1OahEBBM0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707773377; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=w/vpgUlxwYkYfzdIOVEOJs/EkTS5c6fGnc+iYkiR+LM=; b=id/4u6NdghLlOkzHVXbt6uojAbzkj/DdxeKqfa1MGWlC8oH3UpZu7iK/hdeunOha31PL9q 24sPGE8dGXzTqsaBh7E59dmBxXuhIJw+0GyyAsHe4CJ3IgARIsmm7o24Tu7LQ4avC12q+W BGt35GRSgH+wLQ4oAVf/VQvBXAvckrk= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-114-QydKfjHkMo6HxsD_LM8FEg-1; Mon, 12 Feb 2024 16:29:36 -0500 X-MC-Unique: QydKfjHkMo6HxsD_LM8FEg-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-42c4a11c8c5so41074701cf.3 for ; Mon, 12 Feb 2024 13:29:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707773376; x=1708378176; h=mime-version:user-agent:message-id:date:organization:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=w/vpgUlxwYkYfzdIOVEOJs/EkTS5c6fGnc+iYkiR+LM=; b=BTxkE0tHBbpyvoMl9C1vvXrrdhTTY/tCxhClaU9N3HOx6o0DJfNYUVhorJ7W+Y+v/5 7wnKSuFLx6PSVBtxZmkHmMc/2qsBMHA8cAoHMIgz+Vf+R/MxHJClckI8Gs/6x82fdB7l AZ2dMxUJc3Nq/3WWqd1fOodbrRpR5eCUOEEec/qO9iGbZhlgjndAn0Ox5+mzefoXVNUY 7xUr+BurfKczzDp6nEVLL0lFNf+sUYhaGurPRunmvQEZiVqEW0vMEDoYod6KlQ+E7+JV kvguv5cNXf0mcyfgePcJ/2WfpuSi6yoYukc1WVgVNSdEJlfueCnG3Dnctcd7Q5QVSHPh TmBQ== X-Gm-Message-State: AOJu0YzFR5V9XPL7z3Gzaaj+P8y0d3doGZ03zdmBc+/1qMbER80pGmhD XtNDXWHm8pfKdu20FlsNyjbDz9CwhNCGOLMbYNEx5korUQP9CPb4OYoWbzY65nMPEFxawh0d7fx J4ds+pEiNDB2yyfhyfOM2YR+PPQNy3Vz0/i1oZuS3bu3qvkZEYvAKQZtWuABK+zRsdQ== X-Received: by 2002:a05:622a:11d5:b0:42a:b387:a3e with SMTP id n21-20020a05622a11d500b0042ab3870a3emr10518788qtk.54.1707773376008; Mon, 12 Feb 2024 13:29:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IH4EfBel/syz9qTndDeIEiaFehR9PcrrPcsbz0/0ftHauUcFX/8xeCrmX6xLqyL6v4P5DVkxA== X-Received: by 2002:a05:622a:11d5:b0:42a:b387:a3e with SMTP id n21-20020a05622a11d500b0042ab3870a3emr10518782qtk.54.1707773375756; Mon, 12 Feb 2024 13:29:35 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVvDq9d0/XXooS0N9bfvPUNTqLkDkXiMmJhoh3zq1hl1yJLnZM4pOs6CLX8EyPFAsx4x7ItBmJjYmZslEF5yVC4 Received: from localhost (88-120-130-27.subs.proxad.net. [88.120.130.27]) by smtp.gmail.com with ESMTPSA id c22-20020ac84e16000000b0042994b3c20dsm511610qtw.29.2024.02.12.13.29.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 13:29:35 -0800 (PST) Received: by localhost (Postfix, from userid 1000) id C5E37B4FCA; Mon, 12 Feb 2024 22:29:33 +0100 (CET) From: Dodji Seketeli To: libabigail@sourceware.org Subject: [PATCH, applying to mainline] writer: Don't forget data members when emitting referenced types Organization: Red Hat / France X-Operating-System: CentOS Stream release 9 X-URL: http://www.redhat.com Date: Mon, 12 Feb 2024 22:29:33 +0100 Message-ID: <87v86txtfm.fsf@redhat.com> 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.4 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, 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, When emitting a type referenced type in the ABIXML, write_decl_in_scope just emits markup for the opening (and closing) tags for the scopes up until the actual referenced type. Then the referenced type is emitted. But then if the referenced type is a member type of a class A, for instance, the other data members of that class are not emitted. That can cause the data members of A to be missing. Oops. To fix that, if a scope of the referenced type is itself a type, write_decl_in_scope now emits the full type. * src/abg-writer.cc (write_decl_in_scope): If the scope of the decl to write is a type that was not yet emitted, then emit it in full. Otherwise, just do things as we were doing previously. Signed-off-by: Dodji Seketeli Applying to the master branch. --- src/abg-writer.cc | 72 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 21 deletions(-) diff --git a/src/abg-writer.cc b/src/abg-writer.cc index a6b8d6f7..24616364 100644 --- a/src/abg-writer.cc +++ b/src/abg-writer.cc @@ -2059,30 +2059,47 @@ write_decl_in_scope(const decl_base_sptr& decl, { c = is_class_type(look_through_decl_only_class(c)); class_decl_sptr class_type(c, noop_deleter()); - write_class_decl_opening_tag(class_type, "", ctxt, indent, - /*prepare_to_handle_empty=*/false); - closing_tags.push(""); - closing_indents.push(indent); - - unsigned nb_ws = get_indent_to_level(ctxt, indent, 1); - write_member_type_opening_tag(type, ctxt, nb_ws); - indent = nb_ws; - closing_tags.push(""); - closing_indents.push(nb_ws); + if (!ctxt.type_is_emitted(c)) + { + write_type(class_type, ctxt, initial_indent); + break; + } + else + { + write_class_decl_opening_tag(class_type, "", ctxt, indent, + /*prepare_to_handle_empty=*/false); + closing_tags.push(""); + closing_indents.push(indent); + + unsigned nb_ws = get_indent_to_level(ctxt, indent, 1); + write_member_type_opening_tag(type, ctxt, nb_ws); + indent = nb_ws; + closing_tags.push(""); + closing_indents.push(nb_ws); + } } else if (union_decl *u = is_union_type(*i)) { + u = is_union_type(look_through_decl_only(u)); union_decl_sptr union_type(u, noop_deleter()); - write_union_decl_opening_tag(union_type, "", ctxt, indent, - /*prepare_to_handle_empty=*/false); - closing_tags.push(""); - closing_indents.push(indent); - - unsigned nb_ws = get_indent_to_level(ctxt, indent, 1); - write_member_type_opening_tag(type, ctxt, nb_ws); - indent = nb_ws; - closing_tags.push(""); - closing_indents.push(nb_ws); + if (!ctxt.type_is_emitted(u)) + { + write_type(union_type, ctxt, initial_indent); + break; + } + else + { + write_union_decl_opening_tag(union_type, "", ctxt, indent, + /*prepare_to_handle_empty=*/false); + closing_tags.push(""); + closing_indents.push(indent); + + unsigned nb_ws = get_indent_to_level(ctxt, indent, 1); + write_member_type_opening_tag(type, ctxt, nb_ws); + indent = nb_ws; + closing_tags.push(""); + closing_indents.push(nb_ws); + } } else // We should never reach this point. @@ -2090,7 +2107,20 @@ write_decl_in_scope(const decl_base_sptr& decl, indent += c.get_xml_element_indent(); } - write_decl(decl, ctxt, indent); + bool do_write = false; + if (type_base_sptr type = is_type(decl)) + { + if (!ctxt.type_is_emitted(type)) + do_write= true; + } + else + { + if (!ctxt.decl_is_emitted(decl)) + do_write= true; + } + + if (do_write) + write_decl(decl, ctxt, indent); while (!closing_tags.empty()) {