gdb: Convert language_data::c_style_arrays to a method
authorAndrew Burgess <andrew.burgess@embecosm.com>
Sat, 4 Jul 2020 08:06:08 +0000 (09:06 +0100)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Wed, 16 Sep 2020 09:16:47 +0000 (10:16 +0100)
Convert language_data::c_style_arrays member variable to a virtual
method language_defn::c_style_arrays_p.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Remove c_style_arrays
initializer.
(ada_language::c_style_arrays_p): New member fuction.
* c-lang.c (c_language_data): Remove c_style_arrays
initializer.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* eval.c (ptrmath_type_p): Update call to c_style_arrays_p.
* f-lang.c (f_language_data): Remove c_style_arrays initializer.
(f_language::c_style_arrays_p): New member function.
* go-lang.c (go_language_data): Remove c_style_arrays initializer.
* infcall.c (value_arg_coerce): Update call to c_style_arrays_p.
* language.c (unknown_language_data): Remove c_style_arrays
initializer.
(auto_language_data): Likewise.
* language.h (language_data): Remove c_style_arrays field.
(language_defn::c_style_arrays_p): New member function.
* m2-lang.c (m2_language_data): Remove c_style_arrays initializer.
(m2_language::c_style_arrays_p): New member function.
* objc-lang.c (objc_language_data): Remove c_style_arrays
initializer.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.
* valarith.c (value_subscript): Update call to c_style_arrays_p,
and update local variable to a bool.
* valops.c (value_cast): Update call to c_style_arrays_p.
(value_array): Likewise.
* value.c (coerce_array): Likewise.

18 files changed:
gdb/ChangeLog
gdb/ada-lang.c
gdb/c-lang.c
gdb/d-lang.c
gdb/eval.c
gdb/f-lang.c
gdb/go-lang.c
gdb/infcall.c
gdb/language.c
gdb/language.h
gdb/m2-lang.c
gdb/objc-lang.c
gdb/opencl-lang.c
gdb/p-lang.c
gdb/rust-lang.c
gdb/valarith.c
gdb/valops.c
gdb/value.c

index dfdd18f61010d3299bf5b51b663dd1412ffb54f3..4f4336f48143c1b0093b2763ba8c33a7c6f2eda0 100644 (file)
@@ -1,3 +1,37 @@
+2020-09-16  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * ada-lang.c (ada_language_data): Remove c_style_arrays
+       initializer.
+       (ada_language::c_style_arrays_p): New member fuction.
+       * c-lang.c (c_language_data): Remove c_style_arrays
+       initializer.
+       (cplus_language_data): Likewise.
+       (asm_language_data): Likewise.
+       (minimal_language_data): Likewise.
+       * d-lang.c (d_language_data): Likewise.
+       * eval.c (ptrmath_type_p): Update call to c_style_arrays_p.
+       * f-lang.c (f_language_data): Remove c_style_arrays initializer.
+       (f_language::c_style_arrays_p): New member function.
+       * go-lang.c (go_language_data): Remove c_style_arrays initializer.
+       * infcall.c (value_arg_coerce): Update call to c_style_arrays_p.
+       * language.c (unknown_language_data): Remove c_style_arrays
+       initializer.
+       (auto_language_data): Likewise.
+       * language.h (language_data): Remove c_style_arrays field.
+       (language_defn::c_style_arrays_p): New member function.
+       * m2-lang.c (m2_language_data): Remove c_style_arrays initializer.
+       (m2_language::c_style_arrays_p): New member function.
+       * objc-lang.c (objc_language_data): Remove c_style_arrays
+       initializer.
+       * opencl-lang.c (opencl_language_data): Likewise.
+       * p-lang.c (pascal_language_data): Likewise.
+       * rust-lang.c (rust_language_data): Likewise.
+       * valarith.c (value_subscript): Update call to c_style_arrays_p,
+       and update local variable to a bool.
+       * valops.c (value_cast): Update call to c_style_arrays_p.
+       (value_array): Likewise.
+       * value.c (coerce_array): Likewise.
+
 2020-09-16  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * ada-lang.c (ada_language_data): Remove la_language initializer.
