public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 1/3] Remove op_name
Date: Fri, 28 Apr 2023 10:02:51 -0600	[thread overview]
Message-ID: <20230428-minor-expr-cleanuups-v1-1-0a634e8d5c25@adacore.com> (raw)
In-Reply-To: <20230428-minor-expr-cleanuups-v1-0-0a634e8d5c25@adacore.com>

op_name is only needed in a single place, so remove it and inline it
there.
---
 gdb/expprint.c   | 41 +++++++++++++++++------------------------
 gdb/expression.h |  4 ----
 2 files changed, 17 insertions(+), 28 deletions(-)

diff --git a/gdb/expprint.c b/gdb/expprint.c
index e0ec25573c2..b996c9faf8b 100644
--- a/gdb/expprint.c
+++ b/gdb/expprint.c
@@ -36,29 +36,6 @@
 
 #include <ctype.h>
 
-/* Default name for the standard operator OPCODE (i.e., one defined in
-   the definition of enum exp_opcode).  */
-
-const char *
-op_name (enum exp_opcode opcode)
-{
-  switch (opcode)
-    {
-    default:
-      {
-	static char buf[30];
-
-	xsnprintf (buf, sizeof (buf), "<unknown %d>", opcode);
-	return buf;
-      }
-#define OP(name)	\
-    case name:		\
-      return #name ;
-#include "std-operator.def"
-#undef OP
-    }
-}
-
 /* Meant to be used in debug sessions, so don't export it in a header file.  */
 extern void ATTRIBUTE_USED debug_exp (struct expression *exp);
 
@@ -84,7 +61,23 @@ check_objfile (const struct block *block, struct objfile *objfile)
 void
 dump_for_expression (struct ui_file *stream, int depth, enum exp_opcode op)
 {
-  gdb_printf (stream, _("%*sOperation: %s\n"), depth, "", op_name (op));
+  gdb_printf (stream, _("%*sOperation: "), depth, "");
+
+  switch (op)
+    {
+    default:
+      gdb_printf (stream, "<unknown %d>", op);
+      break;
+
+#define OP(name)	\
+    case name:		\
+      gdb_puts (#name, stream); \
+      break;
+#include "std-operator.def"
+#undef OP
+    }
+
+  gdb_puts ("\n", stream);
 }
 
 void
diff --git a/gdb/expression.h b/gdb/expression.h
index c314fc24e1b..77949ddaf4b 100644
--- a/gdb/expression.h
+++ b/gdb/expression.h
@@ -284,10 +284,6 @@ extern struct value *evaluate_subexp_do_call (expression *exp,
 					      const char *function_name,
 					      type *default_return_type);
 
-/* From expprint.c */
-
-extern const char *op_name (enum exp_opcode opcode);
-
 /* In an OP_RANGE expression, either bound could be empty, indicating
    that its value is by default that of the corresponding bound of the
    array or string.  Also, the upper end of the range can be exclusive

-- 
2.39.1


  reply	other threads:[~2023-04-28 16:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-28 16:02 [PATCH 0/3] Minor expression cleanups Tom Tromey
2023-04-28 16:02 ` Tom Tromey [this message]
2023-04-28 16:02 ` [PATCH 2/3] Remove evaluate_expression Tom Tromey
2023-04-28 16:02 ` [PATCH 3/3] Remove evaluate_type Tom Tromey
2023-04-28 16:14 ` [PATCH 0/3] Minor expression cleanups Keith Seitz
2023-05-01 17:04   ` 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=20230428-minor-expr-cleanuups-v1-1-0a634e8d5c25@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).