Inline some ui_out methods

Message ID 20240513172139.3159365-1-tromey@adacore.com
State New
Headers
Series Inline some ui_out methods |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed

Commit Message

Tom Tromey May 13, 2024, 5:21 p.m. UTC
  I noticed a few ui_out methods that are just trivial wrappers.  This
patch moves these to ui-out.h, as it seems like they should be
inlineable.
---
 gdb/ui-out.c | 43 -------------------------------------------
 gdb/ui-out.h | 17 ++++++++++-------
 2 files changed, 10 insertions(+), 50 deletions(-)
  

Comments

Andrew Burgess May 17, 2024, 2:37 p.m. UTC | #1
Tom Tromey <tromey@adacore.com> writes:

> I noticed a few ui_out methods that are just trivial wrappers.  This
> patch moves these to ui-out.h, as it seems like they should be
> inlineable.

LGTM.

Approved-By: Andrew Burgess <aburgess@redhat.com>

Thanks,
Andrew

> ---
>  gdb/ui-out.c | 43 -------------------------------------------
>  gdb/ui-out.h | 17 ++++++++++-------
>  2 files changed, 10 insertions(+), 50 deletions(-)
>
> diff --git a/gdb/ui-out.c b/gdb/ui-out.c
> index b3a2fb7f4e5..d5bc4947f63 100644
> --- a/gdb/ui-out.c
> +++ b/gdb/ui-out.c
> @@ -555,18 +555,6 @@ ui_out::field_fmt (const char *fldname, const ui_file_style &style,
>    va_end (args);
>  }
>  
> -void
> -ui_out::spaces (int numspaces)
> -{
> -  do_spaces (numspaces);
> -}
> -
> -void
> -ui_out::text (const char *string)
> -{
> -  do_text (string);
> -}
> -
>  void
>  ui_out::call_do_message (const ui_file_style &style, const char *format,
>  			 ...)
> @@ -780,37 +768,6 @@ ui_out::message (const char *format, ...)
>    va_end (args);
>  }
>  
> -void
> -ui_out::wrap_hint (int indent)
> -{
> -  do_wrap_hint (indent);
> -}
> -
> -void
> -ui_out::flush ()
> -{
> -  do_flush ();
> -}
> -
> -void
> -ui_out::redirect (ui_file *outstream)
> -{
> -  do_redirect (outstream);
> -}
> -
> -/* Test the flags against the mask given.  */
> -ui_out_flags
> -ui_out::test_flags (ui_out_flags mask)
> -{
> -  return m_flags & mask;
> -}
> -
> -bool
> -ui_out::is_mi_like_p () const
> -{
> -  return do_is_mi_like_p ();
> -}
> -
>  /* Verify that the field/tuple/list is correctly positioned.  Return
>     the field number and corresponding alignment (if
>     available/applicable).  */
> diff --git a/gdb/ui-out.h b/gdb/ui-out.h
> index 5b6ddd55063..74b570b1794 100644
> --- a/gdb/ui-out.h
> +++ b/gdb/ui-out.h
> @@ -163,6 +163,8 @@ class ui_out
>    explicit ui_out (ui_out_flags flags = 0);
>    virtual ~ui_out ();
>  
> +  DISABLE_COPY_AND_ASSIGN (ui_out);
> +
>    void push_level (ui_out_type type);
>    void pop_level (ui_out_type type);
>  
> @@ -203,8 +205,8 @@ class ui_out
>  		  const char *format, ...)
>      ATTRIBUTE_PRINTF (4, 5);
>  
> -  void spaces (int numspaces);
> -  void text (const char *string);
> +  void spaces (int numspaces) { do_spaces (numspaces); }
> +  void text (const char *string) { do_text (string); }
>    void text (const std::string &string) { text (string.c_str ()); }
>  
>    /* Output a printf-style formatted string.  In addition to the usual
> @@ -255,21 +257,22 @@ class ui_out
>    void vmessage (const ui_file_style &in_style,
>  		 const char *format, va_list args) ATTRIBUTE_PRINTF (3, 0);
>  
> -  void wrap_hint (int indent);
> +  void wrap_hint (int indent) { do_wrap_hint (indent); }
>  
> -  void flush ();
> +  void flush () { do_flush (); }
>  
>    /* Redirect the output of a ui_out object temporarily.  */
> -  void redirect (ui_file *outstream);
> +  void redirect (ui_file *outstream) { do_redirect (outstream); }
>  
> -  ui_out_flags test_flags (ui_out_flags mask);
> +  ui_out_flags test_flags (ui_out_flags mask)
> +  { return m_flags & mask; }
>  
>    /* HACK: Code in GDB is currently checking to see the type of ui_out
>       builder when determining which output to produce.  This function is
>       a hack to encapsulate that test.  Once GDB manages to separate the
>       CLI/MI from the core of GDB the problem should just go away ....  */
>  
> -  bool is_mi_like_p () const;
> +  bool is_mi_like_p () const { return do_is_mi_like_p (); }
>  
>    bool query_table_field (int colno, int *width, int *alignment,
>  			  const char **col_name);
> -- 
> 2.44.0
  