index b1127d8421791781b5b0b7639621e4e962884c38..859dcec84ba792e8b724ffc5ddc466700b7c50ae 100644 (file)
@@ -13716,7 +13716,6 @@ extern const struct language_data ada_language_data =
   &ada_exp_descriptor,
   true,                         /* la_store_sym_names_in_linkage_form_p */
   ada_op_print_tab,             /* expression operators for printing */
-  0,                            /* c-style arrays */
   1,                            /* String lower bound */
   &ada_varobj_ops,
 };
@@ -14200,6 +14199,11 @@ public:
   const char *struct_too_deep_ellipsis () const override
   { return "(...)"; }
 
+  /* See language.h.  */
+
+  bool c_style_arrays_p () const override
+  { return false; }
+
 protected:
   /* See language.h.  */
 
index d8d66c241033431ba7a21762dc4013466945bcd0..41eac2d43a3c83bdd77aa79346ef1931e13c6bc4 100644 (file)
@@ -882,7 +882,6 @@ extern const struct language_data c_language_data =
   &exp_descriptor_c,
   true,                                /* la_store_sym_names_in_linkage_form_p */
   c_op_print_tab,              /* expression operators for printing */
-  1,                           /* c-style arrays */
   0,                           /* String lower bound */
   &c_varobj_ops,
 };
@@ -990,7 +989,6 @@ extern const struct language_data cplus_language_data =
   &exp_descriptor_c,
   false,                       /* la_store_sym_names_in_linkage_form_p */
   c_op_print_tab,              /* expression operators for printing */
-  1,                           /* c-style arrays */
   0,                           /* String lower bound */
   &cplus_varobj_ops,
 };
@@ -1201,7 +1199,6 @@ extern const struct language_data asm_language_data =
   &exp_descriptor_c,
   true,                                /* la_store_sym_names_in_linkage_form_p */
   c_op_print_tab,              /* expression operators for printing */
-  1,                           /* c-style arrays */
   0,                           /* String lower bound */
   &default_varobj_ops,
 };
@@ -1270,7 +1267,6 @@ extern const struct language_data minimal_language_data =
   &exp_descriptor_c,
   true,                                /* la_store_sym_names_in_linkage_form_p */
   c_op_print_tab,              /* expression operators for printing */
-  1,                           /* c-style arrays */
   0,                           /* String lower bound */
   &default_varobj_ops,
 };
index 18f785fd58dd472e222e39b0ab20c2ce634f874f..679120899891ecf51ae5621270dc0c8e3278b6e9 100644 (file)
@@ -135,7 +135,6 @@ extern const struct language_data d_language_data =
   &exp_descriptor_c,
   false,                       /* la_store_sym_names_in_linkage_form_p */
   d_op_print_tab,              /* Expression operators for printing.  */
-  1,                           /* C-style arrays.  */
   0,                           /* String lower bound.  */
   &default_varobj_ops,
 };
index 1177f7444e6814ffac2aa0ce5bdd0202aeddb9c7..1af57fcad83d4887f8d3c6d0ced2cef87063748f 100644 (file)
@@ -622,7 +622,7 @@ ptrmath_type_p (const struct language_defn *lang, struct type *type)
       return 1;
 
     case TYPE_CODE_ARRAY:
-      return type->is_vector () ? 0 : lang->c_style_arrays;
+      return type->is_vector () ? 0 : lang->c_style_arrays_p ();
 
     default:
       return 0;
index 55d0a7a00deb21355a1ca04bf5e3abd7fe03358c..649716ba1060ceb728ae1a9eff7c13f4a2931b16 100644 (file)
@@ -493,7 +493,6 @@ extern const struct language_data f_language_data =
   &exp_descriptor_f,
   false,                       /* la_store_sym_names_in_linkage_form_p */
   f_op_print_tab,              /* expression operators for printing */
-  0,                           /* arrays are first-class (not c-style) */
   1,                           /* String lower bound */
   &default_varobj_ops,
 };
@@ -720,6 +719,11 @@ public:
   const char *struct_too_deep_ellipsis () const override
   { return "(...)"; }
 
+  /* See language.h.  */
+
+  bool c_style_arrays_p () const override
+  { return false; }
+
 protected:
 
   /* See language.h.  */
