From: Giuliano Procida <gprocida@google.com>
To: libabigail@sourceware.org
Cc: dodji@seketeli.org, kernel-team@android.com, gprocida@google.com,
maennich@google.com
Subject: [PATCH 1/3] abg-ir.cc: Tidy some operator== definitions
Date: Wed, 8 Jul 2020 10:53:13 +0100 [thread overview]
Message-ID: <20200708095315.948634-2-gprocida@google.com> (raw)
In-Reply-To: <20200708095315.948634-1-gprocida@google.com>
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 <gprocida@google.com>
---
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<const function_type*>(&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<const function_type*>(&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
next prev parent reply other threads:[~2020-07-08 9:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-08 9:53 [PATCH 0/3] Type equality refactor and instrumentation Giuliano Procida
2020-07-08 9:53 ` Giuliano Procida [this message]
2020-07-08 9:53 ` [PATCH 2/3] abg-ir.cc: Refactor operator== methods with helper Giuliano Procida
2020-07-27 7:56 ` Dodji Seketeli
2020-07-27 10:36 ` Giuliano Procida
2020-07-27 16:12 ` Dodji Seketeli
2020-07-08 9:53 ` [PATCH 3/3] Add some type equality paranoia Giuliano Procida
2020-07-27 7:32 ` [PATCH 0/3] Type equality refactor and instrumentation Dodji Seketeli
2020-07-27 10:55 ` Giuliano Procida
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200708095315.948634-2-gprocida@google.com \
--to=gprocida@google.com \
--cc=dodji@seketeli.org \
--cc=kernel-team@android.com \
--cc=libabigail@sourceware.org \
--cc=maennich@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).