mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-26 01:07:52 +00:00
Always pass an explicit language down to c_type_print
The next patch will want to do language->print_type(type, ...), to print a type in a given language, avoiding a dependency on the current language. That doesn't work correctly currently, however, because most language implementations of language_defn::print_type call c_print_type without passing down the language. There are two overloads of c_print_type, one that takes a language, and one that does not. The one that does not uses the current language, defeating the point of calling language->print_type()... This commit removes the c_print_type overload that does not take a language, and adjusts the codebase throughout to always pass down a language. In most places, there's already an enum language handy. language_defn::print_type implementations naturally pass down this->la_language. In a couple spots, like in ada-typeprint.c and rust-lang.c there's no enum language handy, but the code is written for a specific language, so we just hardcode the language. In gnuv3_print_method_ptr, I wasn't sure whether we could hardcode C++ here, and we don't have an enum language handy, so I made it use the current language, just like today. Can always be improved later. Change-Id: Ib54fab4cf0fd307bfd55bf1dd5056830096a653b
This commit is contained in:
@@ -163,22 +163,6 @@ c_print_type_1 (struct type *type,
|
||||
}
|
||||
}
|
||||
|
||||
/* LEVEL is the depth to indent lines by. */
|
||||
|
||||
void
|
||||
c_print_type (struct type *type,
|
||||
const char *varstring,
|
||||
struct ui_file *stream,
|
||||
int show, int level,
|
||||
const struct type_print_options *flags)
|
||||
{
|
||||
struct print_offset_data podata (flags);
|
||||
|
||||
c_print_type_1 (type, varstring, stream, show, level,
|
||||
current_language->la_language, flags, &podata);
|
||||
}
|
||||
|
||||
|
||||
/* See c-lang.h. */
|
||||
|
||||
void
|
||||
@@ -303,7 +287,7 @@ cp_type_print_method_args (struct type *mtype, const char *prefix,
|
||||
if (FIELD_ARTIFICIAL (arg))
|
||||
continue;
|
||||
|
||||
c_print_type (arg.type (), "", stream, 0, 0, flags);
|
||||
c_print_type (arg.type (), "", stream, 0, 0, language, flags);
|
||||
|
||||
if (i == nargs && varargs)
|
||||
gdb_printf (stream, ", ...");
|
||||
@@ -872,7 +856,8 @@ c_type_print_varspec_suffix (struct type *type,
|
||||
|
||||
static void
|
||||
c_type_print_template_args (const struct type_print_options *flags,
|
||||
struct type *type, struct ui_file *stream)
|
||||
struct type *type, struct ui_file *stream,
|
||||
enum language language)
|
||||
{
|
||||
int first = 1, i;
|
||||
|
||||
@@ -899,7 +884,7 @@ c_type_print_template_args (const struct type_print_options *flags,
|
||||
gdb_printf (stream, "%s = ", sym->linkage_name ());
|
||||
}
|
||||
|
||||
c_print_type (sym->type (), "", stream, -1, 0, flags);
|
||||
c_print_type (sym->type (), "", stream, -1, 0, language, flags);
|
||||
}
|
||||
|
||||
if (!first)
|
||||
@@ -1094,7 +1079,7 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
|
||||
struct type *basetype;
|
||||
int vptr_fieldno;
|
||||
|
||||
c_type_print_template_args (&local_flags, type, stream);
|
||||
c_type_print_template_args (&local_flags, type, stream, language);
|
||||
|
||||
/* Add in template parameters when printing derivation info. */
|
||||
if (local_flags.local_typedefs != NULL)
|
||||
|
||||
Reference in New Issue
Block a user