index ed7fcd1f425b9567f5c41e9036163beb8f8f82c6..c2724e3d7cc06e5c8867283d302b0b324b552efd 100644 (file)
@@ -515,7 +515,6 @@ extern const struct language_data go_language_data =
   &exp_descriptor_c,
   false,                       /* la_store_sym_names_in_linkage_form_p */
   go_op_print_tab,             /* Expression operators for printing.  */
-  1,                           /* C-style arrays.  */
   0,                           /* String lower bound.  */
   &default_varobj_ops,
 };
index f87b7456ec050032704f881447cc32d4fd327a0e..8df7523f1576881e3f42fb98f06f97a72a258fb9 100644 (file)
@@ -219,7 +219,7 @@ value_arg_coerce (struct gdbarch *gdbarch, struct value *arg,
       /* Arrays are coerced to pointers to their first element, unless
          they are vectors, in which case we want to leave them alone,
          because they are passed by value.  */
-      if (current_language->c_style_arrays)
+      if (current_language->c_style_arrays_p ())
        if (!type->is_vector ())
          type = lookup_pointer_type (TYPE_TARGET_TYPE (type));
       break;
index 55e8104132b1b611b6d4c3745f353b0a4984c432..9a496ae8548bec0af71188c3dce12f83494d6187 100644 (file)
@@ -782,7 +782,6 @@ extern const struct language_data unknown_language_data =
   &exp_descriptor_standard,
   true,                                /* store_sym_names_in_linkage_form_p */
   unk_op_print_tab,            /* expression operators for printing */
-  1,                           /* c-style arrays */
   0,                           /* String lower bound */
   &default_varobj_ops,
 };
@@ -917,7 +916,6 @@ extern const struct language_data auto_language_data =
   &exp_descriptor_standard,
   false,                       /* store_sym_names_in_linkage_form_p */
   unk_op_print_tab,            /* expression operators for printing */
-  1,                           /* c-style arrays */
   0,                           /* String lower bound */
   &default_varobj_ops,
 };
index 731b641d261d7f07b6608e76b28b9c9c3b6759a7..83014e47789d1586de855c454e0b12fdb26441e2 100644 (file)
@@ -232,11 +232,6 @@ struct language_data
 
     const struct op_print *la_op_print_tab;
 
-    /* Zero if the language has first-class arrays.  True if there are no
-       array values, and array objects decay to pointers, as in C.  */
-
-    char c_style_arrays;
-
     /* Index to use for extracting the first element of a string.  */
     char string_lower_bound;
 
@@ -565,6 +560,14 @@ struct language_defn : language_data
   virtual const char *name_of_this () const
   { return nullptr; }
 
+  /* Return false if the language has first-class arrays.  Return true if
+     there are no array values, and array objects decay to pointers, as in
+     C.  The default is true as currently most supported languages behave
+     in this manor.  */
+
+  virtual bool c_style_arrays_p () const
+  { return true; }
+
 protected:
 
   /* This is the overridable part of the GET_SYMBOL_NAME_MATCHER method.
index 94340b0d9b29131e5013772cb92de819aed09ffa..9dd557777c0a2473e755cfa3f20f0dcd16060519 100644 (file)
@@ -206,7 +206,6 @@ extern const struct language_data m2_language_data =
   &exp_descriptor_modula2,
   false,                       /* la_store_sym_names_in_linkage_form_p */
   m2_op_print_tab,             /* expression operators for printing */
-  0,                           /* arrays are first-class (not c-style) */
   0,                           /* String lower bound */
   &default_varobj_ops,
 };
@@ -436,6 +435,11 @@ public:
 
     return false;
   }
+
+  /* See language.h.  */
+
+  bool c_style_arrays_p () const override
+  { return false; }
 };
 
 /* Single instance of the M2 language.  */
index f605c2194b067515cca2b474a0b35252ca5e6828..66b7b50144b3b934ed539f9479e70ac1bc5c6bd9 100644 (file)
@@ -330,7 +330,6 @@ extern const struct language_data objc_language_data =
   &exp_descriptor_standard,
   false,                       /* la_store_sym_names_in_linkage_form_p */
   objc_op_print_tab,           /* Expression operators for printing */
-  1,                           /* C-style arrays */
   0,                           /* String lower bound */
   &default_varobj_ops,
 };
