From a737d952e0a9122dd0d439ba2a2ca531b070e6bd Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 17 Apr 2018 13:51:25 -0600 Subject: [PATCH] Remove type_name_no_tag and rename type_name_no_tag_or_error 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. gdb/ChangeLog 2018-06-01 Tom Tromey * 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/ChangeLog b/gdb/ChangeLog index 7caa3aff52..01f4c009b2 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,32 @@ +2018-06-01 Tom Tromey + + * 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. + 2018-06-01 Tom Tromey * valops.c (enum_constant_from_type, value_namespace_elt) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index ceabf64c31..7d66a9ac55 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; @@ -5189,7 +5189,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; @@ -8101,8 +8101,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)) @@ -13411,7 +13411,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 6141950afe..d7eaa5433d 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 @@ -1380,7 +1379,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 b8e681b79a..1cabfbb0d4 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -15034,7 +15034,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) { @@ -18224,7 +18224,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 70d355d369..d6ed41253e 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 ecf70d7b44..fdd28c0886 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 : "", @@ -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 1399b8efc1..14059ab3dc 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -1867,9 +1867,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 a60f2742db..30a03d1547 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 *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 68feabdebc..ed4a3d3181 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -1245,7 +1245,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) @@ -2782,7 +2782,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 = ""; @@ -2792,7 +2792,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 (_("C++ abbreviated type name " @@ -3196,7 +3196,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 e1f033d1d8..20bc178db4 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 ed8019c62c..d147cda59c 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.34.1