* [RFA 0/4] Remove TYPE_TAG_NAME
@ 2018-04-17 19:51 Tom Tromey
2018-04-17 19:51 ` [RFA 3/4] " Tom Tromey
` (5 more replies)
0 siblings, 6 replies; 16+ messages in thread
From: Tom Tromey @ 2018-04-17 19:51 UTC (permalink / raw)
To: gdb-patches
As mentioned on the list, here is the series to remove TYPE_TAG_NAME.
I think each patch is relatively self-explanatory, so I won't describe
them further here.
Regression tested by the buildbot.
Tom
^ permalink raw reply [flat|nested] 16+ messages in thread
* [RFA 1/4] Make c_type_print_varspec_suffix static
2018-04-17 19:51 [RFA 0/4] Remove TYPE_TAG_NAME Tom Tromey
2018-04-17 19:51 ` [RFA 3/4] " Tom Tromey
@ 2018-04-17 19:51 ` Tom Tromey
2018-05-31 1:33 ` Joel Brobecker
2018-04-17 19:51 ` [RFA 4/4] Remove type_name_no_tag and rename type_name_no_tag_or_error Tom Tromey
` (3 subsequent siblings)
5 siblings, 1 reply; 16+ messages in thread
From: Tom Tromey @ 2018-04-17 19:51 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
I noticed that c_type_print_varspec_suffix is only called from
c-typeprint.c, so this patch makes it "static".
ChangeLog
2018-04-17 Tom Tromey <tom@tromey.com>
* typeprint.h (c_type_print_varspec_suffix): Don't declare.
* c-typeprint.c (c_type_print_varspec_suffix): Now static.
---
gdb/ChangeLog | 5 +++++
gdb/c-typeprint.c | 6 +++++-
gdb/typeprint.h | 3 ---
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index 1a8af78669..e26687ba25 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -50,6 +50,10 @@ enum access_specifier
s_protected
};
+static void c_type_print_varspec_suffix (struct type *, struct ui_file *, int,
+ int, int,
+ const struct type_print_options *);
+
static void c_type_print_varspec_prefix (struct type *,
struct ui_file *,
int, int, int,
@@ -716,7 +720,7 @@ remove_qualifiers (char *qid)
needed after the variable name (to describe its type).
Args work like c_type_print_varspec_prefix. */
-void
+static void
c_type_print_varspec_suffix (struct type *type,
struct ui_file *stream,
int show, int passed_a_ptr,
diff --git a/gdb/typeprint.h b/gdb/typeprint.h
index 895eebd50a..74006b3058 100644
--- a/gdb/typeprint.h
+++ b/gdb/typeprint.h
@@ -120,9 +120,6 @@ private:
void print_type_scalar (struct type * type, LONGEST, struct ui_file *);
-void c_type_print_varspec_suffix (struct type *, struct ui_file *, int,
- int, int, const struct type_print_options *);
-
void c_type_print_args (struct type *, struct ui_file *, int, enum language,
const struct type_print_options *);
--
2.13.6
^ permalink raw reply [flat|nested] 16+ messages in thread
* [RFA 3/4] Remove TYPE_TAG_NAME
2018-04-17 19:51 [RFA 0/4] Remove TYPE_TAG_NAME Tom Tromey
@ 2018-04-17 19:51 ` Tom Tromey
2018-04-18 16:57 ` Keith Seitz
2018-05-31 2:35 ` Joel Brobecker
2018-04-17 19:51 ` [RFA 1/4] Make c_type_print_varspec_suffix static Tom Tromey
` (4 subsequent siblings)
5 siblings, 2 replies; 16+ messages in thread
From: Tom Tromey @ 2018-04-17 19:51 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
TYPE_TAG_NAME has been an occasional source of confusion and bugs. It
seems to me that it is only useful for C and C++ -- but even there,
not so much, because at least with DWARF there doesn't seem to be any
way to wind up with a type where the name and the tag name are both
non-NULL and different.
So, this patch removes TYPE_TAG_NAME entirely. This should save a
little memory, but more importantly, it simplifies this part of gdb.
A few minor test suite adjustments were needed. In some situations
the new code does not yield identical output to the old code.
ChangeLog
2018-04-17 Tom Tromey <tom@tromey.com>
* valops.c (enum_constant_from_type, value_namespace_elt)
(value_maybe_namespace_elt): Update.
* valarith.c (find_size_for_pointer_math): Update.
* target-descriptions.c (make_gdb_type): Update.
* symmisc.c (print_symbol): Update.
* stabsread.c (define_symbol, read_type)
(complain_about_struct_wipeout, add_undefined_type)
(cleanup_undefined_types_1): Update.
* rust-lang.c (rust_tuple_type_p, rust_slice_type_p)
(rust_range_type_p, val_print_struct, rust_print_struct_def)
(rust_internal_print_type, rust_composite_type)
(rust_evaluate_funcall, rust_evaluate_subexp): Update.
* python/py-type.c (typy_get_tag): Update.
* p-typeprint.c (pascal_type_print_base): Update.
* mdebugread.c (parse_symbol, parse_type): Update.
* m2-typeprint.c (m2_long_set, m2_record_fields, m2_enum):
Update.
* guile/scm-type.c (gdbscm_type_tag): Update.
* go-lang.c (sixg_string_p): Update.
* gnu-v3-abi.c (build_gdb_vtable_type, build_std_type_info_type):
Update.
* gdbtypes.h (struct main_type) <tag_name>: Remove.
(TYPE_TAG_NAME): Remove.
* gdbtypes.c (type_name_no_tag): Simplify.
(check_typedef, check_types_equal, recursive_dump_type)
(copy_type_recursive, arch_composite_type): Update.
* f-typeprint.c (f_type_print_base): Update. Print "Type" prefix
in summary mode when needed.
* eval.c (evaluate_funcall): Update.
* dwarf2read.c (fixup_go_packaging, read_structure_type)
(process_structure_scope, read_enumeration_type)
(read_namespace_type, read_module_type, determine_prefix): Update.
* cp-support.c (inspect_type): Update.
* coffread.c (process_coff_symbol, decode_base_type): Update.
* c-varobj.c (c_is_path_expr_parent): Update.
* c-typeprint.c (c_type_print_base_struct_union): Update.
(c_type_print_base_1): Update. Print struct/class/union/enum in
summary when using C language.
* ax-gdb.c (gen_struct_ref, gen_namespace_elt)
(gen_maybe_namespace_elt): Update.
* ada-lang.c (ada_type_name): Simplify.
(empty_record, ada_template_to_fixed_record_type_1)
(template_to_static_fixed_type)
(to_record_with_fixed_variant_part, ada_check_typedef): Update.
testsuite/ChangeLog
2018-04-17 Tom Tromey <tom@tromey.com>
* gdb.xml/tdesc-regs.exp (load_description): Update expected
results.
* gdb.dwarf2/method-ptr.exp: Set language to C++.
* gdb.dwarf2/member-ptr-forwardref.exp: Set language to C++.
* gdb.cp/typeid.exp (do_typeid_tests): Update type_re.
* gdb.base/maint.exp (maint_pass_if): Update.
---
gdb/ChangeLog | 47 +++++++++++++++++++
gdb/ada-lang.c | 17 ++-----
gdb/ax-gdb.c | 6 +--
gdb/c-typeprint.c | 46 +++++++++++++------
gdb/c-varobj.c | 3 +-
gdb/coffread.c | 16 +------
gdb/cp-support.c | 2 +-
gdb/dwarf2read.c | 31 ++++---------
gdb/eval.c | 4 +-
gdb/f-typeprint.c | 13 ++++--
gdb/gdbtypes.c | 29 ++----------
gdb/gdbtypes.h | 21 ++-------
gdb/gnu-v3-abi.c | 4 +-
gdb/go-lang.c | 4 +-
gdb/guile/scm-type.c | 10 +++-
gdb/m2-typeprint.c | 22 +++------
gdb/mdebugread.c | 14 +++---
gdb/p-typeprint.c | 20 ++++----
gdb/python/py-type.c | 10 +++-
gdb/rust-lang.c | 53 +++++++++++-----------
gdb/stabsread.c | 20 +++-----
gdb/symmisc.c | 2 +-
gdb/target-descriptions.c | 1 -
gdb/testsuite/ChangeLog | 9 ++++
gdb/testsuite/gdb.base/maint.exp | 2 +-
gdb/testsuite/gdb.cp/typeid.exp | 2 +-
gdb/testsuite/gdb.dwarf2/member-ptr-forwardref.exp | 1 +
gdb/testsuite/gdb.dwarf2/method-ptr.exp | 1 +
gdb/testsuite/gdb.xml/tdesc-regs.exp | 4 +-
gdb/valarith.c | 2 -
gdb/valops.c | 6 +--
31 files changed, 215 insertions(+), 207 deletions(-)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index de20c43bed..41235def3e 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -8136,18 +8136,15 @@ ada_prefer_type (struct type *type0, struct type *type1)
return 0;
}
-/* The name of TYPE, which is either its TYPE_NAME, or, if that is
- null, its TYPE_TAG_NAME. Null if TYPE is null. */
+/* The name of TYPE, which is its TYPE_NAME. Null if TYPE is
+ null. */
const char *
ada_type_name (struct type *type)
{
if (type == NULL)
return NULL;
- else if (TYPE_NAME (type) != NULL)
- return TYPE_NAME (type);
- else
- return TYPE_TAG_NAME (type);
+ return TYPE_NAME (type);
}
/* Search the list of "descriptive" types associated to TYPE for a type
@@ -8316,7 +8313,6 @@ empty_record (struct type *templ)
TYPE_FIELDS (type) = NULL;
INIT_CPLUS_SPECIFIC (type);
TYPE_NAME (type) = "<empty>";
- TYPE_TAG_NAME (type) = NULL;
TYPE_LENGTH (type) = 0;
return type;
}
@@ -8375,7 +8371,6 @@ ada_template_to_fixed_record_type_1 (struct type *type,
TYPE_ALLOC (rtype, nfields * sizeof (struct field));
memset (TYPE_FIELDS (rtype), 0, sizeof (struct field) * nfields);
TYPE_NAME (rtype) = ada_type_name (type);
- TYPE_TAG_NAME (rtype) = NULL;
TYPE_FIXED_INSTANCE (rtype) = 1;
off = 0;
@@ -8652,7 +8647,6 @@ template_to_static_fixed_type (struct type *type0)
memcpy (TYPE_FIELDS (type), TYPE_FIELDS (type0),
sizeof (struct field) * nfields);
TYPE_NAME (type) = ada_type_name (type0);
- TYPE_TAG_NAME (type) = NULL;
TYPE_FIXED_INSTANCE (type) = 1;
TYPE_LENGTH (type) = 0;
}
@@ -8702,7 +8696,6 @@ to_record_with_fixed_variant_part (struct type *type, const gdb_byte *valaddr,
memcpy (TYPE_FIELDS (rtype), TYPE_FIELDS (type),
sizeof (struct field) * nfields);
TYPE_NAME (rtype) = ada_type_name (type);
- TYPE_TAG_NAME (rtype) = NULL;
TYPE_FIXED_INSTANCE (rtype) = 1;
TYPE_LENGTH (rtype) = TYPE_LENGTH (type);
@@ -9313,11 +9306,11 @@ ada_check_typedef (struct type *type)
type = check_typedef (type);
if (type == NULL || TYPE_CODE (type) != TYPE_CODE_ENUM
|| !TYPE_STUB (type)
- || TYPE_TAG_NAME (type) == NULL)
+ || TYPE_NAME (type) == NULL)
return type;
else
{
- const char *name = TYPE_TAG_NAME (type);
+ const char *name = TYPE_NAME (type);
struct type *type1 = ada_find_any_type (name);
if (type1 == NULL)
diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c
index 9a44d4b750..2468061aad 100644
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -1533,7 +1533,7 @@ gen_struct_ref (struct agent_expr *ax, struct axs_value *value,
if (!found)
error (_("Couldn't find member named `%s' in struct/union/class `%s'"),
- field, TYPE_TAG_NAME (type));
+ field, TYPE_NAME (type));
}
static int
@@ -1629,7 +1629,7 @@ gen_namespace_elt (struct agent_expr *ax, struct axs_value *value,
if (!found)
error (_("No symbol \"%s\" in namespace \"%s\"."),
- name, TYPE_TAG_NAME (curtype));
+ name, TYPE_NAME (curtype));
return found;
}
@@ -1644,7 +1644,7 @@ static int
gen_maybe_namespace_elt (struct agent_expr *ax, struct axs_value *value,
const struct type *curtype, char *name)
{
- const char *namespace_name = TYPE_TAG_NAME (curtype);
+ const char *namespace_name = TYPE_NAME (curtype);
struct block_symbol sym;
sym = cp_lookup_symbol_namespace (namespace_name, name,
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index a53331aefc..846727f298 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -1174,13 +1174,13 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
spurious "{unnamed struct}"/"{unnamed union}"/"{unnamed
enum}" tag for unnamed struct/union/enum's, which we don't
want to print. */
- if (TYPE_TAG_NAME (type) != NULL
- && !startswith (TYPE_TAG_NAME (type), "{unnamed"))
+ if (TYPE_NAME (type) != NULL
+ && !startswith (TYPE_NAME (type), "{unnamed"))
{
/* When printing the tag name, we are still effectively
printing in the outer context, hence the use of FLAGS
here. */
- print_name_maybe_canonical (TYPE_TAG_NAME (type), flags, stream);
+ print_name_maybe_canonical (TYPE_NAME (type), flags, stream);
if (show > 0)
fputs_filtered (" ", stream);
}
@@ -1189,10 +1189,10 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
{
/* If we just printed a tag name, no need to print anything
else. */
- if (TYPE_TAG_NAME (type) == NULL)
+ if (TYPE_NAME (type) == NULL)
fprintf_filtered (stream, "{...}");
}
- else if (show > 0 || TYPE_TAG_NAME (type) == NULL)
+ else if (show > 0 || TYPE_NAME (type) == NULL)
{
struct type *basetype;
int vptr_fieldno;
@@ -1602,15 +1602,31 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream,
/* When SHOW is zero or less, and there is a valid type name, then
always just print the type name directly from the type. */
- /* If we have "typedef struct foo {. . .} bar;" do we want to print
- it as "struct foo" or as "bar"? Pick the latter, because C++
- folk tend to expect things like "class5 *foo" rather than "struct
- class5 *foo". */
if (show <= 0
&& TYPE_NAME (type) != NULL)
{
c_type_print_modifier (type, stream, 0, 1);
+
+ /* If we have "typedef struct foo {. . .} bar;" do we want to
+ print it as "struct foo" or as "bar"? Pick the latter for
+ C++, because C++ folk tend to expect things like "class5
+ *foo" rather than "struct class5 *foo". */
+ if (language == language_c || language == language_minimal)
+ {
+ if (TYPE_CODE (type) == TYPE_CODE_UNION)
+ fprintf_filtered (stream, "union ");
+ else if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
+ {
+ if (TYPE_DECLARED_CLASS (type))
+ fprintf_filtered (stream, "class ");
+ else
+ fprintf_filtered (stream, "struct ");
+ }
+ else if (TYPE_CODE (type) == TYPE_CODE_ENUM)
+ fprintf_filtered (stream, "enum ");
+ }
+
print_name_maybe_canonical (TYPE_NAME (type), flags, stream);
return;
}
@@ -1661,10 +1677,10 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream,
"{unnamed struct}"/"{unnamed union}"/"{unnamed enum}"
tag for unnamed struct/union/enum's, which we don't
want to print. */
- if (TYPE_TAG_NAME (type) != NULL
- && !startswith (TYPE_TAG_NAME (type), "{unnamed"))
+ if (TYPE_NAME (type) != NULL
+ && !startswith (TYPE_NAME (type), "{unnamed"))
{
- print_name_maybe_canonical (TYPE_TAG_NAME (type), flags, stream);
+ print_name_maybe_canonical (TYPE_NAME (type), flags, stream);
if (show > 0)
fputs_filtered (" ", stream);
}
@@ -1674,10 +1690,10 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream,
{
/* If we just printed a tag name, no need to print anything
else. */
- if (TYPE_TAG_NAME (type) == NULL)
+ if (TYPE_NAME (type) == NULL)
fprintf_filtered (stream, "{...}");
}
- else if (show > 0 || TYPE_TAG_NAME (type) == NULL)
+ else if (show > 0 || TYPE_NAME (type) == NULL)
{
LONGEST lastval = 0;
@@ -1786,7 +1802,7 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream,
case TYPE_CODE_NAMESPACE:
fputs_filtered ("namespace ", stream);
- fputs_filtered (TYPE_TAG_NAME (type), stream);
+ fputs_filtered (TYPE_NAME (type), stream);
break;
default:
diff --git a/gdb/c-varobj.c b/gdb/c-varobj.c
index 03656c0a81..7f12989979 100644
--- a/gdb/c-varobj.c
+++ b/gdb/c-varobj.c
@@ -145,8 +145,7 @@ c_is_path_expr_parent (const struct varobj *var)
/* Anonymous unions and structs are also not path_expr parents. */
if ((TYPE_CODE (type) == TYPE_CODE_STRUCT
|| TYPE_CODE (type) == TYPE_CODE_UNION)
- && TYPE_NAME (type) == NULL
- && TYPE_TAG_NAME (type) == NULL)
+ && TYPE_NAME (type) == NULL)
{
const struct varobj *parent = var->parent;
diff --git a/gdb/coffread.c b/gdb/coffread.c
index cad3e7e2f1..e07a440443 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -1787,11 +1787,11 @@ process_coff_symbol (struct coff_symbol *cs,
/* Some compilers try to be helpful by inventing "fake"
names for anonymous enums, structures, and unions, like
"~0fake" or ".0fake". Thanks, but no thanks... */
- if (TYPE_TAG_NAME (SYMBOL_TYPE (sym)) == 0)
+ if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0)
if (SYMBOL_LINKAGE_NAME (sym) != NULL
&& *SYMBOL_LINKAGE_NAME (sym) != '~'
&& *SYMBOL_LINKAGE_NAME (sym) != '.')
- TYPE_TAG_NAME (SYMBOL_TYPE (sym)) =
+ TYPE_NAME (SYMBOL_TYPE (sym)) =
concat (SYMBOL_LINKAGE_NAME (sym), (char *)NULL);
add_symbol_to_list (sym, &file_symbols);
@@ -1957,10 +1957,6 @@ decode_base_type (struct coff_symbol *cs,
type = coff_alloc_type (cs->c_symnum);
TYPE_CODE (type) = TYPE_CODE_STRUCT;
TYPE_NAME (type) = NULL;
- /* This used to set the tag to "<opaque>". But I think
- setting it to NULL is right, and the printing code can
- print it as "struct {...}". */
- TYPE_TAG_NAME (type) = NULL;
INIT_CPLUS_SPECIFIC (type);
TYPE_LENGTH (type) = 0;
TYPE_FIELDS (type) = 0;
@@ -1981,10 +1977,6 @@ decode_base_type (struct coff_symbol *cs,
/* Anonymous union type. */
type = coff_alloc_type (cs->c_symnum);
TYPE_NAME (type) = NULL;
- /* This used to set the tag to "<opaque>". But I think
- setting it to NULL is right, and the printing code can
- print it as "union {...}". */
- TYPE_TAG_NAME (type) = NULL;
INIT_CPLUS_SPECIFIC (type);
TYPE_LENGTH (type) = 0;
TYPE_FIELDS (type) = 0;
@@ -2007,10 +1999,6 @@ decode_base_type (struct coff_symbol *cs,
type = coff_alloc_type (cs->c_symnum);
TYPE_CODE (type) = TYPE_CODE_ENUM;
TYPE_NAME (type) = NULL;
- /* This used to set the tag to "<opaque>". But I think
- setting it to NULL is right, and the printing code can
- print it as "enum {...}". */
- TYPE_TAG_NAME (type) = NULL;
TYPE_LENGTH (type) = 0;
TYPE_FIELDS (type) = 0;
TYPE_NFIELDS (type) = 0;
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index dde417be80..c16b67171f 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -199,7 +199,7 @@ inspect_type (struct demangle_parse_info *info,
&& strcmp (TYPE_NAME (type), name) == 0)
return 0;
- is_anon = (TYPE_TAG_NAME (type) == NULL
+ is_anon = (TYPE_NAME (type) == NULL
&& (TYPE_CODE (type) == TYPE_CODE_ENUM
|| TYPE_CODE (type) == TYPE_CODE_STRUCT
|| TYPE_CODE (type) == TYPE_CODE_UNION));
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 8dbe12db02..78c36887ee 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -9778,8 +9778,6 @@ fixup_go_packaging (struct dwarf2_cu *cu)
saved_package_name);
struct symbol *sym;
- TYPE_TAG_NAME (type) = TYPE_NAME (type);
-
sym = allocate_symbol (objfile);
SYMBOL_SET_LANGUAGE (sym, language_go, &objfile->objfile_obstack);
SYMBOL_SET_NAMES (sym, saved_package_name,
@@ -15621,18 +15619,13 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
if (get_die_type (die, cu) != NULL)
return get_die_type (die, cu);
- TYPE_TAG_NAME (type) = full_name;
- if (die->tag == DW_TAG_structure_type
- || die->tag == DW_TAG_class_type)
- TYPE_NAME (type) = TYPE_TAG_NAME (type);
+ TYPE_NAME (type) = full_name;
}
else
{
/* The name is already allocated along with this objfile, so
we don't need to duplicate it for the type. */
- TYPE_TAG_NAME (type) = name;
- if (die->tag == DW_TAG_class_type)
- TYPE_NAME (type) = TYPE_TAG_NAME (type);
+ TYPE_NAME (type) = name;
}
}
@@ -15913,7 +15906,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu)
complaint (&symfile_complaints,
_("virtual function table pointer "
"not found when defining class '%s'"),
- TYPE_TAG_NAME (type) ? TYPE_TAG_NAME (type) :
+ TYPE_NAME (type) ? TYPE_NAME (type) :
"");
}
else
@@ -16104,7 +16097,7 @@ read_enumeration_type (struct die_info *die, struct dwarf2_cu *cu)
TYPE_CODE (type) = TYPE_CODE_ENUM;
name = dwarf2_full_name (NULL, die, cu);
if (name != NULL)
- TYPE_TAG_NAME (type) = name;
+ TYPE_NAME (type) = name;
attr = dwarf2_attr (die, DW_AT_type, cu);
if (attr != NULL)
@@ -16649,7 +16642,6 @@ read_namespace_type (struct die_info *die, struct dwarf2_cu *cu)
/* Create the type. */
type = init_type (objfile, TYPE_CODE_NAMESPACE, 0, name);
- TYPE_TAG_NAME (type) = TYPE_NAME (type);
return set_die_type (die, type, cu);
}
@@ -16715,9 +16707,6 @@ read_module_type (struct die_info *die, struct dwarf2_cu *cu)
sect_offset_str (die->sect_off));
type = init_type (objfile, TYPE_CODE_MODULE, 0, module_name);
- /* determine_prefix uses TYPE_TAG_NAME. */
- TYPE_TAG_NAME (type) = TYPE_NAME (type);
-
return set_die_type (die, type, cu);
}
@@ -22155,18 +22144,18 @@ determine_prefix (struct die_info *die, struct dwarf2_cu *cu)
DW_TAG_namespace DIEs with a name of "::" for the global namespace.
Work around this problem here. */
if (cu->language == language_cplus
- && strcmp (TYPE_TAG_NAME (parent_type), "::") == 0)
+ && strcmp (TYPE_NAME (parent_type), "::") == 0)
return "";
/* We give a name to even anonymous namespaces. */
- return TYPE_TAG_NAME (parent_type);
+ return TYPE_NAME (parent_type);
case DW_TAG_class_type:
case DW_TAG_interface_type:
case DW_TAG_structure_type:
case DW_TAG_union_type:
case DW_TAG_module:
parent_type = read_type_die (parent, cu);
- if (TYPE_TAG_NAME (parent_type) != NULL)
- return TYPE_TAG_NAME (parent_type);
+ if (TYPE_NAME (parent_type) != NULL)
+ return TYPE_NAME (parent_type);
else
/* An anonymous structure is only allowed non-static data
members; no typedefs, no member functions, et cetera.
@@ -22191,8 +22180,8 @@ determine_prefix (struct die_info *die, struct dwarf2_cu *cu)
parent_type = read_type_die (parent, cu);
if (TYPE_DECLARED_CLASS (parent_type))
{
- if (TYPE_TAG_NAME (parent_type) != NULL)
- return TYPE_TAG_NAME (parent_type);
+ if (TYPE_NAME (parent_type) != NULL)
+ return TYPE_NAME (parent_type);
return "";
}
/* Fall through. */
diff --git a/gdb/eval.c b/gdb/eval.c
index b6fbfcf6c9..0bed4aa3fc 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -984,13 +984,13 @@ evaluate_funcall (type *expect_type, expression *exp, int *pos,
function_name = NULL;
if (TYPE_CODE (type) == TYPE_CODE_NAMESPACE)
{
- function = cp_lookup_symbol_namespace (TYPE_TAG_NAME (type),
+ function = cp_lookup_symbol_namespace (TYPE_NAME (type),
name,
get_selected_block (0),
VAR_DOMAIN).symbol;
if (function == NULL)
error (_("No symbol \"%s\" in namespace \"%s\"."),
- name, TYPE_TAG_NAME (type));
+ name, TYPE_NAME (type));
tem = 1;
/* arg2 is left as NULL on purpose. */
diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c
index f14f1811f4..3f13c111ac 100644
--- a/gdb/f-typeprint.c
+++ b/gdb/f-typeprint.c
@@ -290,7 +290,12 @@ f_type_print_base (struct type *type, struct ui_file *stream, int show,
if ((show <= 0) && (TYPE_NAME (type) != NULL))
{
- fprintfi_filtered (level, stream, "%s", TYPE_NAME (type));
+ const char *prefix = "";
+ if (TYPE_CODE (type) == TYPE_CODE_UNION)
+ prefix = "Type, C_Union :: ";
+ else if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
+ prefix = "Type ";
+ fprintfi_filtered (level, stream, "%s%s", prefix, TYPE_NAME (type));
return;
}
@@ -370,7 +375,7 @@ f_type_print_base (struct type *type, struct ui_file *stream, int show,
fprintfi_filtered (level, stream, "Type, C_Union :: ");
else
fprintfi_filtered (level, stream, "Type ");
- fputs_filtered (TYPE_TAG_NAME (type), stream);
+ fputs_filtered (TYPE_NAME (type), stream);
/* According to the definition,
we only print structure elements in case show > 0. */
if (show > 0)
@@ -387,12 +392,12 @@ f_type_print_base (struct type *type, struct ui_file *stream, int show,
fputs_filtered ("\n", stream);
}
fprintfi_filtered (level, stream, "End Type ");
- fputs_filtered (TYPE_TAG_NAME (type), stream);
+ fputs_filtered (TYPE_NAME (type), stream);
}
break;
case TYPE_CODE_MODULE:
- fprintfi_filtered (level, stream, "module %s", TYPE_TAG_NAME (type));
+ fprintfi_filtered (level, stream, "module %s", TYPE_NAME (type));
break;
default_case:
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index b3a037971e..b3a388656e 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1469,12 +1469,6 @@ smash_to_method_type (struct type *type, struct type *self_type,
const char *
type_name_no_tag (const struct type *type)
{
- if (TYPE_TAG_NAME (type) != NULL)
- return TYPE_TAG_NAME (type);
-
- /* Is there code which expects this to return the name if there is
- no tag name? My guess is that this is mainly used for C++ in
- cases where the two will always be the same. */
return TYPE_NAME (type);
}
@@ -2445,10 +2439,8 @@ check_typedef (struct type *type)
return make_qualified_type (type, instance_flags, NULL);
name = type_name_no_tag (type);
- /* FIXME: shouldn't we separately check the TYPE_NAME and
- the TYPE_TAG_NAME, and look in STRUCT_DOMAIN and/or
- VAR_DOMAIN as appropriate? (this code was written before
- TYPE_NAME and TYPE_TAG_NAME were separate). */
+ /* FIXME: shouldn't we look in STRUCT_DOMAIN and/or
+ VAR_DOMAIN as appropriate? */
if (name == NULL)
{
stub_noname_complaint ();
@@ -2534,10 +2526,8 @@ check_typedef (struct type *type)
else if (TYPE_STUB (type) && !currently_reading_symtab)
{
const char *name = type_name_no_tag (type);
- /* FIXME: shouldn't we separately check the TYPE_NAME and the
- TYPE_TAG_NAME, and look in STRUCT_DOMAIN and/or VAR_DOMAIN
- as appropriate? (this code was written before TYPE_NAME and
- TYPE_TAG_NAME were separate). */
+ /* FIXME: shouldn't we look in STRUCT_DOMAIN and/or VAR_DOMAIN
+ as appropriate? */
struct symbol *sym;
if (name == NULL)
@@ -3547,9 +3537,6 @@ check_types_equal (struct type *type1, struct type *type2,
|| TYPE_NFIELDS (type1) != TYPE_NFIELDS (type2))
return 0;
- if (!compare_maybe_null_strings (TYPE_TAG_NAME (type1),
- TYPE_TAG_NAME (type2)))
- return 0;
if (!compare_maybe_null_strings (TYPE_NAME (type1), TYPE_NAME (type2)))
return 0;
@@ -4419,10 +4406,6 @@ recursive_dump_type (struct type *type, int spaces)
TYPE_NAME (type) ? TYPE_NAME (type) : "<NULL>");
gdb_print_host_address (TYPE_NAME (type), gdb_stdout);
printf_filtered (")\n");
- printfi_filtered (spaces, "tagname '%s' (",
- TYPE_TAG_NAME (type) ? TYPE_TAG_NAME (type) : "<NULL>");
- gdb_print_host_address (TYPE_TAG_NAME (type), gdb_stdout);
- printf_filtered (")\n");
printfi_filtered (spaces, "code 0x%x ", TYPE_CODE (type));
switch (TYPE_CODE (type))
{
@@ -4806,8 +4789,6 @@ copy_type_recursive (struct objfile *objfile,
if (TYPE_NAME (type))
TYPE_NAME (new_type) = xstrdup (TYPE_NAME (type));
- if (TYPE_TAG_NAME (type))
- TYPE_TAG_NAME (new_type) = xstrdup (TYPE_TAG_NAME (type));
TYPE_INSTANCE_FLAGS (new_type) = TYPE_INSTANCE_FLAGS (type);
TYPE_LENGTH (new_type) = TYPE_LENGTH (type);
@@ -5145,7 +5126,7 @@ arch_composite_type (struct gdbarch *gdbarch, const char *name,
gdb_assert (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION);
t = arch_type (gdbarch, code, 0, NULL);
- TYPE_TAG_NAME (t) = name;
+ TYPE_NAME (t) = name;
INIT_CPLUS_SPECIFIC (t);
return t;
}
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 552a2a2a16..70dac75855 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -721,26 +721,12 @@ struct main_type
/* * Name of this type, or NULL if none.
- This is used for printing only, except by poorly designed C++
- code. For looking up a name, look for a symbol in the
- VAR_DOMAIN. This is generally allocated in the objfile's
- obstack. However coffread.c uses malloc. */
+ This is used for printing only. For looking up a name, look for
+ a symbol in the VAR_DOMAIN. This is generally allocated in the
+ objfile's obstack. However coffread.c uses malloc. */
const char *name;
- /* * Tag name for this type, or NULL if none. This means that the
- name of the type consists of a keyword followed by the tag name.
- Which keyword is determined by the type code ("struct" for
- TYPE_CODE_STRUCT, etc.). As far as I know C/C++ are the only
- languages with this feature.
-
- This is used for printing only, except by poorly designed C++ code.
- For looking up a name, look for a symbol in the STRUCT_DOMAIN.
- One more legitimate use is that if TYPE_STUB is set, this is
- the name to use to look for definitions in other files. */
-
- const char *tag_name;
-
/* * Every type is now associated with a particular objfile, and the
type is allocated on the objfile_obstack for that objfile. One
problem however, is that there are times when gdb allocates new
@@ -1281,7 +1267,6 @@ extern void allocate_gnat_aux_type (struct type *);
#define TYPE_INSTANCE_FLAGS(thistype) (thistype)->instance_flags
#define TYPE_MAIN_TYPE(thistype) (thistype)->main_type
#define TYPE_NAME(thistype) TYPE_MAIN_TYPE(thistype)->name
-#define TYPE_TAG_NAME(type) TYPE_MAIN_TYPE(type)->tag_name
#define TYPE_TARGET_TYPE(thistype) TYPE_MAIN_TYPE(thistype)->target_type
#define TYPE_POINTER_TYPE(thistype) (thistype)->pointer_type
#define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type
diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
index 859187f2e9..781acaa409 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -164,7 +164,7 @@ build_gdb_vtable_type (struct gdbarch *arch)
t = arch_type (arch, TYPE_CODE_STRUCT, offset * TARGET_CHAR_BIT, NULL);
TYPE_NFIELDS (t) = field - field_list;
TYPE_FIELDS (t) = field_list;
- TYPE_TAG_NAME (t) = "gdb_gnu_v3_abi_vtable";
+ TYPE_NAME (t) = "gdb_gnu_v3_abi_vtable";
INIT_CPLUS_SPECIFIC (t);
return make_type_with_address_space (t, TYPE_INSTANCE_FLAG_CODE_SPACE);
@@ -1028,7 +1028,7 @@ build_std_type_info_type (struct gdbarch *arch)
t = arch_type (arch, TYPE_CODE_STRUCT, offset * TARGET_CHAR_BIT, NULL);
TYPE_NFIELDS (t) = field - field_list;
TYPE_FIELDS (t) = field_list;
- TYPE_TAG_NAME (t) = "gdb_gnu_v3_type_info";
+ TYPE_NAME (t) = "gdb_gnu_v3_type_info";
INIT_CPLUS_SPECIFIC (t);
return t;
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index e9cba7713c..60ab2f3dc3 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -106,8 +106,8 @@ static int
sixg_string_p (struct type *type)
{
if (TYPE_NFIELDS (type) == 2
- && TYPE_TAG_NAME (type) != NULL
- && strcmp (TYPE_TAG_NAME (type), "string") == 0)
+ && TYPE_NAME (type) != NULL
+ && strcmp (TYPE_NAME (type), "string") == 0)
return 1;
return 0;
diff --git a/gdb/guile/scm-type.c b/gdb/guile/scm-type.c
index ce67695b76..949e0dca82 100644
--- a/gdb/guile/scm-type.c
+++ b/gdb/guile/scm-type.c
@@ -576,10 +576,16 @@ gdbscm_type_tag (SCM self)
type_smob *t_smob
= tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
struct type *type = t_smob->type;
+ const char *tagname = nullptr;
- if (!TYPE_TAG_NAME (type))
+ if (TYPE_CODE (type) == TYPE_CODE_STRUCT
+ || TYPE_CODE (type) == TYPE_CODE_UNION
+ || TYPE_CODE (type) == TYPE_CODE_ENUM)
+ tagname = TYPE_NAME (type);
+
+ if (tagname == nullptr)
return SCM_BOOL_F;
- return gdbscm_scm_from_c_string (TYPE_TAG_NAME (type));
+ return gdbscm_scm_from_c_string (tagname);
}
/* (type-name <gdb:type>) -> string
diff --git a/gdb/m2-typeprint.c b/gdb/m2-typeprint.c
index 27e9429211..7279ab5b54 100644
--- a/gdb/m2-typeprint.c
+++ b/gdb/m2-typeprint.c
@@ -439,22 +439,14 @@ m2_long_set (struct type *type, struct ui_file *stream, int show, int level,
if (m2_is_long_set (type))
{
- if (TYPE_TAG_NAME (type) != NULL)
- {
- fputs_filtered (TYPE_TAG_NAME (type), stream);
- if (show == 0)
- return 1;
- }
- else if (TYPE_NAME (type) != NULL)
+ if (TYPE_NAME (type) != NULL)
{
fputs_filtered (TYPE_NAME (type), stream);
if (show == 0)
return 1;
+ fputs_filtered (" = ", stream);
}
- if (TYPE_TAG_NAME (type) != NULL || TYPE_NAME (type) != NULL)
- fputs_filtered (" = ", stream);
-
if (get_long_set_bounds (type, &low, &high))
{
fprintf_filtered(stream, "SET OF ");
@@ -537,11 +529,11 @@ m2_record_fields (struct type *type, struct ui_file *stream, int show,
int level, const struct type_print_options *flags)
{
/* Print the tag if it exists. */
- if (TYPE_TAG_NAME (type) != NULL)
+ if (TYPE_NAME (type) != NULL)
{
- if (!startswith (TYPE_TAG_NAME (type), "$$"))
+ if (!startswith (TYPE_NAME (type), "$$"))
{
- fputs_filtered (TYPE_TAG_NAME (type), stream);
+ fputs_filtered (TYPE_NAME (type), stream);
if (show > 0)
fprintf_filtered (stream, " = ");
}
@@ -601,10 +593,10 @@ m2_enum (struct type *type, struct ui_file *stream, int show, int level)
if (show < 0)
{
/* If we just printed a tag name, no need to print anything else. */
- if (TYPE_TAG_NAME (type) == NULL)
+ if (TYPE_NAME (type) == NULL)
fprintf_filtered (stream, "(...)");
}
- else if (show > 0 || TYPE_TAG_NAME (type) == NULL)
+ else if (show > 0 || TYPE_NAME (type) == NULL)
{
fprintf_filtered (stream, "(");
len = TYPE_NFIELDS (type);
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index c0bce55148..a760fd9692 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -1031,10 +1031,10 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
(.Fxx or .xxfake or empty) for unnamed struct/union/enums.
Alpha cc puts out an sh->iss of zero for those. */
if (sh->iss == 0 || name[0] == '.' || name[0] == '\0')
- TYPE_TAG_NAME (t) = NULL;
+ TYPE_NAME (t) = NULL;
else
- TYPE_TAG_NAME (t) = obconcat (&mdebugread_objfile->objfile_obstack,
- name, (char *) NULL);
+ TYPE_NAME (t) = obconcat (&mdebugread_objfile->objfile_obstack,
+ name, (char *) NULL);
TYPE_CODE (t) = type_code;
TYPE_LENGTH (t) = sh->value;
@@ -1699,10 +1699,10 @@ parse_type (int fd, union aux_ext *ax, unsigned int aux_index, int *bs,
/* Do not set the tag name if it is a compiler generated tag name
(.Fxx or .xxfake or empty) for unnamed struct/union/enums. */
if (name[0] == '.' || name[0] == '\0')
- TYPE_TAG_NAME (tp) = NULL;
- else if (TYPE_TAG_NAME (tp) == NULL
- || strcmp (TYPE_TAG_NAME (tp), name) != 0)
- TYPE_TAG_NAME (tp)
+ TYPE_NAME (tp) = NULL;
+ else if (TYPE_NAME (tp) == NULL
+ || strcmp (TYPE_NAME (tp), name) != 0)
+ TYPE_NAME (tp)
= ((const char *)
obstack_copy0 (&mdebugread_objfile->objfile_obstack,
name, strlen (name)));
diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c
index e35e0fbd80..f82a2bc981 100644
--- a/gdb/p-typeprint.c
+++ b/gdb/p-typeprint.c
@@ -522,9 +522,9 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show,
only after args !! */
break;
case TYPE_CODE_STRUCT:
- if (TYPE_TAG_NAME (type) != NULL)
+ if (TYPE_NAME (type) != NULL)
{
- fputs_filtered (TYPE_TAG_NAME (type), stream);
+ fputs_filtered (TYPE_NAME (type), stream);
fputs_filtered (" = ", stream);
}
if (HAVE_CPLUS_STRUCT (type))
@@ -538,9 +538,9 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show,
goto struct_union;
case TYPE_CODE_UNION:
- if (TYPE_TAG_NAME (type) != NULL)
+ if (TYPE_NAME (type) != NULL)
{
- fputs_filtered (TYPE_TAG_NAME (type), stream);
+ fputs_filtered (TYPE_NAME (type), stream);
fputs_filtered (" = ", stream);
}
fprintf_filtered (stream, "case <?> of ");
@@ -550,10 +550,10 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show,
if (show < 0)
{
/* If we just printed a tag name, no need to print anything else. */
- if (TYPE_TAG_NAME (type) == NULL)
+ if (TYPE_NAME (type) == NULL)
fprintf_filtered (stream, "{...}");
}
- else if (show > 0 || TYPE_TAG_NAME (type) == NULL)
+ else if (show > 0 || TYPE_NAME (type) == NULL)
{
pascal_type_print_derivation_info (stream, type);
@@ -740,9 +740,9 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show,
break;
case TYPE_CODE_ENUM:
- if (TYPE_TAG_NAME (type) != NULL)
+ if (TYPE_NAME (type) != NULL)
{
- fputs_filtered (TYPE_TAG_NAME (type), stream);
+ fputs_filtered (TYPE_NAME (type), stream);
if (show > 0)
fputs_filtered (" ", stream);
}
@@ -753,10 +753,10 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show,
if (show < 0)
{
/* If we just printed a tag name, no need to print anything else. */
- if (TYPE_TAG_NAME (type) == NULL)
+ if (TYPE_NAME (type) == NULL)
fprintf_filtered (stream, "(...)");
}
- else if (show > 0 || TYPE_TAG_NAME (type) == NULL)
+ else if (show > 0 || TYPE_NAME (type) == NULL)
{
fprintf_filtered (stream, "(");
len = TYPE_NFIELDS (type);
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index 8a948eeaa6..6cbb1b663d 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -416,10 +416,16 @@ static PyObject *
typy_get_tag (PyObject *self, void *closure)
{
struct type *type = ((type_object *) self)->type;
+ const char *tagname = nullptr;
- if (!TYPE_TAG_NAME (type))
+ if (TYPE_CODE (type) == TYPE_CODE_STRUCT
+ || TYPE_CODE (type) == TYPE_CODE_UNION
+ || TYPE_CODE (type) == TYPE_CODE_ENUM)
+ tagname = TYPE_NAME (type);
+
+ if (tagname == nullptr)
Py_RETURN_NONE;
- return PyString_FromString (TYPE_TAG_NAME (type));
+ return PyString_FromString (tagname);
}
/* Return the type, stripped of typedefs. */
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index cf8a15ee43..aa02ede52f 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -95,8 +95,8 @@ rust_tuple_type_p (struct type *type)
nothing else in the debuginfo to distinguish a tuple from a
struct. */
return (TYPE_CODE (type) == TYPE_CODE_STRUCT
- && TYPE_TAG_NAME (type) != NULL
- && TYPE_TAG_NAME (type)[0] == '(');
+ && TYPE_NAME (type) != NULL
+ && TYPE_NAME (type)[0] == '(');
}
/* Return true if all non-static fields of a structlike type are in a
@@ -143,9 +143,9 @@ static bool
rust_slice_type_p (struct type *type)
{
return (TYPE_CODE (type) == TYPE_CODE_STRUCT
- && TYPE_TAG_NAME (type) != NULL
- && (strncmp (TYPE_TAG_NAME (type), "&[", 2) == 0
- || strcmp (TYPE_TAG_NAME (type), "&str") == 0));
+ && TYPE_NAME (type) != NULL
+ && (strncmp (TYPE_NAME (type), "&[", 2) == 0
+ || strcmp (TYPE_NAME (type), "&str") == 0));
}
/* Return true if TYPE is a range type, otherwise false. */
@@ -157,8 +157,8 @@ rust_range_type_p (struct type *type)
if (TYPE_CODE (type) != TYPE_CODE_STRUCT
|| TYPE_NFIELDS (type) > 2
- || TYPE_TAG_NAME (type) == NULL
- || strstr (TYPE_TAG_NAME (type), "::Range") == NULL)
+ || TYPE_NAME (type) == NULL
+ || strstr (TYPE_NAME (type), "::Range") == NULL)
return false;
if (TYPE_NFIELDS (type) == 0)
@@ -342,13 +342,13 @@ val_print_struct (struct type *type, int embedded_offset,
if (!is_tuple)
{
- if (TYPE_TAG_NAME (type) != NULL)
- fprintf_filtered (stream, "%s", TYPE_TAG_NAME (type));
+ if (TYPE_NAME (type) != NULL)
+ fprintf_filtered (stream, "%s", TYPE_NAME (type));
if (TYPE_NFIELDS (type) == 0)
return;
- if (TYPE_TAG_NAME (type) != NULL)
+ if (TYPE_NAME (type) != NULL)
fputs_filtered (" ", stream);
}
@@ -617,7 +617,7 @@ rust_print_struct_def (struct type *type, const char *varstring,
/* Print a tuple type simply. */
if (rust_tuple_type_p (type))
{
- fputs_filtered (TYPE_TAG_NAME (type), stream);
+ fputs_filtered (TYPE_NAME (type), stream);
return;
}
@@ -627,7 +627,7 @@ rust_print_struct_def (struct type *type, const char *varstring,
/* Compute properties of TYPE here because, in the enum case, the
rest of the code ends up looking only at the variant part. */
- const char *tagname = TYPE_TAG_NAME (type);
+ const char *tagname = TYPE_NAME (type);
bool is_tuple_struct = rust_tuple_struct_type_p (type);
bool is_tuple = rust_tuple_type_p (type);
bool is_enum = rust_enum_p (type);
@@ -808,11 +808,11 @@ rust_internal_print_type (struct type *type, const char *varstring,
int i, len = 0;
fputs_filtered ("enum ", stream);
- if (TYPE_TAG_NAME (type) != NULL)
+ if (TYPE_NAME (type) != NULL)
{
- fputs_filtered (TYPE_TAG_NAME (type), stream);
+ fputs_filtered (TYPE_NAME (type), stream);
fputs_filtered (" ", stream);
- len = strlen (TYPE_TAG_NAME (type));
+ len = strlen (TYPE_NAME (type));
}
fputs_filtered ("{\n", stream);
@@ -823,7 +823,7 @@ rust_internal_print_type (struct type *type, const char *varstring,
QUIT;
if (len > 0
- && strncmp (name, TYPE_TAG_NAME (type), len) == 0
+ && strncmp (name, TYPE_NAME (type), len) == 0
&& name[len] == ':'
&& name[len + 1] == ':')
name += len + 2;
@@ -912,7 +912,6 @@ rust_composite_type (struct type *original,
TYPE_CODE (result) = TYPE_CODE_STRUCT;
TYPE_NAME (result) = name;
- TYPE_TAG_NAME (result) = name;
TYPE_NFIELDS (result) = nfields;
TYPE_FIELDS (result)
@@ -1090,10 +1089,10 @@ rust_evaluate_funcall (struct expression *exp, int *pos, enum noside noside)
&& TYPE_CODE (type) != TYPE_CODE_ENUM)
|| rust_tuple_type_p (type))
error (_("Method calls only supported on struct or enum types"));
- if (TYPE_TAG_NAME (type) == NULL)
+ if (TYPE_NAME (type) == NULL)
error (_("Method call on nameless type"));
- std::string name = std::string (TYPE_TAG_NAME (type)) + "::" + method;
+ std::string name = std::string (TYPE_NAME (type)) + "::" + method;
block = get_selected_block (0);
sym = lookup_symbol (name.c_str (), block, VAR_DOMAIN, NULL);
@@ -1606,13 +1605,13 @@ rust_evaluate_subexp (struct type *expect_type, struct expression *exp,
if (outer_type != NULL)
error(_("Cannot access field %d of variant %s::%s, "
"there are only %d fields"),
- field_number, TYPE_TAG_NAME (outer_type),
- rust_last_path_segment (TYPE_TAG_NAME (type)),
+ field_number, TYPE_NAME (outer_type),
+ rust_last_path_segment (TYPE_NAME (type)),
nfields);
else
error(_("Cannot access field %d of %s, "
"there are only %d fields"),
- field_number, TYPE_TAG_NAME (type), nfields);
+ field_number, TYPE_NAME (type), nfields);
}
/* Tuples are tuple structs too. */
@@ -1620,13 +1619,13 @@ rust_evaluate_subexp (struct type *expect_type, struct expression *exp,
{
if (outer_type != NULL)
error(_("Variant %s::%s is not a tuple variant"),
- TYPE_TAG_NAME (outer_type),
- rust_last_path_segment (TYPE_TAG_NAME (type)));
+ TYPE_NAME (outer_type),
+ rust_last_path_segment (TYPE_NAME (type)));
else
error(_("Attempting to access anonymous field %d "
"of %s, which is not a tuple, tuple struct, or "
"tuple-like variant"),
- field_number, TYPE_TAG_NAME (type));
+ field_number, TYPE_NAME (type));
}
result = value_primitive_field (lhs, 0, field_number, type);
@@ -1668,7 +1667,7 @@ tuple structs, and tuple-like enum variants"));
if (rust_tuple_type_p (type) || rust_tuple_struct_type_p (type))
error (_("Attempting to access named field foo of tuple "
"variant %s::%s, which has only anonymous fields"),
- TYPE_TAG_NAME (outer_type),
+ TYPE_NAME (outer_type),
rust_last_path_segment (TYPE_NAME (type)));
TRY
@@ -1679,7 +1678,7 @@ tuple structs, and tuple-like enum variants"));
CATCH (except, RETURN_MASK_ERROR)
{
error (_("Could not find field %s of struct variant %s::%s"),
- field_name, TYPE_TAG_NAME (outer_type),
+ field_name, TYPE_NAME (outer_type),
rust_last_path_segment (TYPE_NAME (type)));
}
END_CATCH
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 0017f18c35..420cdd2742 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -1344,8 +1344,8 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF;
SYMBOL_VALUE (sym) = valu;
SYMBOL_DOMAIN (sym) = STRUCT_DOMAIN;
- if (TYPE_TAG_NAME (SYMBOL_TYPE (sym)) == 0)
- TYPE_TAG_NAME (SYMBOL_TYPE (sym))
+ if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0)
+ TYPE_NAME (SYMBOL_TYPE (sym))
= obconcat (&objfile->objfile_obstack,
SYMBOL_LINKAGE_NAME (sym),
(char *) NULL);
@@ -1702,7 +1702,7 @@ again:
type. */
type = dbx_alloc_type (typenums, objfile);
TYPE_CODE (type) = code;
- TYPE_TAG_NAME (type) = type_name;
+ TYPE_NAME (type) = type_name;
INIT_CPLUS_SPECIFIC (type);
TYPE_STUB (type) = 1;
@@ -1767,7 +1767,6 @@ again:
copies of a type otherwise. */
replace_type (type, xtype);
TYPE_NAME (type) = NULL;
- TYPE_TAG_NAME (type) = NULL;
}
else
{
@@ -3428,9 +3427,9 @@ complain_about_struct_wipeout (struct type *type)
const char *name = "";
const char *kind = "";
- if (TYPE_TAG_NAME (type))
+ if (TYPE_NAME (type))
{
- name = TYPE_TAG_NAME (type);
+ name = TYPE_NAME (type);
switch (TYPE_CODE (type))
{
case TYPE_CODE_STRUCT: kind = "struct "; break;
@@ -3439,11 +3438,6 @@ complain_about_struct_wipeout (struct type *type)
default: kind = "";
}
}
- else if (TYPE_NAME (type))
- {
- name = TYPE_NAME (type);
- kind = "";
- }
else
{
name = "<unknown>";
@@ -4476,7 +4470,7 @@ add_undefined_type_1 (struct type *type)
static void
add_undefined_type (struct type *type, int typenums[2])
{
- if (TYPE_TAG_NAME (type) == NULL)
+ if (TYPE_NAME (type) == NULL)
add_undefined_type_noname (type, typenums);
else
add_undefined_type_1 (type);
@@ -4561,7 +4555,7 @@ cleanup_undefined_types_1 (void)
struct pending *ppt;
int i;
/* Name of the type, without "struct" or "union". */
- const char *type_name = TYPE_TAG_NAME (*type);
+ const char *type_name = TYPE_NAME (*type);
if (type_name == NULL)
{
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 9adde044cd..4d56a3e952 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -540,7 +540,7 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol,
if (SYMBOL_DOMAIN (symbol) == STRUCT_DOMAIN)
{
- if (TYPE_TAG_NAME (SYMBOL_TYPE (symbol)))
+ if (TYPE_NAME (SYMBOL_TYPE (symbol)))
{
LA_PRINT_TYPE (SYMBOL_TYPE (symbol), "", outfile, 1, depth,
&type_print_raw_options);
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 5d34e29a86..ddec6ee5d6 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -428,7 +428,6 @@ make_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *ttype)
{
m_type = arch_composite_type (m_gdbarch, NULL, TYPE_CODE_STRUCT);
TYPE_NAME (m_type) = xstrdup (e->name.c_str ());
- TYPE_TAG_NAME (m_type) = TYPE_NAME (m_type);
for (const tdesc_type_field &f : e->fields)
{
diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp
index 9322108565..4ec80812a9 100644
--- a/gdb/testsuite/gdb.base/maint.exp
+++ b/gdb/testsuite/gdb.base/maint.exp
@@ -345,7 +345,7 @@ foreach { test_name command } $test_list {
set msg "maint print type"
gdb_test_multiple "maint print type argc" $msg {
- -re "type node $hex\r\nname .int. \\($hex\\)\r\ntagname .<NULL>. \\($hex\\)\r\ncode $hex \\(TYPE_CODE_INT\\)\r\nlength \[24\]\r\nobjfile $hex\r\ntarget_type $hex\r\npointer_type $hex\r\nreference_type $hex\r\ntype_chain $hex\r\ninstance_flags $hex\r\nflags\r\nnfields 0 $hex\r\n$gdb_prompt $" {
+ -re "type node $hex\r\nname .int. \\($hex\\)\r\ncode $hex \\(TYPE_CODE_INT\\)\r\nlength \[24\]\r\nobjfile $hex\r\ntarget_type $hex\r\npointer_type $hex\r\nreference_type $hex\r\ntype_chain $hex\r\ninstance_flags $hex\r\nflags\r\nnfields 0 $hex\r\n$gdb_prompt $" {
pass $msg
}
}
diff --git a/gdb/testsuite/gdb.cp/typeid.exp b/gdb/testsuite/gdb.cp/typeid.exp
index 4378dcbb59..1731b78b9d 100644
--- a/gdb/testsuite/gdb.cp/typeid.exp
+++ b/gdb/testsuite/gdb.cp/typeid.exp
@@ -27,7 +27,7 @@ proc do_typeid_tests {started} {
global hex
# We might see the standard type or gdb's internal type.
- set type_re "(std::type_info|struct gdb_gnu_v3_type_info)"
+ set type_re "(std::type_info|gdb_gnu_v3_type_info)"
foreach simple_var {i cp ccp ca b} {
diff --git a/gdb/testsuite/gdb.dwarf2/member-ptr-forwardref.exp b/gdb/testsuite/gdb.dwarf2/member-ptr-forwardref.exp
index 41eff9237c..31707bbd0c 100644
--- a/gdb/testsuite/gdb.dwarf2/member-ptr-forwardref.exp
+++ b/gdb/testsuite/gdb.dwarf2/member-ptr-forwardref.exp
@@ -38,4 +38,5 @@ gdb_test "show cp-abi" {The currently selected C\+\+ ABI is "gnu-v3".*}
gdb_load ${binfile}
+gdb_test_no_output "set language c++"
gdb_test "ptype c" "type = struct C {\[\r\n \t\]*private:\[\r\n \t\]*int \\(C::\\*fp\\)\\(C \\*( const)?\\);\[\r\n \t\]*}"
diff --git a/gdb/testsuite/gdb.dwarf2/method-ptr.exp b/gdb/testsuite/gdb.dwarf2/method-ptr.exp
index 5a4f05350e..7fe755cb7d 100644
--- a/gdb/testsuite/gdb.dwarf2/method-ptr.exp
+++ b/gdb/testsuite/gdb.dwarf2/method-ptr.exp
@@ -82,5 +82,6 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \
return -1
}
+gdb_test_no_output "set language c++"
gdb_test "ptype the_typedef" \
"type = int \\(S::\\*\\)\\(S \\* const, float\\)"
diff --git a/gdb/testsuite/gdb.xml/tdesc-regs.exp b/gdb/testsuite/gdb.xml/tdesc-regs.exp
index bb7b9be16c..94d4007a89 100644
--- a/gdb/testsuite/gdb.xml/tdesc-regs.exp
+++ b/gdb/testsuite/gdb.xml/tdesc-regs.exp
@@ -179,7 +179,7 @@ gdb_test "ptype \$extrareg" "type = (int|long|long long)"
gdb_test "ptype \$uintreg" "type = uint32_t"
gdb_test "ptype \$vecreg" "type = int8_t __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
gdb_test "ptype \$unionreg" \
- "type = union {\r\n *v4int8 v4;\r\n *v2int16 v2;\r\n}"
+ "type = union vecint {\r\n *v4int8 v4;\r\n *v2int16 v2;\r\n}"
gdb_test "ptype \$unionreg.v4" "type = int8_t __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
gdb_test "ptype \$structreg" \
"type = struct struct1 {\r\n *v4int8 v4;\r\n *v2int16 v2;\r\n}"
@@ -189,7 +189,7 @@ gdb_test "ptype \$bitfields" \
gdb_test "ptype \$flags" \
"type = flag flags {\r\n *bool X @0;\r\n *uint32_t Y @2;\r\n}"
gdb_test "ptype \$mixed_flags" \
- "type = flag mixed_flags {\r\n *bool A @0;\r\n *uint32_t B @1-3;\r\n *bool C @4;\r\n *uint32_t D @5;\r\n *uint32_t @6-7;\r\n *enum {yes = 1, no = 0, maybe = 2, so} Z @8-9;\r\n}"
+ "type = flag mixed_flags {\r\n *bool A @0;\r\n *uint32_t B @1-3;\r\n *bool C @4;\r\n *uint32_t D @5;\r\n *uint32_t @6-7;\r\n *enum Z_values {yes = 1, no = 0, maybe = 2, so} Z @8-9;\r\n}"
# Reggroups should have at least general and the extra foo group
gdb_test "maintenance print reggroups" \
" Group\[ \t\]+Type\[ \t\]+\r\n.* general\[ \t\]+user\[ \t\]+\r\n.* foo\[ \t\]+user\[ \t\]+"
diff --git a/gdb/valarith.c b/gdb/valarith.c
index 58e3a09c37..d2dd590064 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -61,8 +61,6 @@ find_size_for_pointer_math (struct type *ptr_type)
name = TYPE_NAME (ptr_target);
if (name == NULL)
- name = TYPE_TAG_NAME (ptr_target);
- if (name == NULL)
error (_("Cannot perform pointer math on incomplete types, "
"try casting to a known type, or void *."));
else
diff --git a/gdb/valops.c b/gdb/valops.c
index 1f655b5187..cb51a2688e 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -3243,7 +3243,7 @@ enum_constant_from_type (struct type *type, const char *name)
}
error (_("no constant named \"%s\" in enum \"%s\""),
- name, TYPE_TAG_NAME (type));
+ name, TYPE_NAME (type));
}
/* C++: Given an aggregate type CURTYPE, and a member name NAME,
@@ -3581,7 +3581,7 @@ value_namespace_elt (const struct type *curtype,
if (retval == NULL)
error (_("No symbol \"%s\" in namespace \"%s\"."),
- name, TYPE_TAG_NAME (curtype));
+ name, TYPE_NAME (curtype));
return retval;
}
@@ -3597,7 +3597,7 @@ value_maybe_namespace_elt (const struct type *curtype,
const char *name, int want_address,
enum noside noside)
{
- const char *namespace_name = TYPE_TAG_NAME (curtype);
+ const char *namespace_name = TYPE_NAME (curtype);
struct block_symbol sym;
struct value *result;
--
2.13.6
^ permalink raw reply [flat|nested] 16+ messages in thread
* [RFA 2/4] Thread language through c_type_print_args
2018-04-17 19:51 [RFA 0/4] Remove TYPE_TAG_NAME Tom Tromey
` (2 preceding siblings ...)
2018-04-17 19:51 ` [RFA 4/4] Remove type_name_no_tag and rename type_name_no_tag_or_error Tom Tromey
@ 2018-04-17 19:51 ` Tom Tromey
2018-04-18 17:53 ` Tom Tromey
2018-05-31 1:37 ` Joel Brobecker
2018-04-18 16:57 ` [RFA 0/4] Remove TYPE_TAG_NAME Keith Seitz
2018-05-09 15:42 ` Tom Tromey
5 siblings, 2 replies; 16+ messages in thread
From: Tom Tromey @ 2018-04-17 19:51 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
Currently dwarf2read.c will pass the CU's language to
c_type_print_args -- but this doesn't affect all aspects of type
printing, because some code in c-typeprint.c refers to
current_language.
This patch threads the language through more of the type printing
code, adding an overload to c_type_print. Some uses of
current_language remain, but now they are only in top-level functions.
ChangeLog
2018-04-17 Tom Tromey <tom@tromey.com>
* dwarf2read.c (dwarf2_compute_name): Pass CU's language to
c_print_type.
* c-typeprint.c (c_print_type_1): Add "language" parameter.
(c_print_type): Update.
(c_print_type): New overload.
(c_type_print_varspec_prefix, c_type_print_args)
(c_type_print_varspec_suffix, c_print_type_no_offsets)
(c_type_print_base_struct_union, c_type_print_base_1)
(cp_type_print_method_args): Add "language" parameter.
(c_type_print_base): Update.
* c-lang.h (c_print_type): Add new overload.
---
gdb/ChangeLog | 14 +++++++
gdb/c-lang.h | 7 ++++
gdb/c-typeprint.c | 114 +++++++++++++++++++++++++++++++++++-------------------
gdb/dwarf2read.c | 3 +-
4 files changed, 98 insertions(+), 40 deletions(-)
diff --git a/gdb/c-lang.h b/gdb/c-lang.h
index 18dedcc1fa..a250fb34a6 100644
--- a/gdb/c-lang.h
+++ b/gdb/c-lang.h
@@ -72,6 +72,13 @@ extern void c_print_type (struct type *, const char *,
struct ui_file *, int, int,
const struct type_print_options *);
+/* Print a type but allow the precise language to be specified. */
+
+extern void c_print_type (struct type *, const char *,
+ struct ui_file *, int, int,
+ enum language,
+ const struct type_print_options *);
+
extern void c_print_typedef (struct type *,
struct symbol *,
struct ui_file *);
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index e26687ba25..a53331aefc 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -52,11 +52,13 @@ enum access_specifier
static void c_type_print_varspec_suffix (struct type *, struct ui_file *, int,
int, int,
+ enum language,
const struct type_print_options *);
static void c_type_print_varspec_prefix (struct type *,
struct ui_file *,
int, int, int,
+ enum language,
const struct type_print_options *,
struct print_offset_data *);
@@ -66,7 +68,7 @@ static void c_type_print_modifier (struct type *,
int, int);
static void c_type_print_base_1 (struct type *type, struct ui_file *stream,
- int show, int level,
+ int show, int level, enum language language,
const struct type_print_options *flags,
struct print_offset_data *podata);
\f
@@ -108,6 +110,7 @@ c_print_type_1 (struct type *type,
const char *varstring,
struct ui_file *stream,
int show, int level,
+ enum language language,
const struct type_print_options *flags,
struct print_offset_data *podata)
{
@@ -128,7 +131,7 @@ c_print_type_1 (struct type *type,
}
else
{
- c_type_print_base_1 (type, stream, show, level, flags, podata);
+ c_type_print_base_1 (type, stream, show, level, language, flags, podata);
code = TYPE_CODE (type);
if ((varstring != NULL && *varstring != '\0')
/* Need a space if going to print stars or brackets;
@@ -144,7 +147,7 @@ c_print_type_1 (struct type *type,
fputs_filtered (" ", stream);
need_post_space = (varstring != NULL && strcmp (varstring, "") != 0);
c_type_print_varspec_prefix (type, stream, show, 0, need_post_space,
- flags, podata);
+ language, flags, podata);
}
if (varstring != NULL)
@@ -158,7 +161,7 @@ c_print_type_1 (struct type *type,
demangled_args = strchr (varstring, '(') != NULL;
c_type_print_varspec_suffix (type, stream, show,
0, demangled_args,
- flags);
+ language, flags);
}
}
}
@@ -174,7 +177,25 @@ c_print_type (struct type *type,
{
struct print_offset_data podata;
- c_print_type_1 (type, varstring, stream, show, level, flags, &podata);
+ c_print_type_1 (type, varstring, stream, show, level,
+ current_language->la_language, flags, &podata);
+}
+
+
+/* See c-lang.h. */
+
+void
+c_print_type (struct type *type,
+ const char *varstring,
+ struct ui_file *stream,
+ int show, int level,
+ enum language language,
+ const struct type_print_options *flags)
+{
+ struct print_offset_data podata;
+
+ c_print_type_1 (type, varstring, stream, show, level, language, flags,
+ &podata);
}
/* Print a typedef using C syntax. TYPE is the underlying type.
@@ -257,6 +278,7 @@ static void
cp_type_print_method_args (struct type *mtype, const char *prefix,
const char *varstring, int staticp,
struct ui_file *stream,
+ enum language language,
const struct type_print_options *flags)
{
struct field *args = TYPE_FIELDS (mtype);
@@ -297,7 +319,7 @@ cp_type_print_method_args (struct type *mtype, const char *prefix,
}
else if (varargs)
fprintf_filtered (stream, "...");
- else if (current_language->la_language == language_cplus)
+ else if (language == language_cplus)
fprintf_filtered (stream, "void");
fprintf_filtered (stream, ")");
@@ -344,6 +366,7 @@ c_type_print_varspec_prefix (struct type *type,
struct ui_file *stream,
int show, int passed_a_ptr,
int need_post_space,
+ enum language language,
const struct type_print_options *flags,
struct print_offset_data *podata)
{
@@ -361,40 +384,46 @@ c_type_print_varspec_prefix (struct type *type,
{
case TYPE_CODE_PTR:
c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
- stream, show, 1, 1, flags, podata);
+ stream, show, 1, 1, language, flags,
+ podata);
fprintf_filtered (stream, "*");
c_type_print_modifier (type, stream, 1, need_post_space);
break;
case TYPE_CODE_MEMBERPTR:
c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
- stream, show, 0, 0, flags, podata);
+ stream, show, 0, 0, language, flags,
+ podata);
name = type_name_no_tag (TYPE_SELF_TYPE (type));
if (name)
print_name_maybe_canonical (name, flags, stream);
else
c_type_print_base_1 (TYPE_SELF_TYPE (type),
- stream, -1, passed_a_ptr, flags, podata);
+ stream, -1, passed_a_ptr, language, flags,
+ podata);
fprintf_filtered (stream, "::*");
break;
case TYPE_CODE_METHODPTR:
c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
- stream, show, 0, 0, flags, podata);
+ stream, show, 0, 0, language, flags,
+ podata);
fprintf_filtered (stream, "(");
name = type_name_no_tag (TYPE_SELF_TYPE (type));
if (name)
print_name_maybe_canonical (name, flags, stream);
else
c_type_print_base_1 (TYPE_SELF_TYPE (type),
- stream, -1, passed_a_ptr, flags, podata);
+ stream, -1, passed_a_ptr, language, flags,
+ podata);
fprintf_filtered (stream, "::*");
break;
case TYPE_CODE_REF:
case TYPE_CODE_RVALUE_REF:
c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
- stream, show, 1, 0, flags, podata);
+ stream, show, 1, 0, language, flags,
+ podata);
fprintf_filtered (stream, TYPE_CODE(type) == TYPE_CODE_REF ? "&" : "&&");
c_type_print_modifier (type, stream, 1, need_post_space);
break;
@@ -402,22 +431,24 @@ c_type_print_varspec_prefix (struct type *type,
case TYPE_CODE_METHOD:
case TYPE_CODE_FUNC:
c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
- stream, show, 0, 0, flags, podata);
+ stream, show, 0, 0, language, flags,
+ podata);
if (passed_a_ptr)
fprintf_filtered (stream, "(");
break;
case TYPE_CODE_ARRAY:
c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
- stream, show, 0, 0, flags, podata);
+ stream, show, 0, 0, language, flags,
+ podata);
if (passed_a_ptr)
fprintf_filtered (stream, "(");
break;
case TYPE_CODE_TYPEDEF:
c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
- stream, show, passed_a_ptr, 0, flags,
- podata);
+ stream, show, passed_a_ptr, 0,
+ language, flags, podata);
break;
case TYPE_CODE_UNDEF:
@@ -556,7 +587,7 @@ c_type_print_args (struct type *type, struct ui_file *stream,
param_type = make_cv_type (0, 0, param_type, NULL);
}
- c_print_type (param_type, "", stream, -1, 0, flags);
+ c_print_type (param_type, "", stream, -1, 0, language, flags);
printed_any = 1;
}
@@ -725,6 +756,7 @@ c_type_print_varspec_suffix (struct type *type,
struct ui_file *stream,
int show, int passed_a_ptr,
int demangled_args,
+ enum language language,
const struct type_print_options *flags)
{
if (type == 0)
@@ -757,26 +789,26 @@ c_type_print_varspec_suffix (struct type *type,
fprintf_filtered (stream, (is_vector ? ")))" : "]"));
c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream,
- show, 0, 0, flags);
+ show, 0, 0, language, flags);
}
break;
case TYPE_CODE_MEMBERPTR:
c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream,
- show, 0, 0, flags);
+ show, 0, 0, language, flags);
break;
case TYPE_CODE_METHODPTR:
fprintf_filtered (stream, ")");
c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream,
- show, 0, 0, flags);
+ show, 0, 0, language, flags);
break;
case TYPE_CODE_PTR:
case TYPE_CODE_REF:
case TYPE_CODE_RVALUE_REF:
c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream,
- show, 1, 0, flags);
+ show, 1, 0, language, flags);
break;
case TYPE_CODE_METHOD:
@@ -784,15 +816,14 @@ c_type_print_varspec_suffix (struct type *type,
if (passed_a_ptr)
fprintf_filtered (stream, ")");
if (!demangled_args)
- c_type_print_args (type, stream, 0, current_language->la_language,
- flags);
+ c_type_print_args (type, stream, 0, language, flags);
c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream,
- show, passed_a_ptr, 0, flags);
+ show, passed_a_ptr, 0, language, flags);
break;
case TYPE_CODE_TYPEDEF:
c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream,
- show, passed_a_ptr, 0, flags);
+ show, passed_a_ptr, 0, language, flags);
break;
case TYPE_CODE_UNDEF:
@@ -1092,6 +1123,7 @@ c_print_type_no_offsets (struct type *type,
const char *varstring,
struct ui_file *stream,
int show, int level,
+ enum language language,
struct type_print_options *flags,
struct print_offset_data *podata)
{
@@ -1100,7 +1132,8 @@ c_print_type_no_offsets (struct type *type,
/* Temporarily disable print_offsets, because it would mess with
indentation. */
flags->print_offsets = 0;
- c_print_type_1 (type, varstring, stream, show, level, flags, podata);
+ c_print_type_1 (type, varstring, stream, show, level, language, flags,
+ podata);
flags->print_offsets = old_po;
}
@@ -1110,6 +1143,7 @@ c_print_type_no_offsets (struct type *type,
static void
c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
int show, int level,
+ enum language language,
const struct type_print_options *flags,
struct print_offset_data *podata)
{
@@ -1290,7 +1324,7 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
c_print_type_1 (TYPE_FIELD_TYPE (type, i),
TYPE_FIELD_NAME (type, i),
stream, newshow, level + 4,
- &local_flags, &local_podata);
+ language, &local_flags, &local_podata);
if (!is_static && TYPE_FIELD_PACKED (type, i))
{
@@ -1379,7 +1413,7 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
{
c_print_type_no_offsets
(TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)),
- "", stream, -1, 0, &local_flags, podata);
+ "", stream, -1, 0, language, &local_flags, podata);
fputs_filtered (" ", stream);
}
@@ -1411,7 +1445,8 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
"",
method_name,
staticp,
- stream, &local_flags);
+ stream, language,
+ &local_flags);
}
else
fprintf_filtered (stream,
@@ -1465,7 +1500,7 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
flags);
c_print_type_no_offsets (TYPE_NESTED_TYPES_FIELD_TYPE (type, i),
"", stream, show, level + 4,
- &semi_local_flags, podata);
+ language, &semi_local_flags, podata);
fprintf_filtered (stream, ";\n");
}
}
@@ -1503,7 +1538,7 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
c_print_type_no_offsets (target,
TYPE_TYPEDEF_FIELD_NAME (type, i),
stream, show - 1, level + 4,
- &semi_local_flags, podata);
+ language, &semi_local_flags, podata);
fprintf_filtered (stream, ";\n");
}
}
@@ -1550,6 +1585,7 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
static void
c_type_print_base_1 (struct type *type, struct ui_file *stream,
int show, int level,
+ enum language language,
const struct type_print_options *flags,
struct print_offset_data *podata)
{
@@ -1597,7 +1633,7 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream,
type_print_unknown_return_type (stream);
else
c_type_print_base_1 (TYPE_TARGET_TYPE (type),
- stream, show, level, flags, podata);
+ stream, show, level, language, flags, podata);
break;
case TYPE_CODE_ARRAY:
case TYPE_CODE_PTR:
@@ -1606,13 +1642,13 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream,
case TYPE_CODE_RVALUE_REF:
case TYPE_CODE_METHODPTR:
c_type_print_base_1 (TYPE_TARGET_TYPE (type),
- stream, show, level, flags, podata);
+ stream, show, level, language, flags, podata);
break;
case TYPE_CODE_STRUCT:
case TYPE_CODE_UNION:
- c_type_print_base_struct_union (type, stream, show, level, flags,
- podata);
+ c_type_print_base_struct_union (type, stream, show, level,
+ language, flags, podata);
break;
case TYPE_CODE_ENUM:
@@ -1653,8 +1689,7 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream,
print too much than too little; but conversely not to
print something egregiously outside the current
language's syntax. */
- if (current_language->la_language == language_cplus
- && TYPE_TARGET_TYPE (type) != NULL)
+ if (language == language_cplus && TYPE_TARGET_TYPE (type) != NULL)
{
struct type *underlying = check_typedef (TYPE_TARGET_TYPE (type));
@@ -1715,7 +1750,7 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream,
c_print_type_1 (TYPE_FIELD_TYPE (type, i),
TYPE_FIELD_NAME (type, i),
stream, show, level + 4,
- &local_flags, podata);
+ language, &local_flags, podata);
fprintf_filtered (stream, " @%s",
plongest (TYPE_FIELD_BITPOS (type, i)));
if (TYPE_FIELD_BITSIZE (type, i) > 1)
@@ -1784,5 +1819,6 @@ c_type_print_base (struct type *type, struct ui_file *stream,
{
struct print_offset_data podata;
- c_type_print_base_1 (type, stream, show, level, flags, &podata);
+ c_type_print_base_1 (type, stream, show, level,
+ current_language->la_language, flags, &podata);
}
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 9c9dcee058..8dbe12db02 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -10814,7 +10814,8 @@ dwarf2_compute_name (const char *name,
if (child->tag == DW_TAG_template_type_param)
{
- c_print_type (type, "", &buf, -1, 0, &type_print_raw_options);
+ c_print_type (type, "", &buf, -1, 0, cu->language,
+ &type_print_raw_options);
continue;
}
--
2.13.6
^ permalink raw reply [flat|nested] 16+ messages in thread
* [RFA 4/4] Remove type_name_no_tag and rename type_name_no_tag_or_error
2018-04-17 19:51 [RFA 0/4] Remove TYPE_TAG_NAME Tom Tromey
2018-04-17 19:51 ` [RFA 3/4] " Tom Tromey
2018-04-17 19:51 ` [RFA 1/4] Make c_type_print_varspec_suffix static Tom Tromey
@ 2018-04-17 19:51 ` Tom Tromey
2018-05-31 6:22 ` Joel Brobecker
2018-04-17 19:51 ` [RFA 2/4] Thread language through c_type_print_args Tom Tromey
` (2 subsequent siblings)
5 siblings, 1 reply; 16+ messages in thread
From: Tom Tromey @ 2018-04-17 19:51 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
type_name_no_tag is just a plain wrapper for TYPE_NAME now, so this
patch removes it. And, because tag names no longer exist, this
renames type_name_no_tag_or_error to type_name_or_error.
ChangeLog
2018-04-17 Tom Tromey <tom@tromey.com>
* valops.c (value_cast_structs, destructor_name_p): Update.
* symtab.c (gdb_mangle_name): Update.
* stabsread.c (define_symbol, read_cpp_abbrev, read_baseclasses):
Update.
* p-valprint.c (pascal_object_is_vtbl_ptr_type)
(pascal_object_print_value_fields, pascal_object_print_value):
Update.
* p-typeprint.c (pascal_type_print_derivation_info): Update.
* linespec.c (find_methods): Update.
* gdbtypes.h (type_name_no_tag): Remove.
(type_name_or_error): Rename from type_name_no_tag_or_error.
* gdbtypes.c (type_name_no_tag): Remove.
(type_name_or_error): Rename from type_name_no_tag_or_error.
(lookup_struct_elt_type, check_typedef): Update.
* expprint.c (print_subexp_standard): Update.
* dwarf2read.c (dwarf2_add_field, load_partial_dies): Update.
* d-namespace.c (d_lookup_nested_symbol): Update.
* cp-valprint.c (cp_is_vtbl_ptr_type, cp_print_value_fields)
(cp_print_class_member): Update.
* cp-namespace.c (cp_lookup_nested_symbol): Update.
* completer.c (add_struct_fields): Update.
* c-typeprint.c (cp_type_print_derivation_info)
(c_type_print_varspec_prefix, c_type_print_base_struct_union):
Update.
* ada-lang.c (parse_old_style_renaming, xget_renaming_scope)
(ada_prefer_type, ada_is_exception_sym): Update.
---
gdb/ChangeLog | 29 +++++++++++++++++++++++++++++
gdb/ada-lang.c | 10 +++++-----
gdb/c-typeprint.c | 11 +++++------
gdb/completer.c | 2 +-
gdb/cp-namespace.c | 6 +++---
gdb/cp-valprint.c | 6 +++---
gdb/d-namespace.c | 2 +-
gdb/dwarf2read.c | 4 ++--
gdb/expprint.c | 2 +-
gdb/gdbtypes.c | 25 ++++++++-----------------
gdb/gdbtypes.h | 4 +---
gdb/linespec.c | 2 +-
gdb/p-typeprint.c | 2 +-
gdb/p-valprint.c | 6 +++---
gdb/stabsread.c | 8 ++++----
gdb/symtab.c | 2 +-
gdb/valops.c | 8 ++++----
17 files changed, 73 insertions(+), 56 deletions(-)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 41235def3e..ce342fd684 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -4399,7 +4399,7 @@ parse_old_style_renaming (struct type *type,
|| TYPE_NFIELDS (type) != 1)
return ADA_NOT_RENAMING;
- name = type_name_no_tag (type);
+ name = TYPE_NAME (type);
if (name == NULL)
return ADA_NOT_RENAMING;
@@ -5190,7 +5190,7 @@ xget_renaming_scope (struct type *renaming_type)
So, to extract the scope, we search for the "___XR" extension,
and then backtrack until we find the first "__". */
- const char *name = type_name_no_tag (renaming_type);
+ const char *name = TYPE_NAME (renaming_type);
const char *suffix = strstr (name, "___XR");
const char *last;
int scope_len;
@@ -8126,8 +8126,8 @@ ada_prefer_type (struct type *type0, struct type *type1)
return 1;
else
{
- const char *type0_name = type_name_no_tag (type0);
- const char *type1_name = type_name_no_tag (type1);
+ const char *type0_name = TYPE_NAME (type0);
+ const char *type1_name = TYPE_NAME (type1);
if (type0_name != NULL && strstr (type0_name, "___XR") != NULL
&& (type1_name == NULL || strstr (type1_name, "___XR") == NULL))
@@ -13517,7 +13517,7 @@ catch_assert_command (const char *arg_entry, int from_tty,
static int
ada_is_exception_sym (struct symbol *sym)
{
- const char *type_name = type_name_no_tag (SYMBOL_TYPE (sym));
+ const char *type_name = TYPE_NAME (SYMBOL_TYPE (sym));
return (SYMBOL_CLASS (sym) != LOC_TYPEDEF
&& SYMBOL_CLASS (sym) != LOC_BLOCK
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index 846727f298..5e5cdd98fd 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -260,7 +260,7 @@ cp_type_print_derivation_info (struct ui_file *stream,
? "public" : (TYPE_FIELD_PROTECTED (type, i)
? "protected" : "private"),
BASETYPE_VIA_VIRTUAL (type, i) ? " virtual" : "");
- name = type_name_no_tag (TYPE_BASECLASS (type, i));
+ name = TYPE_NAME (TYPE_BASECLASS (type, i));
if (name)
print_name_maybe_canonical (name, flags, stream);
else
@@ -392,9 +392,8 @@ c_type_print_varspec_prefix (struct type *type,
case TYPE_CODE_MEMBERPTR:
c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
- stream, show, 0, 0, language, flags,
- podata);
- name = type_name_no_tag (TYPE_SELF_TYPE (type));
+ stream, show, 0, 0, language, flags, podata);
+ name = TYPE_NAME (TYPE_SELF_TYPE (type));
if (name)
print_name_maybe_canonical (name, flags, stream);
else
@@ -409,7 +408,7 @@ c_type_print_varspec_prefix (struct type *type,
stream, show, 0, 0, language, flags,
podata);
fprintf_filtered (stream, "(");
- name = type_name_no_tag (TYPE_SELF_TYPE (type));
+ name = TYPE_NAME (TYPE_SELF_TYPE (type));
if (name)
print_name_maybe_canonical (name, flags, stream);
else
@@ -1365,7 +1364,7 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i);
int j, len2 = TYPE_FN_FIELDLIST_LENGTH (type, i);
const char *method_name = TYPE_FN_FIELDLIST_NAME (type, i);
- const char *name = type_name_no_tag (type);
+ const char *name = TYPE_NAME (type);
int is_constructor = name && strcmp (method_name,
name) == 0;
diff --git a/gdb/completer.c b/gdb/completer.c
index 769dcf0eb6..3e87ed454c 100644
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -999,7 +999,7 @@ add_struct_fields (struct type *type, completion_list &output,
{
if (!computed_type_name)
{
- type_name = type_name_no_tag (type);
+ type_name = TYPE_NAME (type);
computed_type_name = 1;
}
/* Omit constructors from the completion list. */
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index 185607e4eb..c1d7a8db7d 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -915,7 +915,7 @@ cp_lookup_nested_symbol (struct type *parent_type,
const struct block *block,
const domain_enum domain)
{
- /* type_name_no_tag_or_error provides better error reporting using the
+ /* type_name_or_error provides better error reporting using the
original type. */
struct type *saved_parent_type = parent_type;
@@ -923,7 +923,7 @@ cp_lookup_nested_symbol (struct type *parent_type,
if (symbol_lookup_debug)
{
- const char *type_name = type_name_no_tag (saved_parent_type);
+ const char *type_name = TYPE_NAME (saved_parent_type);
fprintf_unfiltered (gdb_stdlog,
"cp_lookup_nested_symbol (%s, %s, %s, %s)\n",
@@ -944,7 +944,7 @@ cp_lookup_nested_symbol (struct type *parent_type,
case TYPE_CODE_MODULE:
{
int size;
- const char *parent_name = type_name_no_tag_or_error (saved_parent_type);
+ const char *parent_name = type_name_or_error (saved_parent_type);
struct block_symbol sym;
char *concatenated_name;
int is_in_anonymous;
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index e019a60791..f67eaed5b7 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -95,7 +95,7 @@ extern const char vtbl_ptr_name[] = "__vtbl_ptr_type";
int
cp_is_vtbl_ptr_type (struct type *type)
{
- const char *type_name = type_name_no_tag (type);
+ const char *type_name = TYPE_NAME (type);
return (type_name != NULL && !strcmp (type_name, vtbl_ptr_name));
}
@@ -243,7 +243,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
fprintf_filtered (stream, "\n");
print_spaces_filtered (2 + 2 * recurse, stream);
fputs_filtered ("members of ", stream);
- fputs_filtered (type_name_no_tag (type), stream);
+ fputs_filtered (TYPE_NAME (type), stream);
fputs_filtered (": ", stream);
}
}
@@ -787,7 +787,7 @@ cp_print_class_member (const gdb_byte *valaddr, struct type *type,
const char *name;
fputs_filtered (prefix, stream);
- name = type_name_no_tag (self_type);
+ name = TYPE_NAME (self_type);
if (name)
fputs_filtered (name, stream);
else
diff --git a/gdb/d-namespace.c b/gdb/d-namespace.c
index f786b55762..6e9ea776a5 100644
--- a/gdb/d-namespace.c
+++ b/gdb/d-namespace.c
@@ -318,7 +318,7 @@ d_lookup_nested_symbol (struct type *parent_type,
case TYPE_CODE_MODULE:
{
int size;
- const char *parent_name = type_name_no_tag_or_error (saved_parent_type);
+ const char *parent_name = type_name_or_error (saved_parent_type);
struct block_symbol sym
= d_lookup_symbol_in_module (parent_name, nested_name,
block, VAR_DOMAIN, 0);
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 78c36887ee..1b18165f7e 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -15070,7 +15070,7 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
SET_FIELD_BITPOS (*fp, offset * bits_per_byte);
FIELD_BITSIZE (*fp) = 0;
FIELD_TYPE (*fp) = die_type (die, cu);
- FIELD_NAME (*fp) = type_name_no_tag (fp->type);
+ FIELD_NAME (*fp) = TYPE_NAME (fp->type);
}
else if (die->tag == DW_TAG_variant_part)
{
@@ -18175,7 +18175,7 @@ load_partial_dies (const struct die_reader_specs *reader,
/* The exception for DW_TAG_typedef with has_children above is
a workaround of GCC PR debug/47510. In the case of this complaint
- type_name_no_tag_or_error will error on such types later.
+ type_name_or_error will error on such types later.
GDB skipped children of DW_TAG_typedef by the shortcut above and then
it could not find the child DIEs referenced later, this is checked
diff --git a/gdb/expprint.c b/gdb/expprint.c
index c906904599..7c9c5b6509 100644
--- a/gdb/expprint.c
+++ b/gdb/expprint.c
@@ -86,7 +86,7 @@ print_subexp_standard (struct expression *exp, int *pos,
case OP_SCOPE:
myprec = PREC_PREFIX;
assoc = 0;
- fputs_filtered (type_name_no_tag (exp->elts[pc + 1].type), stream);
+ fputs_filtered (TYPE_NAME (exp->elts[pc + 1].type), stream);
fputs_filtered ("::", stream);
nargs = longest_to_int (exp->elts[pc + 2].longconst);
(*pos) += 4 + BYTES_TO_EXP_ELEM (nargs + 1);
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index b3a388656e..15ebb97eb9 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1463,16 +1463,7 @@ smash_to_method_type (struct type *type, struct type *self_type,
TYPE_LENGTH (type) = 1; /* In practice, this is never needed. */
}
-/* Return a typename for a struct/union/enum type without "struct ",
- "union ", or "enum ". If the type has a NULL name, return NULL. */
-
-const char *
-type_name_no_tag (const struct type *type)
-{
- return TYPE_NAME (type);
-}
-
-/* A wrapper of type_name_no_tag which calls error if the type is anonymous.
+/* A wrapper of TYPE_NAME which calls error if the type is anonymous.
Since GCC PR debug/47510 DWARF provides associated information to detect the
anonymous class linkage name from its typedef.
@@ -1480,7 +1471,7 @@ type_name_no_tag (const struct type *type)
apply it itself. */
const char *
-type_name_no_tag_or_error (struct type *type)
+type_name_or_error (struct type *type)
{
struct type *saved_type = type;
const char *name;
@@ -1488,11 +1479,11 @@ type_name_no_tag_or_error (struct type *type)
type = check_typedef (type);
- name = type_name_no_tag (type);
+ name = TYPE_NAME (type);
if (name != NULL)
return name;
- name = type_name_no_tag (saved_type);
+ name = TYPE_NAME (saved_type);
objfile = TYPE_OBJFILE (saved_type);
error (_("Invalid anonymous type %s [in module %s], GCC PR debug/47510 bug?"),
name ? name : "<anonymous>",
@@ -1686,7 +1677,7 @@ lookup_struct_elt_type (struct type *type, const char *name, int noerr)
{
char *type_name;
- type_name = type_name_no_tag (type);
+ type_name = TYPE_NAME (type);
if (type_name != NULL && strcmp (type_name, name) == 0)
return type;
}
@@ -2438,7 +2429,7 @@ check_typedef (struct type *type)
if (currently_reading_symtab)
return make_qualified_type (type, instance_flags, NULL);
- name = type_name_no_tag (type);
+ name = TYPE_NAME (type);
/* FIXME: shouldn't we look in STRUCT_DOMAIN and/or
VAR_DOMAIN as appropriate? */
if (name == NULL)
@@ -2491,7 +2482,7 @@ check_typedef (struct type *type)
&& opaque_type_resolution
&& !currently_reading_symtab)
{
- const char *name = type_name_no_tag (type);
+ const char *name = TYPE_NAME (type);
struct type *newtype;
if (name == NULL)
@@ -2525,7 +2516,7 @@ check_typedef (struct type *type)
types. */
else if (TYPE_STUB (type) && !currently_reading_symtab)
{
- const char *name = type_name_no_tag (type);
+ const char *name = TYPE_NAME (type);
/* FIXME: shouldn't we look in STRUCT_DOMAIN and/or VAR_DOMAIN
as appropriate? */
struct symbol *sym;
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 70dac75855..7247bb6481 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -1835,9 +1835,7 @@ extern void smash_to_methodptr_type (struct type *, struct type *);
extern struct type *allocate_stub_method (struct type *);
-extern const char *type_name_no_tag (const struct type *);
-
-extern const char *type_name_no_tag_or_error (struct type *type);
+extern const char *type_name_or_error (struct type *type);
extern struct type *lookup_struct_elt_type (struct type *, const char *, int);
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 7ef8012ab5..e65a0462f1 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -1211,7 +1211,7 @@ find_methods (struct type *t, enum language t_lang, const char *name,
std::vector<struct type *> *superclasses)
{
int ibase;
- const char *class_name = type_name_no_tag (t);
+ const char *class_name = TYPE_NAME (t);
/* Ignore this class if it doesn't have a name. This is ugly, but
unless we figure out how to get the physname without the name of
diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c
index f82a2bc981..349bbd6aa4 100644
--- a/gdb/p-typeprint.c
+++ b/gdb/p-typeprint.c
@@ -139,7 +139,7 @@ pascal_type_print_derivation_info (struct ui_file *stream, struct type *type)
fprintf_filtered (stream, "%s%s ",
BASETYPE_VIA_PUBLIC (type, i) ? "public" : "private",
BASETYPE_VIA_VIRTUAL (type, i) ? " virtual" : "");
- name = type_name_no_tag (TYPE_BASECLASS (type, i));
+ name = TYPE_NAME (TYPE_BASECLASS (type, i));
fprintf_filtered (stream, "%s", name ? name : "(null)");
}
if (i > 0)
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index 933dbfb6c4..766ccc604b 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -489,7 +489,7 @@ const char pascal_vtbl_ptr_name[] =
int
pascal_object_is_vtbl_ptr_type (struct type *type)
{
- const char *type_name = type_name_no_tag (type);
+ const char *type_name = TYPE_NAME (type);
return (type_name != NULL
&& strcmp (type_name, pascal_vtbl_ptr_name) == 0);
@@ -587,7 +587,7 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
fprintf_filtered (stream, "\n");
print_spaces_filtered (2 + 2 * recurse, stream);
fputs_filtered ("members of ", stream);
- fputs_filtered (type_name_no_tag (type), stream);
+ fputs_filtered (TYPE_NAME (type), stream);
fputs_filtered (": ", stream);
}
}
@@ -729,7 +729,7 @@ pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
{
LONGEST boffset = 0;
struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
- const char *basename = type_name_no_tag (baseclass);
+ const char *basename = TYPE_NAME (baseclass);
const gdb_byte *base_valaddr = NULL;
LONGEST thisoffset;
int skip = 0;
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 420cdd2742..65812e6b35 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -1246,7 +1246,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
for (j = TYPE_N_BASECLASSES (SYMBOL_TYPE (sym)) - 1; j >= 0; j--)
if (TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), j) == 0)
TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), j) =
- type_name_no_tag (TYPE_BASECLASS (SYMBOL_TYPE (sym), j));
+ TYPE_NAME (TYPE_BASECLASS (SYMBOL_TYPE (sym), j));
}
if (TYPE_NAME (SYMBOL_TYPE (sym)) == NULL)
@@ -2792,7 +2792,7 @@ read_cpp_abbrev (struct field_info *fip, const char **pp, struct type *type,
switch (cpp_abbrev)
{
case 'f': /* $vf -- a virtual function table pointer */
- name = type_name_no_tag (context);
+ name = TYPE_NAME (context);
if (name == NULL)
{
name = "";
@@ -2802,7 +2802,7 @@ read_cpp_abbrev (struct field_info *fip, const char **pp, struct type *type,
break;
case 'b': /* $vb -- a virtual bsomethingorother */
- name = type_name_no_tag (context);
+ name = TYPE_NAME (context);
if (name == NULL)
{
complaint (&symfile_complaints,
@@ -3209,7 +3209,7 @@ read_baseclasses (struct field_info *fip, const char **pp, struct type *type,
field's name. */
newobj->field.type = read_type (pp, objfile);
- newobj->field.name = type_name_no_tag (newobj->field.type);
+ newobj->field.name = TYPE_NAME (newobj->field.type);
/* Skip trailing ';' and bump count of number of fields seen. */
if (**pp == ';')
diff --git a/gdb/symtab.c b/gdb/symtab.c
index c1ead701ec..4fc5f3e755 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -528,7 +528,7 @@ gdb_mangle_name (struct type *type, int method_id, int signature_id)
struct fn_field *method = &f[signature_id];
const char *field_name = TYPE_FN_FIELDLIST_NAME (type, method_id);
const char *physname = TYPE_FN_FIELD_PHYSNAME (f, signature_id);
- const char *newname = type_name_no_tag (type);
+ const char *newname = TYPE_NAME (type);
/* Does the form of physname indicate that it is the full mangled name
of a constructor (not just the args)? */
diff --git a/gdb/valops.c b/gdb/valops.c
index cb51a2688e..43fad60d0d 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -244,7 +244,7 @@ value_cast_structs (struct type *type, struct value *v2)
offset the pointer rather than just change its type. */
if (TYPE_NAME (t1) != NULL)
{
- v = search_struct_field (type_name_no_tag (t1),
+ v = search_struct_field (TYPE_NAME (t1),
v2, t2, 1);
if (v)
return v;
@@ -273,7 +273,7 @@ value_cast_structs (struct type *type, struct value *v2)
&& !strcmp (TYPE_NAME (real_type), TYPE_NAME (t1)))
return v;
- v = search_struct_field (type_name_no_tag (t2), v, real_type, 1);
+ v = search_struct_field (TYPE_NAME (t2), v, real_type, 1);
if (v)
return v;
}
@@ -281,7 +281,7 @@ value_cast_structs (struct type *type, struct value *v2)
/* Try downcasting using information from the destination type
T2. This wouldn't work properly for classes with virtual
bases, but those were handled above. */
- v = search_struct_field (type_name_no_tag (t2),
+ v = search_struct_field (TYPE_NAME (t2),
value_zero (t1, not_lval), t1, 1);
if (v)
{
@@ -3193,7 +3193,7 @@ destructor_name_p (const char *name, struct type *type)
{
if (name[0] == '~')
{
- const char *dname = type_name_no_tag_or_error (type);
+ const char *dname = type_name_or_error (type);
const char *cp = strchr (dname, '<');
unsigned int len;
--
2.13.6
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFA 3/4] Remove TYPE_TAG_NAME
2018-04-17 19:51 ` [RFA 3/4] " Tom Tromey
@ 2018-04-18 16:57 ` Keith Seitz
2018-04-18 17:57 ` Tom Tromey
2018-05-31 2:35 ` Joel Brobecker
1 sibling, 1 reply; 16+ messages in thread
From: Keith Seitz @ 2018-04-18 16:57 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
On 04/17/2018 12:51 PM, Tom Tromey wrote:
> ChangeLog
> 2018-04-17 Tom Tromey <tom@tromey.com>
>
> * valops.c (enum_constant_from_type, value_namespace_elt)
> (value_maybe_namespace_elt): Update.
> * valarith.c (find_size_for_pointer_math): Update.
> * target-descriptions.c (make_gdb_type): Update.
> * symmisc.c (print_symbol): Update.
> * stabsread.c (define_symbol, read_type)
> (complain_about_struct_wipeout, add_undefined_type)
> (cleanup_undefined_types_1): Update.
> * rust-lang.c (rust_tuple_type_p, rust_slice_type_p)
> (rust_range_type_p, val_print_struct, rust_print_struct_def)
> (rust_internal_print_type, rust_composite_type)
> (rust_evaluate_funcall, rust_evaluate_subexp): Update.
> * python/py-type.c (typy_get_tag): Update.
> * p-typeprint.c (pascal_type_print_base): Update.
> * mdebugread.c (parse_symbol, parse_type): Update.
> * m2-typeprint.c (m2_long_set, m2_record_fields, m2_enum):
> Update.
> * guile/scm-type.c (gdbscm_type_tag): Update.
> * go-lang.c (sixg_string_p): Update.
> * gnu-v3-abi.c (build_gdb_vtable_type, build_std_type_info_type):
> Update.
> * gdbtypes.h (struct main_type) <tag_name>: Remove.
> (TYPE_TAG_NAME): Remove.
> * gdbtypes.c (type_name_no_tag): Simplify.
> (check_typedef, check_types_equal, recursive_dump_type)
> (copy_type_recursive, arch_composite_type): Update.
> * f-typeprint.c (f_type_print_base): Update. Print "Type" prefix
> in summary mode when needed.
> * eval.c (evaluate_funcall): Update.
> * dwarf2read.c (fixup_go_packaging, read_structure_type)
> (process_structure_scope, read_enumeration_type)
> (read_namespace_type, read_module_type, determine_prefix): Update.
> * cp-support.c (inspect_type): Update.
> * coffread.c (process_coff_symbol, decode_base_type): Update.
> * c-varobj.c (c_is_path_expr_parent): Update.
> * c-typeprint.c (c_type_print_base_struct_union): Update.
> (c_type_print_base_1): Update. Print struct/class/union/enum in
> summary when using C language.
> * ax-gdb.c (gen_struct_ref, gen_namespace_elt)
> (gen_maybe_namespace_elt): Update.
> * ada-lang.c (ada_type_name): Simplify.
> (empty_record, ada_template_to_fixed_record_type_1)
> (template_to_static_fixed_type)
> (to_record_with_fixed_variant_part, ada_check_typedef): Update.
>
> testsuite/ChangeLog
> 2018-04-17 Tom Tromey <tom@tromey.com>
>
> * gdb.xml/tdesc-regs.exp (load_description): Update expected
> results.
> * gdb.dwarf2/method-ptr.exp: Set language to C++.
> * gdb.dwarf2/member-ptr-forwardref.exp: Set language to C++.
> * gdb.cp/typeid.exp (do_typeid_tests): Update type_re.
> * gdb.base/maint.exp (maint_pass_if): Update.
Oh, ChangeLogs... Once again I wonder if "update all callers" would have saved you quite a bit of busywork?
> diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
> index a53331aefc..846727f298 100644
> --- a/gdb/c-typeprint.c
> +++ b/gdb/c-typeprint.c
> @@ -1602,15 +1602,31 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream,
>
> /* When SHOW is zero or less, and there is a valid type name, then
> always just print the type name directly from the type. */
> - /* If we have "typedef struct foo {. . .} bar;" do we want to print
> - it as "struct foo" or as "bar"? Pick the latter, because C++
> - folk tend to expect things like "class5 *foo" rather than "struct
> - class5 *foo". */
>
> if (show <= 0
> && TYPE_NAME (type) != NULL)
> {
> c_type_print_modifier (type, stream, 0, 1);
> +
> + /* If we have "typedef struct foo {. . .} bar;" do we want to
> + print it as "struct foo" or as "bar"? Pick the latter for
> + C++, because C++ folk tend to expect things like "class5
> + *foo" rather than "struct class5 *foo". */
> + if (language == language_c || language == language_minimal)
> + {
> + if (TYPE_CODE (type) == TYPE_CODE_UNION)
> + fprintf_filtered (stream, "union ");
> + else if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
> + {
> + if (TYPE_DECLARED_CLASS (type))
> + fprintf_filtered (stream, "class ");
> + else
> + fprintf_filtered (stream, "struct ");
> + }
> + else if (TYPE_CODE (type) == TYPE_CODE_ENUM)
> + fprintf_filtered (stream, "enum ");
> + }
> +
> print_name_maybe_canonical (TYPE_NAME (type), flags, stream);
> return;
> }
I'm almost afraid to ask, but why was language_minimal necessary here? A small comment might be appropriate?
[I think I can already guess the heinous reason...] Do you know if there is a test case that specifically covers this block with language_minimal?
> diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
> index 552a2a2a16..70dac75855 100644
> --- a/gdb/gdbtypes.h
> +++ b/gdb/gdbtypes.h
> @@ -721,26 +721,12 @@ struct main_type
>
> /* * Name of this type, or NULL if none.
>
> - This is used for printing only, except by poorly designed C++
> - code. For looking up a name, look for a symbol in the
> - VAR_DOMAIN. This is generally allocated in the objfile's
> - obstack. However coffread.c uses malloc. */
> + This is used for printing only. For looking up a name, look for
> + a symbol in the VAR_DOMAIN. This is generally allocated in the
> + objfile's obstack. However coffread.c uses malloc. */
Good riddance! I never did understand the "except by poorly designed C++ code" comment.
> diff --git a/gdb/cp-support.c b/gdb/cp-support.c
> index dde417be80..c16b67171f 100644
> --- a/gdb/cp-support.c
> +++ b/gdb/cp-support.c
> @@ -199,7 +199,7 @@ inspect_type (struct demangle_parse_info *info,
> && strcmp (TYPE_NAME (type), name) == 0)
> return 0;
>
> - is_anon = (TYPE_TAG_NAME (type) == NULL
> + is_anon = (TYPE_NAME (type) == NULL
> && (TYPE_CODE (type) == TYPE_CODE_ENUM
> || TYPE_CODE (type) == TYPE_CODE_STRUCT
> || TYPE_CODE (type) == TYPE_CODE_UNION));
> diff --git a/gdb/guile/scm-type.c b/gdb/guile/scm-type.c
> index ce67695b76..949e0dca82 100644
> --- a/gdb/guile/scm-type.c
> +++ b/gdb/guile/scm-type.c
> @@ -576,10 +576,16 @@ gdbscm_type_tag (SCM self)
> type_smob *t_smob
> = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
> struct type *type = t_smob->type;
> + const char *tagname = nullptr;
>
> - if (!TYPE_TAG_NAME (type))
> + if (TYPE_CODE (type) == TYPE_CODE_STRUCT
> + || TYPE_CODE (type) == TYPE_CODE_UNION
> + || TYPE_CODE (type) == TYPE_CODE_ENUM)
> + tagname = TYPE_NAME (type);
> +
> + if (tagname == nullptr)
> return SCM_BOOL_F;
> - return gdbscm_scm_from_c_string (TYPE_TAG_NAME (type));
> + return gdbscm_scm_from_c_string (tagname);
> }
>
> /* (type-name <gdb:type>) -> string
> diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
> index 8a948eeaa6..6cbb1b663d 100644
> --- a/gdb/python/py-type.c
> +++ b/gdb/python/py-type.c
> @@ -416,10 +416,16 @@ static PyObject *
> typy_get_tag (PyObject *self, void *closure)
> {
> struct type *type = ((type_object *) self)->type;
> + const char *tagname = nullptr;
>
> - if (!TYPE_TAG_NAME (type))
> + if (TYPE_CODE (type) == TYPE_CODE_STRUCT
> + || TYPE_CODE (type) == TYPE_CODE_UNION
> + || TYPE_CODE (type) == TYPE_CODE_ENUM)
> + tagname = TYPE_NAME (type);
> +
> + if (tagname == nullptr)
> Py_RETURN_NONE;
> - return PyString_FromString (TYPE_TAG_NAME (type));
> + return PyString_FromString (tagname);
> }
>
> /* Return the type, stripped of typedefs. */
The above three code snippets suggest the introduction of a type_tag_name (struct type *) convenience function might be justified, but I am not going to request any such change.
> diff --git a/gdb/testsuite/gdb.xml/tdesc-regs.exp b/gdb/testsuite/gdb.xml/tdesc-regs.exp
> index bb7b9be16c..94d4007a89 100644
> --- a/gdb/testsuite/gdb.xml/tdesc-regs.exp
> +++ b/gdb/testsuite/gdb.xml/tdesc-regs.exp
> @@ -179,7 +179,7 @@ gdb_test "ptype \$extrareg" "type = (int|long|long long)"
> gdb_test "ptype \$uintreg" "type = uint32_t"
> gdb_test "ptype \$vecreg" "type = int8_t __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
> gdb_test "ptype \$unionreg" \
> - "type = union {\r\n *v4int8 v4;\r\n *v2int16 v2;\r\n}"
> + "type = union vecint {\r\n *v4int8 v4;\r\n *v2int16 v2;\r\n}"
> gdb_test "ptype \$unionreg.v4" "type = int8_t __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
> gdb_test "ptype \$structreg" \
> "type = struct struct1 {\r\n *v4int8 v4;\r\n *v2int16 v2;\r\n}"
<rhetorical>Was the tag name never printed until now?</rhetorical> Wow!
> @@ -189,7 +189,7 @@ gdb_test "ptype \$bitfields" \
> gdb_test "ptype \$flags" \
> "type = flag flags {\r\n *bool X @0;\r\n *uint32_t Y @2;\r\n}"
> gdb_test "ptype \$mixed_flags" \
> - "type = flag mixed_flags {\r\n *bool A @0;\r\n *uint32_t B @1-3;\r\n *bool C @4;\r\n *uint32_t D @5;\r\n *uint32_t @6-7;\r\n *enum {yes = 1, no = 0, maybe = 2, so} Z @8-9;\r\n}"
> + "type = flag mixed_flags {\r\n *bool A @0;\r\n *uint32_t B @1-3;\r\n *bool C @4;\r\n *uint32_t D @5;\r\n *uint32_t @6-7;\r\n *enum Z_values {yes = 1, no = 0, maybe = 2, so} Z @8-9;\r\n}"
> # Reggroups should have at least general and the extra foo group
> gdb_test "maintenance print reggroups" \
> " Group\[ \t\]+Type\[ \t\]+\r\n.* general\[ \t\]+user\[ \t\]+\r\n.* foo\[ \t\]+user\[ \t\]+"
Warning: I am not a maintainer, ... You know the rest of that drill. :-)
Keith
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFA 0/4] Remove TYPE_TAG_NAME
2018-04-17 19:51 [RFA 0/4] Remove TYPE_TAG_NAME Tom Tromey
` (3 preceding siblings ...)
2018-04-17 19:51 ` [RFA 2/4] Thread language through c_type_print_args Tom Tromey
@ 2018-04-18 16:57 ` Keith Seitz
2018-05-09 15:42 ` Tom Tromey
5 siblings, 0 replies; 16+ messages in thread
From: Keith Seitz @ 2018-04-18 16:57 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
On 04/17/2018 12:51 PM, Tom Tromey wrote:
> As mentioned on the list, here is the series to remove TYPE_TAG_NAME.
>
> I think each patch is relatively self-explanatory, so I won't describe
> them further here.
Awesome!
I've looked over all the patches, and I have only some minor comments on patch #3 to which I'll follow-up there.
Thank you so much for doing this. This is something that I keep forgetting to look into -- for many years now!
Keith
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFA 2/4] Thread language through c_type_print_args
2018-04-17 19:51 ` [RFA 2/4] Thread language through c_type_print_args Tom Tromey
@ 2018-04-18 17:53 ` Tom Tromey
2018-05-31 1:37 ` Joel Brobecker
1 sibling, 0 replies; 16+ messages in thread
From: Tom Tromey @ 2018-04-18 17:53 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:
Tom> Currently dwarf2read.c will pass the CU's language to
Tom> c_type_print_args -- but this doesn't affect all aspects of type
Tom> printing, because some code in c-typeprint.c refers to
Tom> current_language.
Tom> This patch threads the language through more of the type printing
Tom> code, adding an overload to c_type_print. Some uses of
Tom> current_language remain, but now they are only in top-level functions.
Today I was wondering whether it would be better to put the language
into the type_print_options. So, I think that is something to consider
during review.
Tom
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFA 3/4] Remove TYPE_TAG_NAME
2018-04-18 16:57 ` Keith Seitz
@ 2018-04-18 17:57 ` Tom Tromey
2018-04-18 18:06 ` Keith Seitz
0 siblings, 1 reply; 16+ messages in thread
From: Tom Tromey @ 2018-04-18 17:57 UTC (permalink / raw)
To: Keith Seitz; +Cc: Tom Tromey, gdb-patches
>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:
>> + /* If we have "typedef struct foo {. . .} bar;" do we want to
>> + print it as "struct foo" or as "bar"? Pick the latter for
>> + C++, because C++ folk tend to expect things like "class5
>> + *foo" rather than "struct class5 *foo". */
>> + if (language == language_c || language == language_minimal)
Keith> I'm almost afraid to ask, but why was language_minimal necessary here?
Keith> A small comment might be appropriate?
Keith> [I think I can already guess the heinous reason...] Do you know if
Keith> there is a test case that specifically covers this block with
Keith> language_minimal?
I think in this case, I added language_minimal on the theory that it is
"C-like". I don't think there's a test case.
I can add a comment, and a test case wouldn't be too hard either.
Keith> Good riddance! I never did understand the "except by poorly
Keith> designed C++ code" comment.
Haha, me neither. I always considered it a critique of some other code
elsewhere in gdb (perhaps long since removed) but who knows.
>> gdb_test "ptype \$structreg" \
>> "type = struct struct1 {\r\n *v4int8 v4;\r\n *v2int16 v2;\r\n}"
Keith> <rhetorical>Was the tag name never printed until now?</rhetorical> Wow!
Maybe I should have investigated this one more deeply?
I dunno. The change seemed to make sense to me so I just moved on.
Tom
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFA 3/4] Remove TYPE_TAG_NAME
2018-04-18 17:57 ` Tom Tromey
@ 2018-04-18 18:06 ` Keith Seitz
0 siblings, 0 replies; 16+ messages in thread
From: Keith Seitz @ 2018-04-18 18:06 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On 04/18/2018 10:57 AM, Tom Tromey wrote:
>>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:
>
>>> + /* If we have "typedef struct foo {. . .} bar;" do we want to
>>> + print it as "struct foo" or as "bar"? Pick the latter for
>>> + C++, because C++ folk tend to expect things like "class5
>>> + *foo" rather than "struct class5 *foo". */
>>> + if (language == language_c || language == language_minimal)
>
> Keith> I'm almost afraid to ask, but why was language_minimal necessary here?
> Keith> A small comment might be appropriate?
> Keith> [I think I can already guess the heinous reason...] Do you know if
> Keith> there is a test case that specifically covers this block with
> Keith> language_minimal?
>
> I think in this case, I added language_minimal on the theory that it is
> "C-like". I don't think there's a test case.
>
> I can add a comment, and a test case wouldn't be too hard either.
Seeing "language_minimal" caught me off guard. A comment would more than satisfy me.
>
>>> gdb_test "ptype \$structreg" \
>>> "type = struct struct1 {\r\n *v4int8 v4;\r\n *v2int16 v2;\r\n}"
>
> Keith> <rhetorical>Was the tag name never printed until now?</rhetorical> Wow!
>
> Maybe I should have investigated this one more deeply?
> I dunno. The change seemed to make sense to me so I just moved on.
I agree. My rhetorical "question" was really more a statement of disbelief. Things like this seem to catch me by surprise every so often -- sometimes more often than not.
Keith
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFA 0/4] Remove TYPE_TAG_NAME
2018-04-17 19:51 [RFA 0/4] Remove TYPE_TAG_NAME Tom Tromey
` (4 preceding siblings ...)
2018-04-18 16:57 ` [RFA 0/4] Remove TYPE_TAG_NAME Keith Seitz
@ 2018-05-09 15:42 ` Tom Tromey
2018-05-25 17:30 ` Tom Tromey
5 siblings, 1 reply; 16+ messages in thread
From: Tom Tromey @ 2018-05-09 15:42 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:
Tom> As mentioned on the list, here is the series to remove TYPE_TAG_NAME.
Tom> I think each patch is relatively self-explanatory, so I won't describe
Tom> them further here.
Tom> Regression tested by the buildbot.
Ping.
Tom
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFA 0/4] Remove TYPE_TAG_NAME
2018-05-09 15:42 ` Tom Tromey
@ 2018-05-25 17:30 ` Tom Tromey
0 siblings, 0 replies; 16+ messages in thread
From: Tom Tromey @ 2018-05-25 17:30 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:
>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:
Tom> As mentioned on the list, here is the series to remove TYPE_TAG_NAME.
Tom> I think each patch is relatively self-explanatory, so I won't describe
Tom> them further here.
Tom> Regression tested by the buildbot.
Tom> Ping.
Ping.
Tom
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFA 1/4] Make c_type_print_varspec_suffix static
2018-04-17 19:51 ` [RFA 1/4] Make c_type_print_varspec_suffix static Tom Tromey
@ 2018-05-31 1:33 ` Joel Brobecker
0 siblings, 0 replies; 16+ messages in thread
From: Joel Brobecker @ 2018-05-31 1:33 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
Hi Tom,
On Tue, Apr 17, 2018 at 01:51:22PM -0600, Tom Tromey wrote:
> I noticed that c_type_print_varspec_suffix is only called from
> c-typeprint.c, so this patch makes it "static".
>
> ChangeLog
> 2018-04-17 Tom Tromey <tom@tromey.com>
>
> * typeprint.h (c_type_print_varspec_suffix): Don't declare.
> * c-typeprint.c (c_type_print_varspec_suffix): Now static.
So very sorry again for how long it's taking to review your patches.
This one is fairly clearly an improvement on its own, so approved.
--
Joel
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFA 2/4] Thread language through c_type_print_args
2018-04-17 19:51 ` [RFA 2/4] Thread language through c_type_print_args Tom Tromey
2018-04-18 17:53 ` Tom Tromey
@ 2018-05-31 1:37 ` Joel Brobecker
1 sibling, 0 replies; 16+ messages in thread
From: Joel Brobecker @ 2018-05-31 1:37 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
> Currently dwarf2read.c will pass the CU's language to
> c_type_print_args -- but this doesn't affect all aspects of type
> printing, because some code in c-typeprint.c refers to
> current_language.
>
> This patch threads the language through more of the type printing
> code, adding an overload to c_type_print. Some uses of
> current_language remain, but now they are only in top-level functions.
>
> ChangeLog
> 2018-04-17 Tom Tromey <tom@tromey.com>
>
> * dwarf2read.c (dwarf2_compute_name): Pass CU's language to
> c_print_type.
> * c-typeprint.c (c_print_type_1): Add "language" parameter.
> (c_print_type): Update.
> (c_print_type): New overload.
> (c_type_print_varspec_prefix, c_type_print_args)
> (c_type_print_varspec_suffix, c_print_type_no_offsets)
> (c_type_print_base_struct_union, c_type_print_base_1)
> (cp_type_print_method_args): Add "language" parameter.
> (c_type_print_base): Update.
> * c-lang.h (c_print_type): Add new overload.
Neat use of overloading to avoid having to manage a potentially
large number of callers all at once...
You mentioned as a follow up that you were wondering about putting
the language in struct type_print_options. I can see why it is
an option, and I wouldn't object to it, but at the moment, the
approach with adding it as a parameter feels better. I think it's
more consistent with what we've been doing before. I could be
convinced otherwise.
In the meantime, this patch is approved.
--
Joel
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFA 3/4] Remove TYPE_TAG_NAME
2018-04-17 19:51 ` [RFA 3/4] " Tom Tromey
2018-04-18 16:57 ` Keith Seitz
@ 2018-05-31 2:35 ` Joel Brobecker
1 sibling, 0 replies; 16+ messages in thread
From: Joel Brobecker @ 2018-05-31 2:35 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
> TYPE_TAG_NAME has been an occasional source of confusion and bugs. It
> seems to me that it is only useful for C and C++ -- but even there,
> not so much, because at least with DWARF there doesn't seem to be any
> way to wind up with a type where the name and the tag name are both
> non-NULL and different.
>
> So, this patch removes TYPE_TAG_NAME entirely. This should save a
> little memory, but more importantly, it simplifies this part of gdb.
>
> A few minor test suite adjustments were needed. In some situations
> the new code does not yield identical output to the old code.
>
> ChangeLog
> 2018-04-17 Tom Tromey <tom@tromey.com>
>
> * valops.c (enum_constant_from_type, value_namespace_elt)
> (value_maybe_namespace_elt): Update.
> * valarith.c (find_size_for_pointer_math): Update.
> * target-descriptions.c (make_gdb_type): Update.
> * symmisc.c (print_symbol): Update.
> * stabsread.c (define_symbol, read_type)
> (complain_about_struct_wipeout, add_undefined_type)
> (cleanup_undefined_types_1): Update.
> * rust-lang.c (rust_tuple_type_p, rust_slice_type_p)
> (rust_range_type_p, val_print_struct, rust_print_struct_def)
> (rust_internal_print_type, rust_composite_type)
> (rust_evaluate_funcall, rust_evaluate_subexp): Update.
> * python/py-type.c (typy_get_tag): Update.
> * p-typeprint.c (pascal_type_print_base): Update.
> * mdebugread.c (parse_symbol, parse_type): Update.
> * m2-typeprint.c (m2_long_set, m2_record_fields, m2_enum):
> Update.
> * guile/scm-type.c (gdbscm_type_tag): Update.
> * go-lang.c (sixg_string_p): Update.
> * gnu-v3-abi.c (build_gdb_vtable_type, build_std_type_info_type):
> Update.
> * gdbtypes.h (struct main_type) <tag_name>: Remove.
> (TYPE_TAG_NAME): Remove.
> * gdbtypes.c (type_name_no_tag): Simplify.
> (check_typedef, check_types_equal, recursive_dump_type)
> (copy_type_recursive, arch_composite_type): Update.
> * f-typeprint.c (f_type_print_base): Update. Print "Type" prefix
> in summary mode when needed.
> * eval.c (evaluate_funcall): Update.
> * dwarf2read.c (fixup_go_packaging, read_structure_type)
> (process_structure_scope, read_enumeration_type)
> (read_namespace_type, read_module_type, determine_prefix): Update.
> * cp-support.c (inspect_type): Update.
> * coffread.c (process_coff_symbol, decode_base_type): Update.
> * c-varobj.c (c_is_path_expr_parent): Update.
> * c-typeprint.c (c_type_print_base_struct_union): Update.
> (c_type_print_base_1): Update. Print struct/class/union/enum in
> summary when using C language.
> * ax-gdb.c (gen_struct_ref, gen_namespace_elt)
> (gen_maybe_namespace_elt): Update.
> * ada-lang.c (ada_type_name): Simplify.
> (empty_record, ada_template_to_fixed_record_type_1)
> (template_to_static_fixed_type)
> (to_record_with_fixed_variant_part, ada_check_typedef): Update.
>
> testsuite/ChangeLog
> 2018-04-17 Tom Tromey <tom@tromey.com>
>
> * gdb.xml/tdesc-regs.exp (load_description): Update expected
> results.
> * gdb.dwarf2/method-ptr.exp: Set language to C++.
> * gdb.dwarf2/member-ptr-forwardref.exp: Set language to C++.
> * gdb.cp/typeid.exp (do_typeid_tests): Update type_re.
> * gdb.base/maint.exp (maint_pass_if): Update.
This looks good to me. Perhaps add the comment that Keith mentioned
about the use of language_minimal in c_type_print_base_1. Sometimes,
I wonder whether we might have over-engineered that thing.
Thanks!
--
Joel
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFA 4/4] Remove type_name_no_tag and rename type_name_no_tag_or_error
2018-04-17 19:51 ` [RFA 4/4] Remove type_name_no_tag and rename type_name_no_tag_or_error Tom Tromey
@ 2018-05-31 6:22 ` Joel Brobecker
0 siblings, 0 replies; 16+ messages in thread
From: Joel Brobecker @ 2018-05-31 6:22 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
> type_name_no_tag is just a plain wrapper for TYPE_NAME now, so this
> patch removes it. And, because tag names no longer exist, this
> renames type_name_no_tag_or_error to type_name_or_error.
>
> ChangeLog
> 2018-04-17 Tom Tromey <tom@tromey.com>
>
> * valops.c (value_cast_structs, destructor_name_p): Update.
> * symtab.c (gdb_mangle_name): Update.
> * stabsread.c (define_symbol, read_cpp_abbrev, read_baseclasses):
> Update.
> * p-valprint.c (pascal_object_is_vtbl_ptr_type)
> (pascal_object_print_value_fields, pascal_object_print_value):
> Update.
> * p-typeprint.c (pascal_type_print_derivation_info): Update.
> * linespec.c (find_methods): Update.
> * gdbtypes.h (type_name_no_tag): Remove.
> (type_name_or_error): Rename from type_name_no_tag_or_error.
> * gdbtypes.c (type_name_no_tag): Remove.
> (type_name_or_error): Rename from type_name_no_tag_or_error.
> (lookup_struct_elt_type, check_typedef): Update.
> * expprint.c (print_subexp_standard): Update.
> * dwarf2read.c (dwarf2_add_field, load_partial_dies): Update.
> * d-namespace.c (d_lookup_nested_symbol): Update.
> * cp-valprint.c (cp_is_vtbl_ptr_type, cp_print_value_fields)
> (cp_print_class_member): Update.
> * cp-namespace.c (cp_lookup_nested_symbol): Update.
> * completer.c (add_struct_fields): Update.
> * c-typeprint.c (cp_type_print_derivation_info)
> (c_type_print_varspec_prefix, c_type_print_base_struct_union):
> Update.
> * ada-lang.c (parse_old_style_renaming, xget_renaming_scope)
> (ada_prefer_type, ada_is_exception_sym): Update.
Looks good, Tom! (approved)
--
Joel
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2018-05-31 1:37 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-17 19:51 [RFA 0/4] Remove TYPE_TAG_NAME Tom Tromey
2018-04-17 19:51 ` [RFA 3/4] " Tom Tromey
2018-04-18 16:57 ` Keith Seitz
2018-04-18 17:57 ` Tom Tromey
2018-04-18 18:06 ` Keith Seitz
2018-05-31 2:35 ` Joel Brobecker
2018-04-17 19:51 ` [RFA 1/4] Make c_type_print_varspec_suffix static Tom Tromey
2018-05-31 1:33 ` Joel Brobecker
2018-04-17 19:51 ` [RFA 4/4] Remove type_name_no_tag and rename type_name_no_tag_or_error Tom Tromey
2018-05-31 6:22 ` Joel Brobecker
2018-04-17 19:51 ` [RFA 2/4] Thread language through c_type_print_args Tom Tromey
2018-04-18 17:53 ` Tom Tromey
2018-05-31 1:37 ` Joel Brobecker
2018-04-18 16:57 ` [RFA 0/4] Remove TYPE_TAG_NAME Keith Seitz
2018-05-09 15:42 ` Tom Tromey
2018-05-25 17:30 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).