[binutils-gdb] Remove eval_op_string

Tom Tromey tromey@sourceware.org
Wed Mar 16 15:44:47 GMT 2022


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=16b6c361546c74aa10287fb88cf0c47c536f9eb3

commit 16b6c361546c74aa10287fb88cf0c47c536f9eb3
Author: Tom Tromey <tromey@adacore.com>
Date:   Tue Mar 8 09:47:39 2022 -0700

    Remove eval_op_string
    
    eval_op_string is only used in a single place -- the implementation of
    string_operation.  This patch turns it into the
    string_operation::evaluate method, removing a bit of extraneous code.

Diff:
---
 gdb/eval.c  | 15 ++++++++++-----
 gdb/expop.h | 11 +----------
 2 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/gdb/eval.c b/gdb/eval.c
index 6ced0b261e7..b7b8915fa89 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1078,17 +1078,22 @@ eval_op_register (struct type *expect_type, struct expression *exp,
     return val;
 }
 
-/* Helper function that implements the body of OP_STRING.  */
+namespace expr
+{
 
-struct value *
-eval_op_string (struct type *expect_type, struct expression *exp,
-		enum noside noside, int len, const char *string)
+value *
+string_operation::evaluate (struct type *expect_type,
+			    struct expression *exp,
+			    enum noside noside)
 {
+  const std::string &str = std::get<0> (m_storage);
   struct type *type = language_string_char_type (exp->language_defn,
 						 exp->gdbarch);
-  return value_string (string, len, type);
+  return value_string (str.c_str (), str.size (), type);
 }
 
+} /* namespace expr */
+
 /* Helper function that implements the body of OP_OBJC_SELECTOR.  */
 
 struct value *
diff --git a/gdb/expop.h b/gdb/expop.h
index 58863b8f3ab..1592568a857 100644
--- a/gdb/expop.h
+++ b/gdb/expop.h
@@ -64,10 +64,6 @@ extern struct value *eval_op_func_static_var (struct type *expect_type,
 extern struct value *eval_op_register (struct type *expect_type,
 				       struct expression *exp,
 				       enum noside noside, const char *name);
-extern struct value *eval_op_string (struct type *expect_type,
-				     struct expression *exp,
-				     enum noside noside, int len,
-				     const char *string);
 extern struct value *eval_op_ternop (struct type *expect_type,
 				     struct expression *exp,
 				     enum noside noside,
@@ -912,12 +908,7 @@ public:
 
   value *evaluate (struct type *expect_type,
 		   struct expression *exp,
-		   enum noside noside) override
-  {
-    const std::string &str = std::get<0> (m_storage);
-    return eval_op_string (expect_type, exp, noside,
-			   str.size (), str.c_str ());
-  }
+		   enum noside noside) override;
 
   enum exp_opcode opcode () const override
   { return OP_STRING; }


More information about the Gdb-cvs mailing list