From: Keith Seitz Date: Fri, 5 May 2017 21:21:23 +0000 (-0700) Subject: Some precursor patch cleanups. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b41eded511629d46c68c26efc3bf6a91e7cd5db7;p=thirdparty%2Fbinutils-gdb.git Some precursor patch cleanups. For dw2_linkage_name{,_attr} and conversion-operators [on c++compile-submit]. --- diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 0b5fc536bc5..a7509dabb7c 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -1563,10 +1563,10 @@ oper: OPERATOR NEW &type_print_raw_options); /* This also needs canonicalization. */ - const char *name = buf.c_str (); - std::string canon = cp_canonicalize_string (name); + std::string canon + = cp_canonicalize_string (buf.c_str ()); if (canon.empty ()) - canon = name; + canon = std::move (buf.string ()); /* We need a space between "operator" and the canonicalized type name. */ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index a9d794c8624..276ed0d6a53 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -8606,6 +8606,22 @@ die_needs_namespace (struct die_info *die, struct dwarf2_cu *cu) or DW_AT_MIPS_linkage_name. Returns NULL if the attribute is not defined for the given DIE. */ +static struct attribute * +dw2_linkage_name_attr (struct die_info *die, struct dwarf2_cu *cu) +{ + struct attribute *attr; + + attr = dwarf2_attr (die, DW_AT_linkage_name, cu); + if (attr == NULL) + attr = dwarf2_attr (die, DW_AT_MIPS_linkage_name, cu); + + return attr; +} + +/* Return the DIE's linkage name as a string, either DW_AT_linkage_name + or DW_AT_MIPS_linkage_name. Returns NULL if the attribute is not + defined for the given DIE. */ + static const char * dw2_linkage_name (struct die_info *die, struct dwarf2_cu *cu) { @@ -13607,8 +13623,8 @@ new_fn_field (struct die_info *name_die, struct dwarf2_cu *name_cu, { complaint (&symfile_complaints, _("cannot determine context for virtual member " - "function \"%s\" (offset %d)"), fieldname, - to_underlying (type_die->sect_off)); + "function \"%s\" (offset %d)"), + fieldname, to_underlying (type_die->sect_off)); } else { @@ -13757,7 +13773,7 @@ dwarf2_attach_fn_fields_to_type (struct field_info *fip, struct type *type, /* Returns non-zero if NAME is the name of a vtable member in CU's language, zero otherwise. */ static int -dw2_is_vtable_name (const char *name, struct dwarf2_cu *cu) +is_vtable_name (const char *name, struct dwarf2_cu *cu) { static const char vptr[] = "_vptr"; static const char vtable[] = "vtable"; @@ -14107,7 +14123,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu) { const char *fieldname = TYPE_FIELD_NAME (t, i); - if (dw2_is_vtable_name (fieldname, cu)) + if (is_vtable_name (fieldname, cu)) { set_type_vptr_fieldno (type, i); break; @@ -20527,10 +20543,7 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu) { char *demangled = NULL; - attr = dwarf2_attr (die, DW_AT_linkage_name, cu); - if (attr == NULL) - attr = dwarf2_attr (die, DW_AT_MIPS_linkage_name, cu); - + attr = dw2_linkage_name_attr (die, cu); if (attr == NULL || DW_STRING (attr) == NULL) return NULL; diff --git a/gdb/testsuite/gdb.cp/cpexprs.cc b/gdb/testsuite/gdb.cp/cpexprs.cc index f70fd51603c..a2364ebe91d 100644 --- a/gdb/testsuite/gdb.cp/cpexprs.cc +++ b/gdb/testsuite/gdb.cp/cpexprs.cc @@ -270,6 +270,7 @@ public: operator int () const { return 21; } // base::operator int operator fluff* () const { return new fluff (); } // base::operator fluff* operator fluff** () const { return &g_fluff; } // base::operator fluff** + operator fluff const* const* () const { return &g_fluff; } // base::operator fluff const* const* }; class base1 : public virtual base @@ -448,6 +449,7 @@ test_function (int argc, char* argv[]) // test_function char* str = a; fluff* flp = a; fluff** flpp = a; + fluff const* const* flcpcp = a; CV_f(CV::i); diff --git a/gdb/testsuite/gdb.cp/cpexprs.exp b/gdb/testsuite/gdb.cp/cpexprs.exp index d0f41b2d8e3..463e89c12cd 100644 --- a/gdb/testsuite/gdb.cp/cpexprs.exp +++ b/gdb/testsuite/gdb.cp/cpexprs.exp @@ -407,6 +407,10 @@ add {base::operator int} \ {int (const base * const)} \ - \ - +add {base::operator fluff const* const*} \ + {const fluff * const *(const base * const)} \ + - \ + - # Templates add {tclass::do_something} \ @@ -746,5 +750,17 @@ gdb_test "p CV_f(CV::i)" " = 43" gdb_test "p CV_f('cpexprs.cc'::CV::t)" \ { = {int \(int\)} 0x[0-9a-f]+ } +# Make sure conversion operator names are canonicalized and properly +# "spelled." +gdb_test "p base::operator const fluff * const *" \ + [get "base::operator fluff const* const*" print] \ + "canonicalized conversion operator name 1" +gdb_test "p base::operator const fluff* const*" \ + [get "base::operator fluff const* const*" print] \ + "canonicalized conversion operator name 2" +gdb_test "p base::operator derived*" \ + "There is no field named operator derived\\*" \ + "undefined conversion operator" + gdb_exit return 0