+2020-09-16 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * 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.
+
2020-09-16 Andrew Burgess <andrew.burgess@embecosm.com>
* ada-lang.c (ada_language_data): Remove la_name and
}
}
-static const char * const ada_extensions[] =
-{
- ".adb", ".ads", ".a", ".ada", ".dg", NULL
-};
-
/* Constant data that describes the Ada language. */
extern const struct language_data ada_language_data =
that's not quite what this means. */
array_row_major,
macro_expansion_no,
- ada_extensions,
&ada_exp_descriptor,
true, /* la_store_sym_names_in_linkage_form_p */
ada_op_print_tab, /* expression operators for printing */
const char *natural_name () const override
{ return "Ada"; }
+ /* See language.h. */
+
+ const std::vector<const char *> &filename_extensions () const override
+ {
+ static const std::vector<const char *> extensions
+ = { ".adb", ".ads", ".a", ".ada", ".dg" };
+ return extensions;
+ }
+
/* Print an array element index using the Ada syntax. */
void print_array_index (struct type *index_type,
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 =
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 */
const char *natural_name () const override
{ 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
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 =
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 */
/* 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
{
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 =
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 */
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? */
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 */
nr_d_primitive_types
};
-static const char * const d_extensions[] =
-{
- ".d", NULL
-};
-
/* Constant data that describes the D language. */
extern const struct language_data d_language_data =
case_sensitive_on,
array_row_major,
macro_expansion_no,
- d_extensions,
&exp_descriptor_c,
false, /* la_store_sym_names_in_linkage_form_p */
d_op_print_tab, /* Expression operators for printing. */
const char *natural_name () const override
{ return "D"; }
+ /* See language.h. */
+
+ const std::vector<const char *> &filename_extensions () const override
+ {
+ static const std::vector<const char *> extensions = { ".d" };
+ return extensions;
+ }
+
/* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
return 0;
}
-static const char * const f_extensions[] =
-{
- ".f", ".F", ".for", ".FOR", ".ftn", ".FTN", ".fpp", ".FPP",
- ".f90", ".F90", ".f95", ".F95", ".f03", ".F03", ".f08", ".F08",
- NULL
-};
-
/* Expression processing for Fortran. */
static const struct exp_descriptor exp_descriptor_f =
{
case_sensitive_off,
array_column_major,
macro_expansion_no,
- f_extensions,
&exp_descriptor_f,
false, /* la_store_sym_names_in_linkage_form_p */
f_op_print_tab, /* expression operators for printing */
const char *natural_name () const override
{ return "Fortran"; }
+ /* See language.h. */
+
+ const std::vector<const char *> &filename_extensions () const override
+ {
+ static const std::vector<const char *> extensions = {
+ ".f", ".F", ".for", ".FOR", ".ftn", ".FTN", ".fpp", ".FPP",
+ ".f90", ".F90", ".f95", ".F95", ".f03", ".F03", ".f08", ".F08"
+ };
+ return extensions;
+ }
+
/* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
case_sensitive_on,
array_row_major,
macro_expansion_no,
- NULL,
&exp_descriptor_c,
false, /* la_store_sym_names_in_linkage_form_p */
go_op_print_tab, /* Expression operators for printing. */
/* Add the filename extensions. */
for (const auto &lang : language_defn::languages)
- if (lang->la_filename_extensions != NULL)
- {
- for (size_t i = 0; lang->la_filename_extensions[i] != NULL; ++i)
- add_filename_language (lang->la_filename_extensions[i],
- lang->la_language);
- }
+ for (const char * const &ext : lang->filename_extensions ())
+ add_filename_language (ext, lang->la_language);
/* Build the "help set language" docs. */
string_file doc;
case_sensitive_on,
array_row_major,
macro_expansion_no,
- NULL,
&exp_descriptor_standard,
true, /* store_sym_names_in_linkage_form_p */
unk_op_print_tab, /* expression operators for printing */
case_sensitive_on,
array_row_major,
macro_expansion_no,
- NULL,
&exp_descriptor_standard,
false, /* store_sym_names_in_linkage_form_p */
unk_op_print_tab, /* expression operators for printing */
/* Style of macro expansion, if any, supported by this language. */
enum macro_expansion la_macro_expansion;
- /* A NULL-terminated array of file extensions for this language.
- The extension must include the ".", like ".c". If this
- language doesn't need to provide any filename extensions, this
- may be NULL. */
-
- const char *const *la_filename_extensions;
-
/* Definitions related to expression printing, prefixifying, and
dumping. */
virtual const char *natural_name () const = 0;
+ /* Return a vector of file extensions for this language. The extension
+ must include the ".", like ".c". If this language doesn't need to
+ provide any filename extensions, this may be an empty vector (which is
+ the default). */
+
+ virtual const std::vector<const char *> &filename_extensions () const
+ {
+ static const std::vector<const char *> no_extensions;
+ return no_extensions;
+ }
+
/* Print the index of an element of an array. This default
implementation prints using C99 syntax. */
case_sensitive_on,
array_row_major,
macro_expansion_no,
- NULL,
&exp_descriptor_modula2,
false, /* la_store_sym_names_in_linkage_form_p */
m2_op_print_tab, /* expression operators for printing */
{NULL, OP_NULL, PREC_NULL, 0}
};
-static const char * const objc_extensions[] =
-{
- ".m", NULL
-};
-
/* Constant data representing the Objective-C language. */
extern const struct language_data objc_language_data =
case_sensitive_on,
array_row_major,
macro_expansion_c,
- objc_extensions,
&exp_descriptor_standard,
false, /* la_store_sym_names_in_linkage_form_p */
objc_op_print_tab, /* Expression operators for printing */
const char *natural_name () const override
{ return "Objective-C"; }
+ /* See language.h. */
+
+ const std::vector<const char *> &filename_extensions () const override
+ {
+ static const std::vector<const char *> extensions = { ".m" };
+ return extensions;
+ }
+
/* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
case_sensitive_on,
array_row_major,
macro_expansion_c,
- NULL,
&exp_descriptor_opencl,
false, /* la_store_sym_names_in_linkage_form_p */
c_op_print_tab, /* expression operators for printing */
nr_pascal_primitive_types
};
-static const char * const p_extensions[] =
-{
- ".pas", ".p", ".pp", NULL
-};
-
/* Constant data representing the Pascal language. */
extern const struct language_data pascal_language_data =
case_sensitive_on,
array_row_major,
macro_expansion_no,
- p_extensions,
&exp_descriptor_standard,
false, /* la_store_sym_names_in_linkage_form_p */
pascal_op_print_tab, /* expression operators for printing */
const char *natural_name () const override
{ return "Pascal"; }
+ /* See language.h. */
+
+ const std::vector<const char *> &filename_extensions () const override
+ {
+ static const std::vector<const char *> extensions
+ = { ".pas", ".p", ".pp" };
+ return extensions;
+ }
/* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
rust_evaluate_subexp
};
-static const char * const rust_extensions[] =
-{
- ".rs", NULL
-};
-
/* Constant data representing the Rust language. */
extern const struct language_data rust_language_data =
case_sensitive_on,
array_row_major,
macro_expansion_no,
- rust_extensions,
&exp_descriptor_rust,
false, /* la_store_sym_names_in_linkage_form_p */
c_op_print_tab, /* expression operators for printing */
const char *natural_name () const override
{ return "Rust"; }
+ /* See language.h. */
+
+ const std::vector<const char *> &filename_extensions () const override
+ {
+ static const std::vector<const char *> extensions = { ".rs" };
+ return extensions;
+ }
+
/* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
void
add_filename_language (const char *ext, enum language lang)
{
+ gdb_assert (ext != nullptr);
filename_language_table.emplace_back (ext, lang);
}