Patch

diff --git a/gdb/ui-out.c b/gdb/ui-out.c
index b3a2fb7f4e5..d5bc4947f63 100644
--- a/gdb/ui-out.c
+++ b/gdb/ui-out.c
@@ -555,18 +555,6 @@  ui_out::field_fmt (const char *fldname, const ui_file_style &style,
   va_end (args);
 }
 
-void
-ui_out::spaces (int numspaces)
-{
-  do_spaces (numspaces);
-}
-
-void
-ui_out::text (const char *string)
-{
-  do_text (string);
-}
-
 void
 ui_out::call_do_message (const ui_file_style &style, const char *format,
 			 ...)
@@ -780,37 +768,6 @@  ui_out::message (const char *format, ...)
   va_end (args);
 }
 
-void
-ui_out::wrap_hint (int indent)
-{
-  do_wrap_hint (indent);
-}
-
-void
-ui_out::flush ()
-{
-  do_flush ();
-}
-
-void
-ui_out::redirect (ui_file *outstream)
-{
-  do_redirect (outstream);
-}
-
-/* Test the flags against the mask given.  */
-ui_out_flags
-ui_out::test_flags (ui_out_flags mask)
-{
-  return m_flags & mask;
-}
-
-bool
-ui_out::is_mi_like_p () const
-{
-  return do_is_mi_like_p ();
-}
-
 /* Verify that the field/tuple/list is correctly positioned.  Return
    the field number and corresponding alignment (if
    available/applicable).  */
diff --git a/gdb/ui-out.h b/gdb/ui-out.h
index 5b6ddd55063..74b570b1794 100644
--- a/gdb/ui-out.h
+++ b/gdb/ui-out.h
@@ -163,6 +163,8 @@  class ui_out
   explicit ui_out (ui_out_flags flags = 0);
   virtual ~ui_out ();
 
+  DISABLE_COPY_AND_ASSIGN (ui_out);
+
   void push_level (ui_out_type type);
   void pop_level (ui_out_type type);
 
@@ -203,8 +205,8 @@  class ui_out
 		  const char *format, ...)
     ATTRIBUTE_PRINTF (4, 5);
 
-  void spaces (int numspaces);
-  void text (const char *string);
+  void spaces (int numspaces) { do_spaces (numspaces); }
+  void text (const char *string) { do_text (string); }
   void text (const std::string &string) { text (string.c_str ()); }
 
   /* Output a printf-style formatted string.  In addition to the usual
@@ -255,21 +257,22 @@  class ui_out
   void vmessage (const ui_file_style &in_style,
 		 const char *format, va_list args) ATTRIBUTE_PRINTF (3, 0);
 
-  void wrap_hint (int indent);
+  void wrap_hint (int indent) { do_wrap_hint (indent); }
 
-  void flush ();
+  void flush () { do_flush (); }
 
   /* Redirect the output of a ui_out object temporarily.  */
-  void redirect (ui_file *outstream);
+  void redirect (ui_file *outstream) { do_redirect (outstream); }
 
-  ui_out_flags test_flags (ui_out_flags mask);
+  ui_out_flags test_flags (ui_out_flags mask)
+  { return m_flags & mask; }
 
   /* HACK: Code in GDB is currently checking to see the type of ui_out
      builder when determining which output to produce.  This function is
      a hack to encapsulate that test.  Once GDB manages to separate the
      CLI/MI from the core of GDB the problem should just go away ....  */
 
-  bool is_mi_like_p () const;
+  bool is_mi_like_p () const { return do_is_mi_like_p (); }
 
   bool query_table_field (int colno, int *width, int *alignment,
 			  const char **col_name);