aboutsummaryrefslogtreecommitdiff
path: root/gdb/c-lang.c
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2020-07-03 18:46:16 +0100
committerAndrew Burgess <andrew.burgess@embecosm.com>2020-09-16 10:16:46 +0100
commite171d6f15e1a65a1fb5a951d2b186ed0c62aec0c (patch)
tree5d5fe46ff2eb9ff81ab28abb90126198fc9bf3b5 /gdb/c-lang.c
parent6f7664a9c33b110248d0fb68bcc41fdb48396c51 (diff)
downloadgdb-e171d6f15e1a65a1fb5a951d2b186ed0c62aec0c.zip
gdb-e171d6f15e1a65a1fb5a951d2b186ed0c62aec0c.tar.gz
gdb-e171d6f15e1a65a1fb5a951d2b186ed0c62aec0c.tar.bz2
gdb: Convert la_filename_extensions to a method
Convert language_data::la_filename_extensions member variable to a virtual method language_defn::filename_extensions. The new method returns a vector of filename extensions, which means that where previously we needed a NULL marker on the end of the list, we can now discard this. All of the old arrays that contained the extensions now become static data within each languages filename_extensions method. I've updated the single use of the filename_extensions method to make use of this method returning a vector. And, just in case anyone accidentally adds a NULL marked into a languages extensions list, I've added a new assert in add_filename_language (symtab.c) to catch this. gdb/ChangeLog: * ada-lang.c (ada_extensions): Delete, moved into ada_language::filename_extensions. (ada_language_data): Remove la_filename_extensions initializer. (ada_language::filename_extensions): New member function. * c-lang.c (c_extensions): Delete, moved into c_language::filename_extensions. (c_language_data): Remove la_filename_extensions initializer. (c_language::filename_extensions): New member function. (cplus_extensions): Delete, moved into cplus_language::filename_extensions. (cplus_language_data): Remove la_filename_extensions initializer. (cplus_language::filename_extensions): New member function. (asm_extensions): Delete, moved into asm_language::filename_extensions. (asm_language_data): Remove la_filename_extensions initializer. (asm_language::filename_extensions): New member function. (minimal_language_data): Remove la_filename_extensions initializer. * d-lang.c (d_extensions): Delete, moved into d_language::filename_extensions. (d_language_data): Remove la_filename_extensions initializer. (d_language::filename_extensions): New member function. * f-lang.c (f_extensions): Delete, moved into f_language::filename_extensions. (f_language_data): Remove la_filename_extensions initializer. (f_language::filename_extensions): New member function. * go-lang.c (go_language_data): Remove la_filename_extensions initializer. * language.c (add_set_language_command): Update now that filename_extensions returns a vector. (unknown_language_data): Remove la_filename_extensions initializer. (auto_language_data): Likewise. * language.h (language_data): Remove la_filename_extensions field. (language_defn::filename_extensions): New member function. * m2-lang.c (m2_language_data): Remove la_filename_extensions initializer. * objc-lang.c (objc_extensions): Delete, moved into objc_language::filename_extensions. (objc_language_data): Remove la_filename_extensions initializer. (objc_language::filename_extensions): New member function. * opencl-lang.c (opencl_language_data): Remove la_filename_extensions initializer. * p-lang.c (pascal_extensions): Delete, moved into pascal_language::filename_extensions. (pascal_language_data): Remove la_filename_extensions initializer. (pascal_language::filename_extensions): New member function. * rust-lang.c (rust_extensions): Delete, moved into rust_language::filename_extensions. (rust_language_data): Remove la_filename_extensions initializer. (rust_language::filename_extensions): New member function. * symfile.c (add_filename_language): Add new assert.
Diffstat (limited to 'gdb/c-lang.c')
-rw-r--r--gdb/c-lang.c45
1 files changed, 26 insertions, 19 deletions
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index eb987f4..ce4620a 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -871,11 +871,6 @@ const struct exp_descriptor exp_descriptor_c =
evaluate_subexp_c
};
-static const char * const c_extensions[] =
-{
- ".c", NULL
-};
-
/* Constant data that describes the C language. */
extern const struct language_data c_language_data =
@@ -885,7 +880,6 @@ extern const struct language_data c_language_data =
case_sensitive_on,
array_row_major,
macro_expansion_c,
- c_extensions,
&exp_descriptor_c,
true, /* la_store_sym_names_in_linkage_form_p */
c_op_print_tab, /* expression operators for printing */
@@ -914,6 +908,14 @@ public:
{ return "C"; }
/* See language.h. */
+
+ const std::vector<const char *> &filename_extensions () const override
+ {
+ static const std::vector<const char *> extensions = { ".c" };
+ return extensions;
+ }
+
+ /* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
{
@@ -978,11 +980,6 @@ enum cplus_primitive_types {
nr_cplus_primitive_types
};
-static const char * const cplus_extensions[] =
-{
- ".C", ".cc", ".cp", ".cpp", ".cxx", ".c++", NULL
-};
-
/* Constant data that describes the C++ language. */
extern const struct language_data cplus_language_data =
@@ -992,7 +989,6 @@ extern const struct language_data cplus_language_data =
case_sensitive_on,
array_row_major,
macro_expansion_c,
- cplus_extensions,
&exp_descriptor_c,
false, /* la_store_sym_names_in_linkage_form_p */
c_op_print_tab, /* expression operators for printing */
@@ -1022,6 +1018,15 @@ public:
/* See language.h. */
+ const std::vector<const char *> &filename_extensions () const override
+ {
+ static const std::vector<const char *> extensions
+ = { ".C", ".cc", ".cp", ".cpp", ".cxx", ".c++" };
+ return extensions;
+ }
+
+ /* See language.h. */
+
struct language_pass_by_ref_info pass_by_reference_info
(struct type *type) const override
{
@@ -1187,11 +1192,6 @@ protected:
static cplus_language cplus_language_defn;
-static const char * const asm_extensions[] =
-{
- ".s", ".sx", ".S", NULL
-};
-
/* Constant data that describes the ASM language. */
extern const struct language_data asm_language_data =
@@ -1201,7 +1201,6 @@ extern const struct language_data asm_language_data =
case_sensitive_on,
array_row_major,
macro_expansion_c,
- asm_extensions,
&exp_descriptor_c,
true, /* la_store_sym_names_in_linkage_form_p */
c_op_print_tab, /* expression operators for printing */
@@ -1229,6 +1228,15 @@ public:
const char *natural_name () const override
{ return "Assembly"; }
+ /* See language.h. */
+
+ const std::vector<const char *> &filename_extensions () const override
+ {
+ static const std::vector<const char *> extensions
+ = { ".s", ".sx", ".S" };
+ return extensions;
+ }
+
/* See language.h.
FIXME: Should this have its own arch info method? */
@@ -1263,7 +1271,6 @@ extern const struct language_data minimal_language_data =
case_sensitive_on,
array_row_major,
macro_expansion_c,
- NULL,
&exp_descriptor_c,
true, /* la_store_sym_names_in_linkage_form_p */
c_op_print_tab, /* expression operators for printing */