From patchwork Mon Mar 7 17:21:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 51752 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 8E7763857C7D for ; Mon, 7 Mar 2022 17:21:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8E7763857C7D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1646673679; bh=KKPUISvLte9h07K77lg2HXoXRex+NQqrnSGwaxXTstI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:From; b=chDYhW2CdLq76Nm7JLjkRyty1vwFe4U1iqxURUaf6raQvrjcZMZ2lL8DAZeLHxTLK 94x1r+gtOf+isevSea4q0hhpaEvii0/LYznigfAxq4R2IE77yINtEGt8r+qOICx6sp Wdqwhw+yyYQtuNofRH/V88TH9Zilc3+/ZaWmXG08= 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 ABB2D385841F for ; Mon, 7 Mar 2022 17:21:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org ABB2D385841F 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.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-438-EeKnu1i8OJiTTy2JPEeDJQ-1; Mon, 07 Mar 2022 12:21:12 -0500 X-MC-Unique: EeKnu1i8OJiTTy2JPEeDJQ-1 Received: by mail-qk1-f200.google.com with SMTP id q24-20020a05620a0c9800b0060d5d0b7a90so12008013qki.11 for ; Mon, 07 Mar 2022 09:21:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:organization:date:message-id :user-agent:mime-version; bh=KKPUISvLte9h07K77lg2HXoXRex+NQqrnSGwaxXTstI=; b=7vDKhXh/YLucDw6TJ9ApOOGdXzzF6TI1u9fzwwJBIWakWsQMhipDmZ5Ftq/lqQupki v1DX5q2z4coWeYHDcv+QnodbKUcSe6ksPb307xgJFREd7xR6VYk8QTeMc4CHMJgcxPt+ 70ZYmRuWSU9UDx/VNlbft2uegKMXs8bPC+iV2OjvGV9DwmO9rjVjaPr3nHj5/sfPNPcm ItZRG//ktyQYJ59JmFKWUpr8tNyq+d3T4rl3pE4uQQGrWyeXm6pNLO0POkD+7tCPOnQL RzhH7hDwF6wD71TxSxvNTbV9e3Z06liNfd7L4xLmGIs8Es1duzLglQBLkQRstRZI6fYc aZWQ== X-Gm-Message-State: AOAM531LOr6k5b+J/azt6fuAQ2JofTFchU0Qfs2SbQ23hK8eJUvlBZNu NbGVRfS4Ol5BZOTpYvH6PGFEcTSUOQWOi8r8b+Ia935g1OWyUxknuoT9JVhVcVlMW9YOje+tjVo lWcW3jG4/E96nK68EDk/bnqtG6N1blHwG9NkwYAHCWW2pmloLCmXvruLNRbbvKXxevbp0 X-Received: by 2002:a05:622a:147:b0:2de:9f38:94ca with SMTP id v7-20020a05622a014700b002de9f3894camr10348896qtw.211.1646673671375; Mon, 07 Mar 2022 09:21:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJyHt7bV1KPCm8K+CxuX3HH4mUvK3iAqkaQkgBQd+6LBhvTOhTAt2ESC+lv54MQvyKRMQTfbZw== X-Received: by 2002:a05:622a:147:b0:2de:9f38:94ca with SMTP id v7-20020a05622a014700b002de9f3894camr10348854qtw.211.1646673670746; Mon, 07 Mar 2022 09:21:10 -0800 (PST) Received: from localhost ([88.120.130.27]) by smtp.gmail.com with ESMTPSA id w4-20020a05620a0e8400b0067b1bcd081csm1945493qkm.66.2022.03.07.09.21.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 09:21:10 -0800 (PST) Received: by localhost (Postfix, from userid 1000) id 37611581C3A; Mon, 7 Mar 2022 18:21:07 +0100 (CET) To: libabigail@sourceware.org Subject: [PATCH, applied] comparison: Factorize the code that inserts diff nodes to the graph Organization: Red Hat / France X-Operating-System: Fedora 36 X-URL: http://www.redhat.com Date: Mon, 07 Mar 2022 18:21:07 +0100 Message-ID: <87v8wphe64.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.9 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_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libabigail@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Dodji Seketeli via Libabigail From: Dodji Seketeli Reply-To: Dodji Seketeli Errors-To: libabigail-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libabigail" Hello, During the traversal of the graph of diff nodes, diff::traverse does two things: 1/ If the generic view of the diff node of is not yet connected to the diff graph, then connect it. Note that the typed view of the diff node is always connected to the diff graph. 2/ Visit the diff node using its generic view and visit its children nodes. Looking at the part 1/, I realized that the code connecting the generic view of the diff node to the diff graph was duplicated in every single type of diff node. This patch put that code into diff::finish_diff_type and makes all the different kinds diff node use that (virtual) member function, effectively factorizing that code. * include/abg-comparison.h ({distinct, var, pointer, reference, array, qualified_type, enum, class_or_union, class, union, base, scope, fn_parm, function_type, function_decl, type_decl, typedef}_diff::finish_diff_type): Remove these declarations. * src/abg-comparison.cc ({distinct, var, pointer, reference, array, qualified_type, enum, class_or_union, class, union, base, scope, fn_parm, function_type, function_decl, type_decl, typedef}_diff::finish_diff_type): Remove these definitions. (diff::finish_diff_type): Add the code to connect the children nodes to the current node, making the generic view of the diff node usable to walk the graph. Signed-off-by: Dodji Seketeli --- include/abg-comparison.h | 51 ------------ src/abg-comparison.cc | 170 +-------------------------------------- 2 files changed, 4 insertions(+), 217 deletions(-) diff --git a/include/abg-comparison.h b/include/abg-comparison.h index 595528a5..78e4102e 100644 --- a/include/abg-comparison.h +++ b/include/abg-comparison.h @@ -1163,9 +1163,6 @@ protected: type_or_decl_base_sptr second, diff_context_sptr ctxt = diff_context_sptr()); - virtual void - finish_diff_type(); - public: const type_or_decl_base_sptr @@ -1219,9 +1216,6 @@ protected: diff_sptr type_diff, diff_context_sptr ctxt = diff_context_sptr()); - virtual void - finish_diff_type(); - public: var_decl_sptr first_var() const; @@ -1273,9 +1267,6 @@ protected: diff_sptr underlying_type_diff, diff_context_sptr ctxt = diff_context_sptr()); - virtual void - finish_diff_type(); - public: const pointer_type_def_sptr first_pointer() const; @@ -1333,9 +1324,6 @@ protected: diff_sptr underlying, diff_context_sptr ctxt = diff_context_sptr()); - virtual void - finish_diff_type(); - public: reference_type_def_sptr first_reference() const; @@ -1393,9 +1381,6 @@ protected: diff_sptr element_type_diff, diff_context_sptr ctxt = diff_context_sptr()); - virtual void - finish_diff_type(); - public: const array_type_def_sptr first_array() const; @@ -1450,9 +1435,6 @@ protected: diff_sptr underling, diff_context_sptr ctxt = diff_context_sptr()); - virtual void - finish_diff_type(); - public: const qualified_type_def_sptr first_qualified_type() const; @@ -1519,9 +1501,6 @@ protected: const diff_sptr, diff_context_sptr ctxt = diff_context_sptr()); - virtual void - finish_diff_type(); - public: const enum_type_decl_sptr first_enum() const; @@ -1592,9 +1571,6 @@ protected: class_or_union_sptr second_scope, diff_context_sptr ctxt = diff_context_sptr()); - virtual void - finish_diff_type(); - public: const class_or_union_diff::priv_ptr& @@ -1714,9 +1690,6 @@ protected: class_decl_sptr second_scope, diff_context_sptr ctxt = diff_context_sptr()); - virtual void - finish_diff_type(); - public: //TODO: add change of the name of the type. @@ -1793,9 +1766,6 @@ protected: union_decl_sptr second_union, diff_context_sptr ctxt = diff_context_sptr()); - virtual void - finish_diff_type(); - public: virtual ~union_diff(); @@ -1835,9 +1805,6 @@ protected: class_diff_sptr underlying, diff_context_sptr ctxt = diff_context_sptr()); - virtual void - finish_diff_type(); - public: class_decl::base_spec_sptr first_base() const; @@ -1902,9 +1869,6 @@ protected: scope_decl_sptr second_scope, diff_context_sptr ctxt = diff_context_sptr()); - virtual void - finish_diff_type(); - public: friend scope_diff_sptr @@ -1996,9 +1960,6 @@ class fn_parm_diff : public decl_diff_base struct priv; std::unique_ptr priv_; - virtual void - finish_diff_type(); - fn_parm_diff(const function_decl::parameter_sptr first, const function_decl::parameter_sptr second, diff_context_sptr ctxt); @@ -2065,9 +2026,6 @@ protected: const function_type_sptr second, diff_context_sptr ctxt); - virtual void - finish_diff_type(); - public: friend function_type_diff_sptr compute_diff(const function_type_sptr first, @@ -2137,9 +2095,6 @@ protected: const function_decl_sptr second, diff_context_sptr ctxt); - virtual void - finish_diff_type(); - public: friend function_decl_diff_sptr @@ -2192,9 +2147,6 @@ protected: const type_decl_sptr second, diff_context_sptr ctxt = diff_context_sptr()); - virtual void - finish_diff_type(); - public: friend type_decl_diff_sptr compute_diff(const type_decl_sptr first, @@ -2244,9 +2196,6 @@ protected: const diff_sptr underlying_type_diff, diff_context_sptr ctxt = diff_context_sptr()); - virtual void - finish_diff_type(); - public: friend typedef_diff_sptr compute_diff(const typedef_decl_sptr first, diff --git a/src/abg-comparison.cc b/src/abg-comparison.cc index cc5b9f6d..5e61ba50 100644 --- a/src/abg-comparison.cc +++ b/src/abg-comparison.cc @@ -1930,6 +1930,10 @@ diff::end_traversing() void diff::finish_diff_type() { + if (diff::priv_->finished_) + return; + chain_into_hierarchy(); + diff::priv_->finished_ = true; } /// Getter of the first subject of the diff. @@ -2544,17 +2548,6 @@ distinct_diff::distinct_diff(type_or_decl_base_sptr first, priv_(new priv) {ABG_ASSERT(entities_are_of_distinct_kinds(first, second));} -/// Finish building the current instance of @ref distinct_diff. -void -distinct_diff::finish_diff_type() -{ - if (diff::priv_->finished_) - return; - - chain_into_hierarchy(); - diff::priv_->finished_ = true; -} - /// Getter for the first subject of the diff. /// /// @return the first subject of the diff. @@ -3247,16 +3240,6 @@ var_diff::var_diff(var_decl_sptr first, priv_(new priv) {priv_->type_diff_ = type_diff;} -/// Finish building the current instance of @ref var_diff. -void -var_diff::finish_diff_type() -{ - if (diff::priv_->finished_) - return; - chain_into_hierarchy(); - diff::priv_->finished_ = true; -} - /// Getter for the first @ref var_decl of the diff. /// /// @return the first @ref var_decl of the diff. @@ -3376,16 +3359,6 @@ pointer_diff::pointer_diff(pointer_type_def_sptr first, priv_(new priv(underlying)) {} -/// Finish building the current instance of @ref pointer_diff. -void -pointer_diff::finish_diff_type() -{ - if (diff::priv_->finished_) - return; - chain_into_hierarchy(); - diff::priv_->finished_ = true; -} - /// Getter for the first subject of a pointer diff /// /// @return the first pointer considered in this pointer diff. @@ -3526,16 +3499,6 @@ array_diff::array_diff(const array_type_def_sptr first, priv_(new priv(element_type_diff)) {} -/// Finish building the current instance of @ref array_diff. -void -array_diff::finish_diff_type() -{ - if (diff::priv_->finished_) - return; - chain_into_hierarchy(); - diff::priv_->finished_ = true; -} - /// Getter for the first array of the diff. /// /// @return the first array of the diff. @@ -3687,16 +3650,6 @@ reference_diff::reference_diff(const reference_type_def_sptr first, priv_(new priv(underlying)) {} -/// Finish building the current instance of @ref reference_diff. -void -reference_diff::finish_diff_type() -{ - if (diff::priv_->finished_) - return; - chain_into_hierarchy(); - diff::priv_->finished_ = true; -} - /// Getter for the first reference of the diff. /// /// @return the first reference of the diff. @@ -3832,16 +3785,6 @@ qualified_type_diff::qualified_type_diff(qualified_type_def_sptr first, priv_(new priv(under)) {} -/// Finish building the current instance of @ref qualified_type_diff. -void -qualified_type_diff::finish_diff_type() -{ - if (diff::priv_->finished_) - return; - chain_into_hierarchy(); - diff::priv_->finished_ = true; -} - /// Getter for the first qualified type of the diff. /// /// @return the first qualified type of the diff. @@ -4075,16 +4018,6 @@ enum_diff::enum_diff(const enum_type_decl_sptr first, priv_(new priv(underlying_type_diff)) {} -/// Finish building the current instance of @ref enum_diff. -void -enum_diff::finish_diff_type() -{ - if (diff::priv_->finished_) - return; - chain_into_hierarchy(); - diff::priv_->finished_ = true; -} - /// @return the first enum of the diff. const enum_type_decl_sptr enum_diff::first_enum() const @@ -4937,16 +4870,6 @@ class_or_union_diff::class_or_union_diff(class_or_union_sptr first_scope, //priv_(new priv) {} -/// Finish building the current instance of @ref class_or_union_diff. -void -class_or_union_diff::finish_diff_type() -{ - if (diff::priv_->finished_) - return; - chain_into_hierarchy(); - diff::priv_->finished_ = true; -} - /// Getter of the private data of the @ref class_or_union_diff type. /// /// Note that due to an optimization, the private data of @ref @@ -5552,16 +5475,6 @@ class_diff::get_priv() const return canonical->priv_; } -/// Finish building the current instance of @ref class_diff. -void -class_diff::finish_diff_type() -{ - if (diff::priv_->finished_) - return; - chain_into_hierarchy(); - diff::priv_->finished_ = true; -} - /// @return the pretty representation of the current instance of @ref /// class_diff. const string& @@ -5800,17 +5713,6 @@ base_diff::base_diff(class_decl::base_spec_sptr first, priv_(new priv(underlying)) {} -/// Finish building the current instance of @ref base_diff. -void -base_diff::finish_diff_type() -{ - if (diff::priv_->finished_) - return; - - chain_into_hierarchy(); - diff::priv_->finished_ = true; -} - /// Getter for the first base spec of the diff object. /// /// @return the first base specifier for the diff object. @@ -5975,11 +5877,6 @@ union_diff::union_diff(union_decl_sptr first_union, : class_or_union_diff(first_union, second_union, ctxt) {} -/// Finish building the current instance of @ref union_diff. -void -union_diff::finish_diff_type() -{class_or_union_diff::finish_diff_type();} - /// Destructor of the union_diff node. union_diff::~union_diff() {} @@ -6319,16 +6216,6 @@ scope_diff::scope_diff(scope_decl_sptr first_scope, priv_(new priv) {} -/// Finish building the current instance of @ref scope_diff. -void -scope_diff::finish_diff_type() -{ - if (diff::priv_->finished_) - return; - chain_into_hierarchy(); - diff::priv_->finished_ = true; -} - /// Getter for the first scope of the diff. /// /// @return the first scope of the diff. @@ -6622,16 +6509,6 @@ fn_parm_diff::fn_parm_diff(const function_decl::parameter_sptr first, ABG_ASSERT(priv_->type_diff); } -/// Finish the building of the current instance of @ref fn_parm_diff. -void -fn_parm_diff::finish_diff_type() -{ - if (diff::priv_->finished_) - return; - chain_into_hierarchy(); - diff::priv_->finished_ = true; -} - /// Getter for the first subject of this diff node. /// /// @return the first function_decl::parameter_sptr subject of this @@ -6893,16 +6770,6 @@ function_type_diff::function_type_diff(const function_type_sptr first, priv_(new priv) {} -/// Finish building the current instance of @ref function_type_diff -void -function_type_diff::finish_diff_type() -{ - if (diff::priv_->finished_) - return; - chain_into_hierarchy(); - diff::priv_->finished_ = true; -} - /// Getter for the first subject of the diff. /// /// @return the first function type involved in the diff. @@ -7109,16 +6976,6 @@ function_decl_diff::function_decl_diff(const function_decl_sptr first, { } -/// Finish building the current instance of @ref function_decl_diff. -void -function_decl_diff::finish_diff_type() -{ - if (diff::priv_->finished_) - return; - chain_into_hierarchy(); - diff::priv_->finished_ = true; -} - /// @return the first function considered by the diff. const function_decl_sptr function_decl_diff::first_function_decl() const @@ -7242,15 +7099,6 @@ type_decl_diff::type_decl_diff(const type_decl_sptr first, : type_diff_base(first, second, ctxt) {} -/// Finish building the current instance of @ref type_decl_diff. -void -type_decl_diff::finish_diff_type() -{ - if (diff::priv_->finished_) - return; - diff::priv_->finished_ = true; -} - /// Getter for the first subject of the type_decl_diff. /// /// @return the first type_decl involved in the diff. @@ -7390,16 +7238,6 @@ typedef_diff::typedef_diff(const typedef_decl_sptr first, priv_(new priv(underlying)) {} -/// Finish building the current instance of @ref typedef_diff. -void -typedef_diff::finish_diff_type() -{ - if (diff::priv_->finished_) - return; - chain_into_hierarchy(); - diff::priv_->finished_ = true; -} - /// Getter for the firt typedef_decl involved in the diff. /// /// @return the first subject of the diff.