index 2c8dba013fe805fe5e88ead317364671c4cbfa60..1ac3aa42a8ebd05da6c3058dbe36b935b976bee0 100644 (file)
@@ -1013,7 +1013,6 @@ extern const struct language_data opencl_language_data =
   &exp_descriptor_opencl,
   false,                       /* la_store_sym_names_in_linkage_form_p */
   c_op_print_tab,              /* expression operators for printing */
-  1,                           /* c-style arrays */
   0,                           /* String lower bound */
   &default_varobj_ops,
 };
index aef908c7dc6c7723603a937cd8eb04a525fbe00d..66ba51ac8eb420092bd37705c0b29e691fb83f31 100644 (file)
@@ -259,7 +259,6 @@ extern const struct language_data pascal_language_data =
   &exp_descriptor_standard,
   false,                       /* la_store_sym_names_in_linkage_form_p */
   pascal_op_print_tab,         /* expression operators for printing */
-  1,                           /* c-style arrays */
   0,                           /* String lower bound */
   &default_varobj_ops,
 };
index 2ceb573da2bef618dc72bcd1ff651440e2412f97..de971e6255a1c48d1de41395ddb7008d67ee51a1 100644 (file)
@@ -1908,7 +1908,6 @@ extern const struct language_data rust_language_data =
   &exp_descriptor_rust,
   false,                       /* la_store_sym_names_in_linkage_form_p */
   c_op_print_tab,              /* expression operators for printing */
-  1,                           /* c-style arrays */
   0,                           /* String lower bound */
   &default_varobj_ops,
 };
index c418fc6f55a8007ca8999e3cac491788f38e4a1c..7127a5d676339e3d95cf0191a685c88ace99d40a 100644 (file)
@@ -140,7 +140,7 @@ value_ptrdiff (struct value *arg1, struct value *arg2)
 struct value *
 value_subscript (struct value *array, LONGEST index)
 {
-  int c_style = current_language->c_style_arrays;
+  bool c_style = current_language->c_style_arrays_p ();
   struct type *tarray;
 
   array = coerce_ref (array);
@@ -156,7 +156,7 @@ value_subscript (struct value *array, LONGEST index)
       if (VALUE_LVAL (array) != lval_memory)
        return value_subscripted_rvalue (array, index, lowerbound);
 
-      if (c_style == 0)
+      if (!c_style)
        {
          if (index >= lowerbound && index <= upperbound)
            return value_subscripted_rvalue (array, index, lowerbound);
@@ -165,7 +165,7 @@ value_subscript (struct value *array, LONGEST index)
          if (upperbound > -1)
            warning (_("array or string index out of range"));
          /* fall doing C stuff */
-         c_style = 1;
+         c_style = true;
        }
 
       index -= lowerbound;
index 6dc2f54b14d52bd8e18bc57aefd87be0924d8acc..7b604da0fd562427fdbba736eed91819a66332ea 100644 (file)
@@ -414,7 +414,7 @@ value_cast (struct type *type, struct value *arg2)
        }
     }
 
-  if (current_language->c_style_arrays
+  if (current_language->c_style_arrays_p ()
       && type2->code () == TYPE_CODE_ARRAY
       && !type2->is_vector ())
     arg2 = value_coerce_array (arg2);
@@ -1622,7 +1622,7 @@ value_array (int lowbound, int highbound, struct value **elemvec)
   arraytype = lookup_array_range_type (value_enclosing_type (elemvec[0]),
                                       lowbound, highbound);
 
-  if (!current_language->c_style_arrays)
+  if (!current_language->c_style_arrays_p ())
     {
       val = allocate_value (arraytype);
       for (idx = 0; idx < nelem; idx++)
index 8f4030e90b203ec78a52c365415173c427b9fc50..c72b2fd6cead66dcc53bd936d8b945a6ce2d2cb5 100644 (file)
@@ -3687,7 +3687,7 @@ coerce_array (struct value *arg)
   switch (type->code ())
     {
     case TYPE_CODE_ARRAY:
-      if (!type->is_vector () && current_language->c_style_arrays)
+      if (!type->is_vector () && current_language->c_style_arrays_p ())
        arg = value_coerce_array (arg);
       break;
     case TYPE_CODE_FUNC:
This page took 0.049464 seconds and 4 git commands to generate.