gdb: add type::has_varargs / type::set_has_varargs
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 14 Sep 2020 15:08:01 +0000 (11:08 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Mon, 14 Sep 2020 15:08:01 +0000 (11:08 -0400)
Add the `has_varargs` and `set_has_varargs` methods on `struct type`, in
order to remove the `TYPE_VARARGS` macro.  In this patch, the macro is
changed to use the getter, so all the call sites of the macro that are
used as a setter are changed to use the setter method directly.  The
next patch will remove the macro completely.

gdb/ChangeLog:

* gdbtypes.h (struct type) <has_varargs, set_has_varargs>: New methods.
(TYPE_VARARGS): Use type::has_varargs, change all write call sites to
use type::set_has_varargs.

Change-Id: I898a1093ae40808b37a7c6fced7f6fa2aae604de

gdb/ChangeLog
gdb/ctfread.c
gdb/dwarf2/read.c
gdb/eval.c
gdb/gdbtypes.c
gdb/gdbtypes.h

index 193d0c85e5f379ff4efc27ea096cf6b6e06b8f5b..e8fecf714cfe881d7585eace66aab56dfd88d007 100644 (file)
@@ -1,3 +1,9 @@
+2020-09-14  Simon Marchi  <simon.marchi@efficios.com>
+
+       * gdbtypes.h (struct type) <has_varargs, set_has_varargs>: New methods.
+       (TYPE_VARARGS): Use type::has_varargs, change all write call sites to
+       use type::set_has_varargs.
+
 2020-09-14  Simon Marchi  <simon.marchi@efficios.com>
 
        * gdbtypes.h (TYPE_PROTOTYPED): Remove, replace all
index 81490baecc1f0db01c7281037fa9585455d4809a..0237b486253d4786348d4dc8d1839a8c82a5de78 100644 (file)
@@ -1142,7 +1142,7 @@ add_stt_func (struct ctf_context *ccp, unsigned long idx)
   tid = ctf_lookup_by_symbol (ccp->fp, idx);
   ftype = get_tid_type (ccp->of, tid);
   if (finfo.ctc_flags & CTF_FUNC_VARARG)
-    TYPE_VARARGS (ftype) = 1;
+    ftype->set_has_varargs (true);
   ftype->set_num_fields (argc);
 
   /* If argc is 0, it has a "void" type.  */
index f4f3a029a769474459106e320e02a7ebba9e4414..e61eda73de4b5238b60285adc484c1c45c1c9d21 100644 (file)
@@ -17707,7 +17707,8 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu)
          if (child_die->tag == DW_TAG_formal_parameter)
            nparams++;
          else if (child_die->tag == DW_TAG_unspecified_parameters)
-           TYPE_VARARGS (ftype) = 1;
+           ftype->set_has_varargs (true);
+
          child_die = child_die->sibling;
        }
 
index 7f9515b2c1105195d6afdcc3e011d492ccee7c44..d87b8dae110aee34d435280710eb65d851a1fdad 100644 (file)
@@ -665,7 +665,7 @@ fake_method::fake_method (type_instance_flags flags,
       if (param_types[num_types - 1] == NULL)
        {
          --num_types;
-         TYPE_VARARGS (type) = 1;
+         type->set_has_varargs (true);
        }
       else if (check_typedef (param_types[num_types - 1])->code ()
               == TYPE_CODE_VOID)
index ae3d92751b4c933b11078d9f133235694fe9c3d8..2ff458af9089df3b4bc7bf8ae0a1d09212992216 100644 (file)
@@ -552,7 +552,7 @@ lookup_function_type_with_arguments (struct type *type,
       if (param_types[nparams - 1] == NULL)
        {
          --nparams;
-         TYPE_VARARGS (fn) = 1;
+         fn->set_has_varargs (true);
        }
       else if (check_typedef (param_types[nparams - 1])->code ()
               == TYPE_CODE_VOID)
@@ -1556,7 +1556,7 @@ smash_to_method_type (struct type *type, struct type *self_type,
   type->set_fields (args);
   type->set_num_fields (nargs);
   if (varargs)
-    TYPE_VARARGS (type) = 1;
+    type->set_has_varargs (true);
   TYPE_LENGTH (type) = 1;      /* In practice, this is never needed.  */
 }
 
index abb67467042e5909ae04a172c89aecb868c06ce1..e1b0d442f1c569baabf31f40ac1ad71cf19320d0 100644 (file)
@@ -219,7 +219,7 @@ DEF_ENUM_FLAGS_TYPE (enum type_instance_flag_value, type_instance_flags);
 /* * FIXME drow/2002-06-03:  Only used for methods, but applies as well
    to functions.  */
 
-#define TYPE_VARARGS(t)                (TYPE_MAIN_TYPE (t)->flag_varargs)
+#define TYPE_VARARGS(t)                ((t)->has_varargs ())
 
 /* * Identify a vector type.  Gcc is handling this by adding an extra
    attribute to the array type.  We slurp that in as a new flag of a
@@ -828,7 +828,7 @@ struct main_type
   unsigned int m_flag_stub : 1;
   unsigned int m_flag_target_stub : 1;
   unsigned int m_flag_prototyped : 1;
-  unsigned int flag_varargs : 1;
+  unsigned int m_flag_varargs : 1;
   unsigned int flag_vector : 1;
   unsigned int flag_stub_supported : 1;
   unsigned int flag_gnu_ifunc : 1;
@@ -1108,6 +1108,16 @@ struct type
     this->main_type->m_flag_prototyped = is_prototyped;
   }
 
+  bool has_varargs () const
+  {
+    return this->main_type->m_flag_varargs;
+  }
+
+  void set_has_varargs (bool has_varargs)
+  {
+    this->main_type->m_flag_varargs = has_varargs;
+  }
+
   /* * Return the dynamic property of the requested KIND from this type's
      list of dynamic properties.  */
   dynamic_prop *dyn_prop (dynamic_prop_node_kind kind) const;
This page took 0.052344 seconds and 4 git commands to generate.