From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <3lpcFXwgKCtkBKMJ7D85BJJBG9.7JHGD656DB5DGNJPM79R5M9.JMB@flex--gprocida.bounces.google.com> Received: from mail-wr1-x44a.google.com (mail-wr1-x44a.google.com [IPv6:2a00:1450:4864:20::44a]) by sourceware.org (Postfix) with ESMTPS id 65E0D3861815 for ; Wed, 8 Jul 2020 09:53:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 65E0D3861815 Received: by mail-wr1-x44a.google.com with SMTP id o12so51262954wrj.23 for ; Wed, 08 Jul 2020 02:53:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=IGgkOaZQL489eI6GZSYwz0h/Ltq6BC+paHKQ80gpmTE=; b=BKiF/rjmgi8q/Yx5aPcQJ3fJZOa6rGvumj0Wpd25agX/ymuOwSziGwRbax3m5jF5Dp AqUEPLzxzHvc2XSuMtaaUzo5a7m822C7BL0JEFKSY75MjjlD3qsXALtZpXnPXF1tcGvz /2InE6Clano5b89Loies2IHvOw+a5S5OSKalcUv/q/T97ItvFmXQaRYTQZktlI5Gr1B+ 5O0xPGJ2D8jLwmL3x18qmShld6OAWf0tK98BkmusIRLLLPLNoaiEQgdlyZPHFvBFMXV7 qIlTeuYn/pB8VNQZhf24mojvJHw7ubl4MfAUnQ2EJo5e68HR/vPAZi+f29beAeJ1pSrf Ku2Q== X-Gm-Message-State: AOAM531+ov2HPLh4QofVTQWDxoV+HFWDQVzNrZ6xiuCAydngNZvDLvbu egcNmtTwWMGz1S4rVTh8xUuQdBnmcINAuPAREY/wXFfG1JFf8w2E00KWN2OK5vURmsU2RNxggyA qNy3NDwUhT2fEtbV04OBPM18u/8HvnHynKC5pYn8KqLD89omOy74kCvP2k8UctWgjip0ceOg= X-Google-Smtp-Source: ABdhPJxhSnifZ/W8ktNBnPn1L9cqNI3bOCq7TyzJmOEn1tlXwG98r3WZ99IBcFHnyncfmg6IODbI0LBYojlO/w== X-Received: by 2002:a1c:a4c6:: with SMTP id n189mr8230415wme.173.1594202006358; Wed, 08 Jul 2020 02:53:26 -0700 (PDT) Date: Wed, 8 Jul 2020 10:53:13 +0100 In-Reply-To: <20200708095315.948634-1-gprocida@google.com> Message-Id: <20200708095315.948634-2-gprocida@google.com> Mime-Version: 1.0 References: <20200708095315.948634-1-gprocida@google.com> X-Mailer: git-send-email 2.27.0.383.g050319c2ae-goog Subject: [PATCH 1/3] abg-ir.cc: Tidy some operator== definitions From: Giuliano Procida To: libabigail@sourceware.org Cc: dodji@seketeli.org, kernel-team@android.com, gprocida@google.com, maennich@google.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-23.4 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-List-Received-Date: Wed, 08 Jul 2020 09:53:30 -0000 Many of the operator== definitions in this source file follow the same pattern: - the address of the argument is dynamic_cast to type of 'this' - naked canonical type pointers are compared, if both present - the types are compared structurally with 'equals' In a couple of cases extra work is done to fetch the canonical type of the definition of a declaration. This commit adjusts a few cases so they more closely follow the common form. This is to make the next refactoring trivial. There are no behavioural changes. * src/abg-irc.cc (scope_type_decl::operator==): Compare naked canonical type pointers instead of the shared pointers. (qualified_type_def::operator==): Remove excess blank line. (function_type::operator==): Do dynamic_cast and check of argument before comparing naked canonical type pointers. (class_or_union::operator==): Eliminate temporary reference. (class_decl::operator==): Likewise. (union_decl::operator==): Likewise. Signed-off-by: Giuliano Procida --- src/abg-ir.cc | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/abg-ir.cc b/src/abg-ir.cc index 37f6bbdf..41e2f00e 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -12872,8 +12872,8 @@ scope_type_decl::operator==(const decl_base& o) const if (!other) return false; - if (get_canonical_type() && other->get_canonical_type()) - return get_canonical_type().get() == other->get_canonical_type().get(); + if (get_naked_canonical_type() && other->get_naked_canonical_type()) + return get_naked_canonical_type() == other->get_naked_canonical_type(); return equals(*this, *other, 0); } @@ -13243,7 +13243,6 @@ qualified_type_def::operator==(const decl_base& o) const if (get_naked_canonical_type() && other->get_naked_canonical_type()) return get_naked_canonical_type() == other->get_naked_canonical_type(); - return equals(*this, *other, 0); } @@ -16723,16 +16722,16 @@ function_type::get_cached_name(bool internal) const bool function_type::operator==(const type_base& other) const { + const function_type* o = dynamic_cast(&other); + if (!o) + return false; + type_base* canonical_type = get_naked_canonical_type(); type_base* other_canonical_type = other.get_naked_canonical_type(); if (canonical_type && other_canonical_type) return canonical_type == other_canonical_type; - const function_type* o = dynamic_cast(&other); - if (!o) - return false; - return equals(*this, *o, 0); } @@ -19111,8 +19110,7 @@ class_or_union::operator==(const decl_base& other) const if (canonical_type && other_canonical_type) return canonical_type == other_canonical_type; - const class_or_union& o = *op; - return equals(*this, o, 0); + return equals(*this, *op, 0); } /// Equality operator. @@ -20966,8 +20964,7 @@ class_decl::operator==(const decl_base& other) const if (canonical_type && other_canonical_type) return canonical_type == other_canonical_type; - const class_decl& o = *op; - return equals(*this, o, 0); + return equals(*this, *op, 0); } /// Equality operator for class_decl. @@ -21755,8 +21752,7 @@ union_decl::operator==(const decl_base& other) const if (canonical_type && other_canonical_type) return canonical_type == other_canonical_type; - const union_decl &o = *op; - return equals(*this, o, 0); + return equals(*this, *op, 0); } /// Equality operator for union_decl. -- 2.27.0.383.g050319c2ae-goog