From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH] Remove some unnecessary Ada expression code
Date: Wed, 6 Mar 2024 09:06:44 -0700 [thread overview]
Message-ID: <20240306160644.3027294-1-tromey@adacore.com> (raw)
ada_bitwise_operation differs from the "usual" bitwise operations only
in that it calls value_cast at the end. However, because gdb is
generally fairly lax about integer types, and because (perhaps oddly)
C-style binary promotion is done here anyway, it seems to me that this
code isn't needed.
---
gdb/ada-exp.h | 27 ---------------------------
gdb/ada-exp.y | 12 ++++++------
2 files changed, 6 insertions(+), 33 deletions(-)
diff --git a/gdb/ada-exp.h b/gdb/ada-exp.h
index 1d8615b2e87..9abdd6f3f70 100644
--- a/gdb/ada-exp.h
+++ b/gdb/ada-exp.h
@@ -286,33 +286,6 @@ class ada_binop_equal_operation
{ return std::get<0> (m_storage); }
};
-/* Bitwise operators for Ada. */
-template<enum exp_opcode OP>
-class ada_bitwise_operation
- : public maybe_constant_operation<operation_up, operation_up>
-{
-public:
-
- using maybe_constant_operation::maybe_constant_operation;
-
- value *evaluate (struct type *expect_type,
- struct expression *exp,
- enum noside noside) override
- {
- value *lhs = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
- value *rhs = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
- value *result = eval_op_binary (expect_type, exp, noside, OP, lhs, rhs);
- return value_cast (lhs->type (), result);
- }
-
- enum exp_opcode opcode () const override
- { return OP; }
-};
-
-using ada_bitwise_and_operation = ada_bitwise_operation<BINOP_BITWISE_AND>;
-using ada_bitwise_ior_operation = ada_bitwise_operation<BINOP_BITWISE_IOR>;
-using ada_bitwise_xor_operation = ada_bitwise_operation<BINOP_BITWISE_XOR>;
-
/* Ada array- or string-slice operation. */
class ada_ternop_slice_operation
: public maybe_constant_operation<operation_up, operation_up, operation_up>,
diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y
index ab936ae4733..26963f78884 100644
--- a/gdb/ada-exp.y
+++ b/gdb/ada-exp.y
@@ -800,10 +800,10 @@ exp : relation
and_exp :
relation _AND_ relation
- { ada_wrap2<ada_bitwise_and_operation>
+ { ada_wrap2<bitwise_and_operation>
(BINOP_BITWISE_AND); }
| and_exp _AND_ relation
- { ada_wrap2<ada_bitwise_and_operation>
+ { ada_wrap2<bitwise_and_operation>
(BINOP_BITWISE_AND); }
;
@@ -818,10 +818,10 @@ and_then_exp :
or_exp :
relation OR relation
- { ada_wrap2<ada_bitwise_ior_operation>
+ { ada_wrap2<bitwise_ior_operation>
(BINOP_BITWISE_IOR); }
| or_exp OR relation
- { ada_wrap2<ada_bitwise_ior_operation>
+ { ada_wrap2<bitwise_ior_operation>
(BINOP_BITWISE_IOR); }
;
@@ -833,10 +833,10 @@ or_else_exp :
;
xor_exp : relation XOR relation
- { ada_wrap2<ada_bitwise_xor_operation>
+ { ada_wrap2<bitwise_xor_operation>
(BINOP_BITWISE_XOR); }
| xor_exp XOR relation
- { ada_wrap2<ada_bitwise_xor_operation>
+ { ada_wrap2<bitwise_xor_operation>
(BINOP_BITWISE_XOR); }
;
--
2.43.0
next reply other threads:[~2024-03-06 16:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-06 16:06 Tom Tromey [this message]
2024-03-18 14:31 ` Tom Tromey
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=20240306160644.3027294-1-tromey@adacore.com \
--to=tromey@adacore.com \
--cc=gdb-patches@sourceware.org \
/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).