From: Keith Seitz Date: Thu, 9 Feb 2017 23:02:03 +0000 (-0800) Subject: More patch separation cleanups. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0437d963daddf39155e131595444cf753e3cf4b3;p=thirdparty%2Fbinutils-gdb.git More patch separation cleanups. --- diff --git a/gdb/c-lang.c b/gdb/c-lang.c index b82b7bf19ed..1d69338f5aa 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -729,16 +729,15 @@ evaluate_subexp_c (struct type *expect_type, struct expression *exp, static unsigned int cplus_compute_string_hash (const char *string0) { - const char *p, *last_scope; - /* If '<' doesn't appear at all in STRING), there is no way we could be dealing with a template name. */ if (find_toplevel_char (string0, '<') == NULL) return default_compute_string_hash (string0); /* Locate the last qualified component of STRING0. */ - p = find_toplevel_string (string0, "::"); - last_scope = NULL; + const char *p = find_toplevel_string (string0, "::"); + const char *last_scope = NULL; + while (p != NULL) { last_scope = p; @@ -758,7 +757,7 @@ cplus_compute_string_hash (const char *string0) and not be a template at all. */ if ((p - last_scope) > 8 && strncmp (p - 8, "operator", 8) == 0) { - /* Skip <,= */ + /* Skip <,=. */ while (strchr ("<=", *p) != NULL) ++p; @@ -770,19 +769,13 @@ cplus_compute_string_hash (const char *string0) a template function itself. */ if (p == NULL) return default_compute_string_hash (string0); - else - { - unsigned int hash; - char *copy = ASTRDUP (string0); - copy[p - string0] = '\0'; + char *copy = ASTRDUP (string0); - /* It *is a template, compute the hash based only until P. */ - hash = default_compute_string_hash (copy); - /* !!keiths: Probably should snarf dict_hash/minsym_hash_iw - and do this by length. What about cp_entire_prefix_len? */ - return hash; - } + copy[p - string0] = '\0'; + + /* It is a template, compute the hash based only until P. */ + return default_compute_string_hash (copy); } diff --git a/gdb/c-lang.h b/gdb/c-lang.h index 508a5461f2f..6fdcaa4f90b 100644 --- a/gdb/c-lang.h +++ b/gdb/c-lang.h @@ -150,7 +150,7 @@ extern int c_textual_element_type (struct type *, char); exception on failure. This is suitable for use as the la_get_compile_instance language method. */ -extern struct compile_instance *c_get_compile_context (void); +extern compile::compile_instance *c_get_compile_context (void); /* Create a new instance of the C++ compiler and return it. The new compiler is owned by the caller and must be freed using the destroy @@ -158,7 +158,7 @@ extern struct compile_instance *c_get_compile_context (void); exception on failure. This is suitable for use as the la_get_compile_instance language method. */ -extern struct compile_instance *cplus_get_compile_context (void); +extern compile::compile_instance *cplus_get_compile_context (void); /* This takes the user-supplied text and returns a new bit of code to compile. @@ -166,7 +166,7 @@ extern struct compile_instance *cplus_get_compile_context (void); This is used as the la_compute_program language method; see that for a description of the arguments. */ -extern std::string c_compute_program (struct compile_instance *inst, +extern std::string c_compute_program (compile::compile_instance *inst, const char *input, struct gdbarch *gdbarch, const struct block *expr_block, @@ -177,7 +177,7 @@ extern std::string c_compute_program (struct compile_instance *inst, This is used as the la_compute_program language method; see that for a description of the arguments. */ -extern std::string cplus_compute_program (struct compile_instance *inst, +extern std::string cplus_compute_program (compile::compile_instance *inst, const char *input, struct gdbarch *gdbarch, const struct block *expr_block, diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index f2042f940ae..5c8e0a024ef 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -1164,9 +1164,9 @@ c_type_print_base (struct type *type, struct ui_file *stream, || is_destructor_name (physname) || method_name[0] == '~'; - /* Do not print out artificial or "duplicate" methods. */ + /* Do not print out artificial or alias methods. */ if (TYPE_FN_FIELD_ARTIFICIAL (f, j) - || TYPE_FN_FIELD_DUPLICATE (f, j)) + || TYPE_FN_FIELD_ALIAS (f, j)) continue; inner_cleanup = make_cleanup (null_cleanup, NULL); diff --git a/gdb/compile/compile-c-support.c b/gdb/compile/compile-c-support.c index e823d3d7b58..02421f054d5 100644 --- a/gdb/compile/compile-c-support.c +++ b/gdb/compile/compile-c-support.c @@ -95,7 +95,7 @@ load_libcompile (const char *fe_libcc, const char *fe_context) template -struct compile_instance * +compile::compile_instance * get_compile_context (const char *fe_libcc, const char *fe_context, BASE_VERSION_TYPE base_version, API_VERSION_TYPE api_version) @@ -119,9 +119,11 @@ get_compile_context (const char *fe_libcc, const char *fe_context, /* A C-language implementation of get_compile_context. */ -struct compile_instance * +compile::compile_instance * c_get_compile_context (void) { + using namespace compile; + return get_compile_context @@ -131,7 +133,7 @@ c_get_compile_context (void) /* A C++-language implementation of get_compile_context. */ -struct compile_instance * +compile::compile_instance * cplus_get_compile_context (void) { using namespace compile; @@ -199,7 +201,6 @@ write_macro_definitions (const struct block *block, CORE_ADDR pc, macro_for_each_in_scope (scope->file, scope->line, print_one_macro, file); } - /* Generate a structure holding all the registers used by the function we're generating. */ @@ -207,13 +208,14 @@ static void generate_register_struct (struct ui_file *stream, struct gdbarch *gdbarch, const unsigned char *registers_used) { + int i; int seen = 0; fputs_unfiltered ("struct " COMPILE_I_SIMPLE_REGISTER_STRUCT_TAG " {\n", stream); if (registers_used != NULL) - for (int i = 0; i < gdbarch_num_regs (gdbarch); ++i) + for (i = 0; i < gdbarch_num_regs (gdbarch); ++i) { if (registers_used[i]) { @@ -648,7 +650,7 @@ private: /* The types used for C and C++ program computations. */ -typedef compile_program c_compile_program; @@ -661,12 +663,14 @@ typedef compile_program (inst); c_compile_program program (c_inst, gdbarch); @@ -676,7 +680,7 @@ c_compute_program (struct compile_instance *inst, /* The la_compute_program method for C++. */ std::string -cplus_compute_program (struct compile_instance *inst, +cplus_compute_program (compile::compile_instance *inst, const char *input, struct gdbarch *gdbarch, const struct block *expr_block, diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c index 9c0a918c89e..e5023af7281 100644 --- a/gdb/compile/compile-c-symbols.c +++ b/gdb/compile/compile-c-symbols.c @@ -33,6 +33,8 @@ +using namespace compile; + /* See description in compile-c.h. */ char * @@ -49,7 +51,7 @@ c_symbol_substitution_name (struct symbol *sym) scope.) */ static void -convert_one_symbol (struct compile_c_instance *context, +convert_one_symbol (compile_c_instance *context, struct block_symbol sym, int is_global, int is_local) @@ -209,7 +211,7 @@ convert_one_symbol (struct compile_c_instance *context, itself, and DOMAIN is the domain which was searched. */ static void -convert_symbol_sym (struct compile_c_instance *context, const char *identifier, +convert_symbol_sym (compile_c_instance *context, const char *identifier, struct block_symbol sym, domain_enum domain) { const struct block *static_block; @@ -259,7 +261,7 @@ convert_symbol_sym (struct compile_c_instance *context, const char *identifier, to use and BMSYM is the minimal symbol to convert. */ static void -convert_symbol_bmsym (struct compile_c_instance *context, +convert_symbol_bmsym (compile_c_instance *context, struct bound_minimal_symbol bmsym) { struct minimal_symbol *msym = bmsym.minsym; @@ -323,7 +325,7 @@ gcc_convert_symbol (void *datum, enum gcc_c_oracle_request request, const char *identifier) { - struct compile_c_instance *context = (struct compile_c_instance *) datum; + compile_c_instance *context = static_cast (datum); domain_enum domain; int found = 0; @@ -386,7 +388,7 @@ gcc_address gcc_symbol_address (void *datum, struct gcc_c_context *gcc_context, const char *identifier) { - struct compile_c_instance *context = (struct compile_c_instance *) datum; + compile_c_instance *context = static_cast (datum); gcc_address result = 0; int found = 0; diff --git a/gdb/compile/compile-c-types.c b/gdb/compile/compile-c-types.c index b8034245288..47a1925b1ac 100644 --- a/gdb/compile/compile-c-types.c +++ b/gdb/compile/compile-c-types.c @@ -23,10 +23,12 @@ #include "compile-internal.h" #include "compile-c.h" +using namespace compile; + /* Convert a pointer type to its gcc representation. */ static gcc_type -convert_pointer (struct compile_c_instance *context, struct type *type) +convert_pointer (compile_c_instance *context, struct type *type) { gcc_type target = context->convert_type (TYPE_TARGET_TYPE (type)); @@ -36,7 +38,7 @@ convert_pointer (struct compile_c_instance *context, struct type *type) /* Convert an array type to its gcc representation. */ static gcc_type -convert_array (struct compile_c_instance *context, struct type *type) +convert_array (compile_c_instance *context, struct type *type) { gcc_type element_type; struct type *range = TYPE_INDEX_TYPE (type); @@ -86,7 +88,7 @@ convert_array (struct compile_c_instance *context, struct type *type) /* Convert a struct or union type to its gcc representation. */ static gcc_type -convert_struct_or_union (struct compile_c_instance *context, struct type *type) +convert_struct_or_union (compile_c_instance *context, struct type *type) { int i; gcc_type result; @@ -122,7 +124,7 @@ convert_struct_or_union (struct compile_c_instance *context, struct type *type) /* Convert an enum type to its gcc representation. */ static gcc_type -convert_enum (struct compile_c_instance *context, struct type *type) +convert_enum (compile_c_instance *context, struct type *type) { gcc_type int_type, result; int i; @@ -148,7 +150,7 @@ convert_enum (struct compile_c_instance *context, struct type *type) /* Convert a function type to its gcc representation. */ static gcc_type -convert_func (struct compile_c_instance *context, struct type *type) +convert_func (compile_c_instance *context, struct type *type) { int i; gcc_type result, return_type; @@ -173,7 +175,7 @@ convert_func (struct compile_c_instance *context, struct type *type) /* Convert an integer type to its gcc representation. */ static gcc_type -convert_int (struct compile_c_instance *context, struct type *type) +convert_int (compile_c_instance *context, struct type *type) { if (context->c_version () >= GCC_C_FE_VERSION_1) { @@ -192,7 +194,7 @@ convert_int (struct compile_c_instance *context, struct type *type) /* Convert a floating-point type to its gcc representation. */ static gcc_type -convert_float (struct compile_c_instance *context, struct type *type) +convert_float (compile_c_instance *context, struct type *type) { if (context->c_version () >= GCC_C_FE_VERSION_1) return context->float_type (TYPE_LENGTH (type), TYPE_NAME (type)); @@ -203,7 +205,7 @@ convert_float (struct compile_c_instance *context, struct type *type) /* Convert the 'void' type to its gcc representation. */ static gcc_type -convert_void (struct compile_c_instance *context, struct type *type) +convert_void (compile_c_instance *context, struct type *type) { return context->void_type (); } @@ -211,7 +213,7 @@ convert_void (struct compile_c_instance *context, struct type *type) /* Convert a boolean type to its gcc representation. */ static gcc_type -convert_bool (struct compile_c_instance *context, struct type *type) +convert_bool (compile_c_instance *context, struct type *type) { return context->bool_type (); } @@ -219,7 +221,7 @@ convert_bool (struct compile_c_instance *context, struct type *type) /* Convert a qualified type to its gcc representation. */ static gcc_type -convert_qualified (struct compile_c_instance *context, struct type *type) +convert_qualified (compile_c_instance *context, struct type *type) { struct type *unqual = make_unqualified_type (type); gcc_type unqual_converted; @@ -240,7 +242,7 @@ convert_qualified (struct compile_c_instance *context, struct type *type) /* Convert a complex type to its gcc representation. */ static gcc_type -convert_complex (struct compile_c_instance *context, struct type *type) +convert_complex (compile_c_instance *context, struct type *type) { gcc_type base = context->convert_type (TYPE_TARGET_TYPE (type)); @@ -253,7 +255,7 @@ convert_complex (struct compile_c_instance *context, struct type *type) returns the gcc type. */ static gcc_type -convert_type_basic (struct compile_c_instance *context, struct type *type) +convert_type_basic (compile_c_instance *context, struct type *type) { /* If we are converting a qualified type, first convert the unqualified type and then apply the qualifiers. */ @@ -299,6 +301,15 @@ convert_type_basic (struct compile_c_instance *context, struct type *type) return context->error (_("cannot convert gdb type to gcc type")); } +/* Default compile flags for C. */ + +const char *compile_c_instance::m_default_cflags = "-std=gnu11" + /* Otherwise the .o file may need + "_Unwind_Resume" and + "__gcc_personality_v0". */ + " -fno-exceptions" + " -Wno-implicit-function-declaration"; + gcc_type compile_c_instance::convert_type (struct type *type) { diff --git a/gdb/compile/compile-c.h b/gdb/compile/compile-c.h index a7024116757..fd2b380c057 100644 --- a/gdb/compile/compile-c.h +++ b/gdb/compile/compile-c.h @@ -30,118 +30,118 @@ extern gcc_c_oracle_function gcc_convert_symbol; extern gcc_c_symbol_address_function gcc_symbol_address; -/* A subclass of compile_instance that is specific to the C front - end. */ - -class compile_c_instance - : public compile_instance +namespace compile { - public: - compile_c_instance (struct gcc_base_context *base, const char *options) - : compile_instance (base, options) + /* A subclass of compile_instance that is specific to the C front + end. */ + + class compile_c_instance + : public compile_instance + { + public: + + compile_c_instance (struct gcc_base_context *base, const char *options) + : compile_instance (base, options) { } - explicit compile_c_instance (struct gcc_c_context *gcc_c) - : compile_instance (&gcc_c->base, - "-std=gnu11" - /* Otherwise the .o file may need - "_Unwind_Resume" and - "__gcc_personality_v0". */ - " -fno-exceptions" - " -Wno-implicit-function-declaration"), - m_context (gcc_c) - { - m_context->c_ops->set_callbacks (m_context, gcc_convert_symbol, - gcc_symbol_address, this); - } + explicit compile_c_instance (struct gcc_c_context *gcc_c) + : compile_instance (&gcc_c->base, m_default_cflags), m_context (gcc_c) + { + m_context->c_ops->set_callbacks (m_context, gcc_convert_symbol, + gcc_symbol_address, this); + } - ~compile_c_instance () + ~compile_c_instance () { m_gcc_fe->ops->destroy (m_gcc_fe); } - /* Convert a gdb type, TYPE, to a GCC type. + /* Convert a gdb type, TYPE, to a GCC type. + + The new GCC type is returned. */ - The new GCC type is returned. */ + gcc_type convert_type (struct type *type); - gcc_type convert_type (struct type *type); + /* Plug-in forwards */ - /* Plug-in forwards */ + unsigned int c_version () const; - unsigned int c_version () const; + bool tagbind (const char *name, gcc_type tagged_type, const char *filename, + unsigned int line_number); - bool tagbind (const char *name, gcc_type tagged_type, const char *filename, - unsigned int line_number); + bool build_constant (gcc_type type, const char *name, unsigned long value, + const char *filename, unsigned int line_number); - bool build_constant (gcc_type type, const char *name, unsigned long value, - const char *filename, unsigned int line_number); + gcc_decl build_decl (const char *name, enum gcc_c_symbol_kind sym_kind, + gcc_type sym_type, const char *substitution_name, + gcc_address address, const char *filename, + unsigned int line_number); - gcc_decl build_decl (const char *name, enum gcc_c_symbol_kind sym_kind, - gcc_type sym_type, const char *substitution_name, - gcc_address address, const char *filename, - unsigned int line_number); + bool bind (gcc_decl decl, bool is_global); - bool bind (gcc_decl decl, bool is_global); + gcc_type error (const char *message); - gcc_type error (const char *message); + gcc_type build_pointer_type (gcc_type base_type); - gcc_type build_pointer_type (gcc_type base_type); + gcc_type build_vla_array_type (gcc_type element_type, + const char *upper_bound_name); - gcc_type build_vla_array_type (gcc_type element_type, - const char *upper_bound_name); + gcc_type build_vector_type (gcc_type element_type, int num_elements); - gcc_type build_vector_type (gcc_type element_type, int num_elements); + gcc_type build_array_type (gcc_type element_type, int num_elements); - gcc_type build_array_type (gcc_type element_type, int num_elements); + gcc_type build_record_type (); - gcc_type build_record_type (); + gcc_type build_union_type (); - gcc_type build_union_type (); + bool build_add_field (gcc_type record_or_union_type, const char *field_name, + gcc_type field_type, unsigned long bitsize, + unsigned long bitpos); - bool build_add_field (gcc_type record_or_union_type, const char *field_name, - gcc_type field_type, unsigned long bitsize, - unsigned long bitpos); + bool finish_record_or_union (gcc_type record_or_union_type, + unsigned long size_in_bytes); - bool finish_record_or_union (gcc_type record_or_union_type, - unsigned long size_in_bytes); + gcc_type int_type (bool is_unsigned, unsigned long size_in_bytes, + const char *builtin_name); - gcc_type int_type (bool is_unsigned, unsigned long size_in_bytes, - const char *builtin_name); + gcc_type int_type (bool is_unsigned, unsigned long size_in_bytes); - gcc_type int_type (bool is_unsigned, unsigned long size_in_bytes); + gcc_type build_enum_type (gcc_type underlying_int_type); - gcc_type build_enum_type (gcc_type underlying_int_type); + bool build_add_enum_constant (gcc_type enum_type, const char *name, + unsigned long value); - bool build_add_enum_constant (gcc_type enum_type, const char *name, - unsigned long value); + bool finish_enum_type (gcc_type enum_type); - bool finish_enum_type (gcc_type enum_type); + gcc_type build_function_type (gcc_type return_value, + const struct gcc_type_array *argument_types, + bool is_varargs); - gcc_type build_function_type (gcc_type return_value, - const struct gcc_type_array *argument_types, - bool is_varargs); + gcc_type char_type (); - gcc_type char_type (); + gcc_type float_type (unsigned long size_in_bytes, const char *builtin_name); - gcc_type float_type (unsigned long size_in_bytes, const char *builtin_name); + gcc_type float_type (unsigned long size_in_bytes); - gcc_type float_type (unsigned long size_in_bytes); + gcc_type void_type (); - gcc_type void_type (); + gcc_type bool_type (); - gcc_type bool_type (); + gcc_type build_qualified_type (gcc_type unqualified_type, + enum gcc_qualifiers qualifiers); - gcc_type build_qualified_type (gcc_type unqualified_type, - enum gcc_qualifiers qualifiers); + gcc_type build_complex_type (gcc_type element_type); - gcc_type build_complex_type (gcc_type element_type); + private: -private: + /* Default compiler flags for C. */ + static const char *m_default_cflags; - /* The GCC C context. */ - struct gcc_c_context *m_context; + /* The GCC C context. */ + struct gcc_c_context *m_context; + }; }; /* Emit code to compute the address for all the local variables in @@ -150,7 +150,7 @@ private: register is needed to compute a local variable. */ extern unsigned char *generate_c_for_variable_locations - (compile_instance *compiler, + (compile::compile_instance *compiler, string_file &stream, struct gdbarch *gdbarch, const struct block *block, diff --git a/gdb/compile/compile-cplus-templates.c b/gdb/compile/compile-cplus-templates.c index d4a1d37c5b2..4b2bf46baae 100644 --- a/gdb/compile/compile-cplus-templates.c +++ b/gdb/compile/compile-cplus-templates.c @@ -178,7 +178,7 @@ void compile_cplus_instance::maybe_define_new_function_template (const struct symbol *sym, struct type *parent_type, int f_idx, int m_idx) - + { if (sym != NULL && SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION (sym)) { diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c index ce1b9399720..52655246199 100644 --- a/gdb/compile/compile-cplus-types.c +++ b/gdb/compile/compile-cplus-types.c @@ -888,7 +888,7 @@ compile::maybe_canonicalize_special_function *ignore = true; return field_name; /* C? */ - case unknown_ctor: + case not_ctor: #if DEBUG_XTOR printf ("unknown_ctr -- ignored\n"); #endif @@ -944,9 +944,9 @@ compile::maybe_canonicalize_special_function *ignore = true; return field_name; /* D? */ - case unknown_dtor: + case not_dtor: #if DEBUG_XTOR - printf ("unknown_dtor -- ignored\n"); + printf ("not_dtor -- ignored\n"); #endif *ignore = true; return field_name; /* unknown */ @@ -1755,14 +1755,17 @@ compile_cplus_instance::convert_type (struct type *type, +/* Default compile flags for C++. */ + +const char *compile_cplus_instance::m_default_cflags = "-std=gnu++11"; + /* See compile-cplus.h. */ compile_cplus_instance::compile_cplus_instance (struct gcc_cp_context *gcc_fe) - : compile_instance (&gcc_fe->base, - "-std=gnu++11"), - m_context (gcc_fe), - m_function_template_defns (new function_template_defn_map_t ()), - m_class_template_defns (new class_template_defn_map_t ()) + : compile_instance (&gcc_fe->base, m_default_cflags), + m_context (gcc_fe), + m_function_template_defns (new function_template_defn_map_t ()), + m_class_template_defns (new class_template_defn_map_t ()) { gcc_fe->cp_ops->set_callbacks (gcc_fe, gcc_cplus_convert_symbol, gcc_cplus_symbol_address, diff --git a/gdb/compile/compile-cplus.h b/gdb/compile/compile-cplus.h index f9d2fef8ff6..2ab31fe1634 100644 --- a/gdb/compile/compile-cplus.h +++ b/gdb/compile/compile-cplus.h @@ -192,8 +192,7 @@ namespace compile void leave_scope (); - /* !!keiths: YUCK! - Plug-in forwards */ + /* Plug-in forwards */ gcc_type get_bool_type (); @@ -237,7 +236,8 @@ namespace compile bool finish_enum_type (gcc_type enum_type); - /* NAME for debugging */ + /* NAME is for debugging only. */ + bool finish_class_type (const char *name, unsigned long size_in_bytes); gcc_type get_float_type (unsigned long size_in_bytes, @@ -248,7 +248,8 @@ namespace compile gcc_expr build_literal_expr (gcc_type type, unsigned long value); - /* DECL_DESC for debugging only */ + /* DECL_DESC is for debugging only. */ + gcc_decl build_decl (const char *decl_desc, const char *name, enum gcc_cp_symbol_kind sym_kind, gcc_type sym_type, const char *substitution_name, @@ -269,7 +270,8 @@ namespace compile const char *filename, unsigned int line_number); - /* NAME is for debugging only */ + /* NAME is for debugging only. */ + bool pop_binding_level (const char *name); bool push_namespace (const char *name); @@ -282,7 +284,8 @@ namespace compile (struct template_symbol *concrete, gcc_address address, const char *filename, unsigned int line_number); - /* NAME only for debugging */ + /* NAME is for debugging only. */ + gcc_type start_class_type (const char *name, gcc_decl typedecl, const struct gcc_vbase_array *base_classes, const char *filename, @@ -294,7 +297,8 @@ namespace compile const char *filename, unsigned int line_number); - /* GENERIC only for debugging */ + /* GENERIC is for debugging only. */ + bool start_template_decl (const char *generic); gcc_type get_void_type (); @@ -302,6 +306,9 @@ namespace compile private: + /* Default compiler flags for C++. */ + static const char *m_default_cflags; + /* Enumerate the template arguments of template DEFN into DEST. */ void enumerate_template_arguments diff --git a/gdb/compile/compile-internal.h b/gdb/compile/compile-internal.h index d883a46f944..71522827c68 100644 --- a/gdb/compile/compile-internal.h +++ b/gdb/compile/compile-internal.h @@ -19,7 +19,6 @@ #include "defs.h" #include "gcc-c-interface.h" -#include "compile-internal.h" #include #include @@ -34,147 +33,150 @@ extern int debug_compile_oracle; struct block; -/* An object of this type holds state associated with a given - compilation job. */ - -class compile_instance +namespace compile { -public: + /* An object of this type holds state associated with a given + compilation job. */ - compile_instance (struct gcc_base_context *gcc_fe, const char *options) - : m_gcc_fe (gcc_fe), m_gcc_target_options (options) + class compile_instance { - } + public: - virtual ~compile_instance () - { - } + compile_instance (struct gcc_base_context *gcc_fe, const char *options) + : m_gcc_fe (gcc_fe), m_gcc_target_options (options) + { + } - /* Returns the GCC options to be passed during compilation. */ + virtual ~compile_instance () + { + } - const std::string &gcc_target_options () const - { - return m_gcc_target_options; - } + /* Returns the GCC options to be passed during compilation. */ - /* Insert GCC_TYPE into the type cache for TYPE. + const std::string &gcc_target_options () const + { + return m_gcc_target_options; + } - It is ok for a given type to be inserted more than once, provided that - the exact same association is made each time. */ + /* Insert GCC_TYPE into the type cache for TYPE. - void insert_type (struct type *type, gcc_type gcc_type); + It is ok for a given type to be inserted more than once, provided that + the exact same association is made each time. */ - /* Associate SYMBOL with some error text. */ + void insert_type (struct type *type, gcc_type gcc_type); - void insert_symbol_error (const struct symbol *sym, std::string text); + /* Associate SYMBOL with some error text. */ - /* Emit the error message corresponding to SYM, if one exists, and - arrange for it not to be emitted again. */ + void insert_symbol_error (const struct symbol *sym, std::string text); - void error_symbol_once (const struct symbol *sym); + /* Emit the error message corresponding to SYM, if one exists, and + arrange for it not to be emitted again. */ - /* These currently just forward to the underlying ops - vtable. */ + void error_symbol_once (const struct symbol *sym); - /* Set the plug-in print callback. */ + /* These currently just forward to the underlying ops + vtable. */ - void set_print_callback (void (*print_function) (void *, const char *), - void *datum); + /* Set the plug-in print callback. */ - /* Return the plug-in's front-end version. */ + void set_print_callback (void (*print_function) (void *, const char *), + void *datum); - unsigned int version () const; + /* Return the plug-in's front-end version. */ - /* Set the plug-in's verbosity level. */ + unsigned int version () const; - void set_verbose (int level); + /* Set the plug-in's verbosity level. */ - /* Set the plug-in driver program. */ + void set_verbose (int level); - void set_driver_filename (const char *filename); + /* Set the plug-in driver program. */ - /* Set the regular expression used to match the configury triplet - prefix to the compiler. */ + void set_driver_filename (const char *filename); - void set_triplet_regexp (const char *regexp); + /* Set the regular expression used to match the configury triplet + prefix to the compiler. */ - /* Set compilation arguments. */ + void set_triplet_regexp (const char *regexp); - char *set_arguments (int argc, char **argv); + /* Set compilation arguments. */ - /* !!keiths: YUCK! */ + char *set_arguments (int argc, char **argv); - char *set_arguments (const char *regexp, int argc, char **argv); + /* As above for protocol version 0. */ - /* Set the filename of the program to compile. */ + char *set_arguments (const char *regexp, int argc, char **argv); - void set_source_file (const char *filename); + /* Set the filename of the program to compile. */ - /* Compile the previously specified source file to FILENAME. */ + void set_source_file (const char *filename); - bool compile (const char *filename); + /* Compile the previously specified source file to FILENAME. */ - /* Same as above, but for earlier protocol versions. */ + bool compile (const char *filename); - bool compile (const char *filename, int verbose_level); + /* Same as above, but for earlier protocol versions. */ - /* Set the scope type for this compile. */ + bool compile (const char *filename, int verbose_level); - void set_scope (enum compile_i_scope_types scope) - { - m_scope = scope; - } + /* Set the scope type for this compile. */ - /* Return the scope type. */ + void set_scope (enum compile_i_scope_types scope) + { + m_scope = scope; + } - enum compile_i_scope_types scope () const - { - return m_scope; - } + /* Return the scope type. */ - /* Set the block to be used for symbol searches. */ + enum compile_i_scope_types scope () const + { + return m_scope; + } - void set_block (const struct block *block) - { - m_block = block; - } + /* Set the block to be used for symbol searches. */ - /* Return the search block. */ + void set_block (const struct block *block) + { + m_block = block; + } - const struct block *block () const - { - return m_block; - } + /* Return the search block. */ + + const struct block *block () const + { + return m_block; + } -protected: + protected: - /* Map types used by the compile instance for caching type conversions. - and error tracking. */ + /* Map types used by the compile instance for caching type conversions. + and error tracking. */ - typedef std::pair type_map_item_t; - typedef std::unordered_map type_map_t; - typedef std::pair symbol_err_map_item_t; - typedef std::unordered_map + typedef std::pair type_map_item_t; + typedef std::unordered_map type_map_t; + typedef std::pair symbol_err_map_item_t; + typedef std::unordered_map symbol_err_map_t; - /* The GCC front end. */ - struct gcc_base_context *m_gcc_fe; + /* The GCC front end. */ + struct gcc_base_context *m_gcc_fe; - /* The "scope" of this compilation. */ - enum compile_i_scope_types m_scope; + /* The "scope" of this compilation. */ + enum compile_i_scope_types m_scope; - /* The block in which an expression is being parsed. */ - const struct block *m_block; + /* The block in which an expression is being parsed. */ + const struct block *m_block; - /* Specify "-std=gnu11", "-std=gnu++11" or similar. These options are put - after CU's DW_AT_producer compilation options to override them. */ - std::string m_gcc_target_options; + /* Specify "-std=gnu11", "-std=gnu++11" or similar. These options are put + after CU's DW_AT_producer compilation options to override them. */ + std::string m_gcc_target_options; - /* Map from gdb types to gcc types. */ - type_map_t m_type_map; + /* Map from gdb types to gcc types. */ + type_map_t m_type_map; - /* Map from gdb symbols to gcc error messages to emit. */ - symbol_err_map_t m_symbol_err_map; + /* Map from gdb symbols to gcc error messages to emit. */ + symbol_err_map_t m_symbol_err_map; + }; }; /* Define the headers and footers for different scopes. */ diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c index 23c68c9e0f8..a0a5d73de87 100644 --- a/gdb/compile/compile.c +++ b/gdb/compile/compile.c @@ -420,8 +420,8 @@ filter_args (int *argcp, char **argv) generated above. */ static void -get_args (const struct compile_instance *compiler, struct gdbarch *gdbarch, - int *argcp, char ***argvp) +get_args (const compile::compile_instance *compiler, + struct gdbarch *gdbarch, int *argcp, char ***argvp) { const char *cs_producer_options; int argc_compiler; @@ -455,7 +455,8 @@ get_args (const struct compile_instance *compiler, struct gdbarch *gdbarch, static void cleanup_compile_instance (void *arg) { - struct compile_instance *inst = (struct compile_instance *) arg; + compile::compile_instance *inst + = static_cast (arg); delete inst; } @@ -487,7 +488,7 @@ static compile_file_names compile_to_object (struct command_line *cmd, const char *cmd_string, enum compile_i_scope_types scope) { - struct compile_instance *compiler; + compile::compile_instance *compiler; struct cleanup *cleanup, *inner_cleanup; const struct block *expr_block; CORE_ADDR trash_pc, expr_pc; @@ -574,7 +575,6 @@ compile_to_object (struct command_line *cmd, const char *cmd_string, get_args (compiler, gdbarch, &argc, &argv); make_cleanup_freeargv (argv); - /* !!keiths: This should be hidden at this level! */ if (compiler->version ()>= GCC_FE_VERSION_1) error_message = compiler->set_arguments (argc, argv); else @@ -698,7 +698,7 @@ compile_register_name_demangle (struct gdbarch *gdbarch, /* See description in compile-internal.h. */ void -compile_instance::insert_type (struct type *type, gcc_type gcc_type) +compile::compile_instance::insert_type (struct type *type, gcc_type gcc_type) { type_map_t::iterator pos = m_type_map.find (type); @@ -717,8 +717,8 @@ compile_instance::insert_type (struct type *type, gcc_type gcc_type) /* See description in compile-internal.h. */ void -compile_instance::insert_symbol_error (const struct symbol *sym, - std::string text) +compile::compile_instance::insert_symbol_error (const struct symbol *sym, + std::string text) { symbol_err_map_t::iterator pos = m_symbol_err_map.find (sym); @@ -729,7 +729,7 @@ compile_instance::insert_symbol_error (const struct symbol *sym, /* See description in compile-internal.h. */ void -compile_instance::error_symbol_once (const struct symbol *sym) +compile::compile_instance::error_symbol_once (const struct symbol *sym) { symbol_err_map_t::iterator pos = m_symbol_err_map.find (sym); if (pos == m_symbol_err_map.end () || pos->second.length () == 0) @@ -747,7 +747,7 @@ compile_instance::error_symbol_once (const struct symbol *sym) /* Set the plug-in print callback. */ void -compile_instance::set_print_callback +compile::compile_instance::set_print_callback (void (*print_function) (void *, const char *), void *datum) { FORWARD (set_print_callback, print_function, datum); @@ -756,7 +756,7 @@ compile_instance::set_print_callback /* Return the plug-in's front-end version. */ unsigned int -compile_instance::version () const +compile::compile_instance::version () const { return m_gcc_fe->ops->version; } @@ -764,7 +764,7 @@ compile_instance::version () const /* Set the plug-in's verbosity level. */ void -compile_instance::set_verbose (int level) +compile::compile_instance::set_verbose (int level) { FORWARD (set_verbose, level); } @@ -772,9 +772,8 @@ compile_instance::set_verbose (int level) /* Set the plug-in driver program. */ void -compile_instance::set_driver_filename (const char *filename) +compile::compile_instance::set_driver_filename (const char *filename) { - /* !!keiths: Possible leak??? */ FORWARD (set_driver_filename, filename); } @@ -782,24 +781,24 @@ compile_instance::set_driver_filename (const char *filename) prefix to the compiler. */ void -compile_instance::set_triplet_regexp (const char *regexp) +compile::compile_instance::set_triplet_regexp (const char *regexp) { - /* !!keiths: Leak? */ FORWARD (set_triplet_regexp, regexp); } /* Set compilation arguments. */ char * -compile_instance::set_arguments (int argc, char **argv) +compile::compile_instance::set_arguments (int argc, char **argv) { return FORWARD (set_arguments, argc, argv); } -/* !!keiths: YUCK! */ +/* As above, for protocol version 0. */ char * -compile_instance::set_arguments (const char *regexp, int argc, char **argv) +compile::compile_instance::set_arguments (const char *regexp, int argc, char + **argv) { return FORWARD (set_arguments_v0, regexp, argc, argv); } @@ -807,7 +806,7 @@ compile_instance::set_arguments (const char *regexp, int argc, char **argv) /* Set the filename of the program to compile. */ void -compile_instance::set_source_file (const char *filename) +compile::compile_instance::set_source_file (const char *filename) { FORWARD (set_source_file, filename); } @@ -815,7 +814,7 @@ compile_instance::set_source_file (const char *filename) /* Compile the previously specified source file to FILENAME. */ bool -compile_instance::compile (const char *filename) +compile::compile_instance::compile (const char *filename) { return FORWARD (compile, filename); } @@ -823,7 +822,7 @@ compile_instance::compile (const char *filename) /* As above, but for an earlier compile protocol. */ bool -compile_instance::compile (const char *filename, int verbose_level) +compile::compile_instance::compile (const char *filename, int verbose_level) { return FORWARD (compile_v0, filename, verbose_level); } diff --git a/gdb/cp-abi.h b/gdb/cp-abi.h index 43833d0094e..9620da10f9c 100644 --- a/gdb/cp-abi.h +++ b/gdb/cp-abi.h @@ -39,9 +39,12 @@ struct frame_info; non-zero. */ enum ctor_kinds { + /* Unrecognized or not a constructor. */ + not_ctor = 0, + /* Initialize a complete object, including virtual bases, using memory provided by caller. */ - complete_object_ctor = 1, + complete_object_ctor, /* Initialize a base object of some larger object. */ base_object_ctor, @@ -53,10 +56,7 @@ enum ctor_kinds { unified_ctor, /* Deprecated? */ - object_ctor_group, - - /* Unknown constructor, e.g., no linkage name. */ - unknown_ctor + object_ctor_group }; /* Return non-zero iff NAME is the mangled name of a constructor. @@ -69,9 +69,12 @@ extern enum ctor_kinds is_constructor_name (const char *name); non-zero. */ enum dtor_kinds { + /* Unrecognized or not a destructor. */ + not_dtor = 0, + /* A destructor which finalizes the entire object, and then calls `delete' on its storage. */ - deleting_dtor = 1, + deleting_dtor, /* A destructor which finalizes the entire object, but does not call `delete'. */ @@ -85,10 +88,7 @@ enum dtor_kinds { unified_dtor, /* Deprecated? */ - object_dtor_group, - - /* Unknown destructor, e.g., no linkage name. */ - unknown_dtor + object_dtor_group }; /* Kinds of template arguments. */ diff --git a/gdb/cp-support.c b/gdb/cp-support.c index 88e1b3276e0..f77546a2cad 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -1689,8 +1689,8 @@ cp_decode_template_type_indices (struct template_symbol *tsymbol, if (tsymbol->linkage_name == NULL) { - /* !!keiths: I can't even issue a good error message! */ - warning (_("Template symbol has no linkage name.")); + warning (_("Template symbol \"%s\" has no linkage name."), + SYMBOL_NATURAL_NAME (&tsymbol->base)); return; } @@ -1719,8 +1719,6 @@ cp_decode_template_type_indices (struct template_symbol *tsymbol, info = dpi.get (); } - /* !!keiths will certainly require extensive testing/revision. */ - /* Determine the return type index. */ ret_comp = info->tree; if (ret_comp->type == DEMANGLE_COMPONENT_TYPED_NAME) diff --git a/gdb/cp-support.h b/gdb/cp-support.h index 7c5005b213e..85d6461eef6 100644 --- a/gdb/cp-support.h +++ b/gdb/cp-support.h @@ -178,13 +178,6 @@ extern struct cmd_list_element *maint_cplus_cmd_list; char *gdb_demangle (const char *name, int options); -/* Find the fn_field for the method with symbol METHOD_SYMBOL in its - parent class. If XTOR_ONLY is non-zero, any symbols not representing a - constructor or destructor will return NULL. */ - -extern struct fn_field *cp_find_method_field (struct symbol *method_symbol, - int xtor_only); - /* Decode template information for TSYMBOL. This function determines whether the template's return and argument types are concrete types or template parameters. The symbol's obstack is used to allocate any needed memory. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 48acc968156..835cfb4079b 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -6918,7 +6918,8 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) { case DW_TAG_subprogram: addr = gdbarch_adjust_dwarf2_addr (gdbarch, pdi->lowpc + baseaddr); - if (pdi->is_external || cu->language == language_ada || cu->language == language_cplus) + if (pdi->is_external || cu->language == language_ada + || cu->language == language_cplus) { /* brobecker/2007-12-26: Normally, only "external" DIEs are part of the global scope. But in Ada, we want to be able to access @@ -8842,10 +8843,10 @@ add_xtor_field (struct type *parent_type, methods[idx] = new_fn_field (name_die, name_cu, type_die, type_cu, parent_type, name, idx, i); - /* If this is an aliased xtor, mark it as a duplicate so that + /* If this is an aliased xtor, mark it as an alias so that it will be ignored during symbol searches and type printing. */ if (name_die != type_die) - TYPE_FN_FIELD_DUPLICATE (methods, idx) = 1; + TYPE_FN_FIELD_ALIAS (methods, idx) = 1; return; } @@ -8915,17 +8916,17 @@ read_imported_decl (struct die_info *die, struct dwarf2_cu *cu) if (linkage_name != NULL) { enum ctor_kinds ctor_kind; - enum dtor_kinds dtor_kind = (enum dtor_kinds) 0; + enum dtor_kinds dtor_kind = not_dtor; ctor_kind = is_constructor_name (linkage_name); - if (ctor_kind == 0) + if (ctor_kind == not_ctor) dtor_kind = is_destructor_name (linkage_name); /* GCC outputs imported_declaration for C1 constructors and D1 destructors which alias to the C4/D4/unified ctor/dtor listed in the parent class's DIE tree. Deal with those here. */ - if (ctor_kind != 0 || dtor_kind != 0) + if (ctor_kind != not_ctor || dtor_kind != not_dtor) { struct die_info *imported_die, *spec_die, *parent_die; struct die_info *type_die; @@ -11448,17 +11449,17 @@ possibly_add_new_xtor_method (const char *name, struct die_info *die, struct dwarf2_cu *cu) { const char *linkage_name = dw2_linkage_name (die, cu); - enum ctor_kinds ctor_kind; if (linkage_name == NULL || cu->language != language_cplus) return; - ctor_kind = is_constructor_name (linkage_name); - if (ctor_kind == 0) + enum ctor_kinds ctor_kind = is_constructor_name (linkage_name); + + if (ctor_kind == not_ctor) { enum dtor_kinds dtor_kind = is_destructor_name (linkage_name); - if (dtor_kind == 0) + if (dtor_kind == not_dtor) return; } @@ -12905,8 +12906,7 @@ dwarf2_add_type_defn (struct field_info *fip, struct die_info *die, || die->tag == DW_TAG_class_type || die->tag == DW_TAG_structure_type || die->tag == DW_TAG_union_type - || die->tag == DW_TAG_enumeration_type - /*|| die->tag == DW_TAG_namespace*/); + || die->tag == DW_TAG_enumeration_type); fp = &new_field->field; @@ -12922,11 +12922,9 @@ dwarf2_add_type_defn (struct field_info *fip, struct die_info *die, accessibility = dwarf2_default_access_attribute (die, cu); switch (accessibility) { -#if 1 case DW_ACCESS_public: fp->is_public = 1; break; -#endif case DW_ACCESS_private: fp->is_private = 1; break; @@ -13063,13 +13061,13 @@ dwarf2_is_constructor (struct die_info *die, struct dwarf2_cu *cu) const char *fieldname; const char *type_name; int len; - const char *linkage_name; /* If there is a linkage name, use it to determine if this DIE represents a constructor. */ - linkage_name = dw2_linkage_name (die, cu); + const char *linkage_name = dw2_linkage_name (die, cu); + if (linkage_name != NULL) - return is_constructor_name (linkage_name) != 0; + return is_constructor_name (linkage_name) != not_ctor; /* Many older versions of GCC do not output DW_AT_linkage_name for constructors. In that case, fallback to a heuristic test. */ @@ -13097,14 +13095,12 @@ dwarf2_is_constructor (struct die_info *die, struct dwarf2_cu *cu) static int dwarf2_is_destructor (struct die_info *die, struct dwarf2_cu *cu) { - const char *fieldname; - const char *linkage_name; - /* If there is a linkage name, use it to determine if this DIE represents a destructor. */ - linkage_name = dw2_linkage_name (die, cu); + const char *linkage_name = dw2_linkage_name (die, cu); + if (linkage_name != NULL) - return is_destructor_name (linkage_name) != 0; + return is_destructor_name (linkage_name) != not_dtor; if (die->parent == NULL) return 0; @@ -13114,7 +13110,8 @@ dwarf2_is_destructor (struct die_info *die, struct dwarf2_cu *cu) && die->parent->tag != DW_TAG_class_type) return 0; - fieldname = dwarf2_name (die, cu); + const char *fieldname = dwarf2_name (die, cu); + return (fieldname != NULL && *fieldname == '~'); } @@ -13217,15 +13214,12 @@ new_fn_field (struct die_info *name_die, struct dwarf2_cu *name_cu, fnfield.is_constructor = dwarf2_is_constructor (name_die, type_cu); if (fnfield.is_constructor) { - const char *linkage_name; + const char *linkage_name = dw2_linkage_name (name_die, name_cu); - linkage_name = dw2_linkage_name (name_die, name_cu); - if (linkage_name == NULL) - fnfield.cdtor_type.ctor_kind = unknown_ctor; - else + if (linkage_name != NULL) { fnfield.cdtor_type.ctor_kind = is_constructor_name (linkage_name); - gdb_assert (fnfield.cdtor_type.ctor_kind != 0); + gdb_assert (fnfield.cdtor_type.ctor_kind != not_ctor); } } else @@ -13233,18 +13227,12 @@ new_fn_field (struct die_info *name_die, struct dwarf2_cu *name_cu, fnfield.is_destructor = dwarf2_is_destructor (name_die, name_cu); if (fnfield.is_destructor) { - const char *linkage_name; - - /* The linkage name can be NULL coming from objfiles created by the - GCC compile plug-in. This special case should be handled by - dwarf2_add_member_fn. */ - linkage_name = dw2_linkage_name (name_die, name_cu); - if (linkage_name == NULL) - fnfield.cdtor_type.dtor_kind = unknown_dtor; - else + const char *linkage_name = dw2_linkage_name (name_die, name_cu); + + if (linkage_name != NULL) { fnfield.cdtor_type.dtor_kind = is_destructor_name (linkage_name); - gdb_assert (fnfield.cdtor_type.dtor_kind != 0); + gdb_assert (fnfield.cdtor_type.dtor_kind != not_dtor); } } } @@ -14584,7 +14572,6 @@ read_namespace (struct die_info *die, struct dwarf2_cu *cu) } } -#if 1 if (die->child != NULL) { struct die_info *child_die = die->child; @@ -14595,11 +14582,6 @@ read_namespace (struct die_info *die, struct dwarf2_cu *cu) child_die = sibling_die (child_die); } } -#else - /* !!keiths: HACK! This works around GDB not being able to - define the contents of a namespace. */ - process_structure_scope (die, cu); -#endif } /* Read a Fortran module as type. This DIE can be only a declaration used for @@ -19651,9 +19633,8 @@ guess_full_die_structure_name (struct die_info *die, struct dwarf2_cu *cu) { if (child->tag == DW_TAG_subprogram) { - const char *linkage_name; + const char *linkage_name = dw2_linkage_name (child, cu); - linkage_name = dw2_linkage_name (child, cu); if (linkage_name != NULL) { char *actual_name diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 10949ae8f89..5e5db2776b1 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1702,8 +1702,7 @@ set_type_vptr_fieldno (struct type *type, int fieldno) { type = check_typedef (type); gdb_assert (TYPE_CODE (type) == TYPE_CODE_STRUCT - || TYPE_CODE (type) == TYPE_CODE_UNION - || TYPE_CODE (type) == TYPE_CODE_NAMESPACE /* !!keiths */); + || TYPE_CODE (type) == TYPE_CODE_UNION); if (!HAVE_CPLUS_STRUCT (type)) ALLOCATE_CPLUS_STRUCT_TYPE (type); TYPE_RAW_CPLUS_SPECIFIC (type)->vptr_fieldno = fieldno; diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 1f1edaca95a..c177fed7f8f 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -45,7 +45,7 @@ */ #include "hashtab.h" -#include "cp-abi.h" /* !!keiths: YUCK! */ +#include "cp-abi.h" /* Forward declarations for prototypes. */ struct field; @@ -876,7 +876,7 @@ struct fn_field /* * True if this function is aliased to an existing fn_field, false otherwise. These functions should be skipped during symbol lookups or type printing. */ - unsigned int is_duplicate : 1; + unsigned int is_alias : 1; /* * Unused. */ @@ -926,9 +926,9 @@ struct template_argument_info struct symbol **arguments; /* * Default values. An array with n_arguments elements. Note that this - array only describes this particular instance! It will not describe default - values for /all/ template instances (unless this instance uses all the defaults). - This is a DWARF limitation. */ + array only describes this particular instance! It will not describe + default values for /all/ template instances (unless this instance uses + all the defaults). This is a DWARF limitation. */ struct symbol **default_arguments; /* * The kinds of arguments. An array with n_arguments elements. */ @@ -1479,7 +1479,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *); #define TYPE_FN_FIELD_STUB(thisfn, n) ((thisfn)[n].is_stub) #define TYPE_FN_FIELD_CONSTRUCTOR(thisfn, n) ((thisfn)[n].is_constructor) #define TYPE_FN_FIELD_DESTRUCTOR(thisfn, n) ((thisfn)[n].is_destructor) -#define TYPE_FN_FIELD_DUPLICATE(thisfn, n) ((thisfn)[n].is_duplicate) +#define TYPE_FN_FIELD_ALIAS(thisfn, n) ((thisfn)[n].is_alias) #define TYPE_FN_FIELD_FCONTEXT(thisfn, n) ((thisfn)[n].fcontext) #define TYPE_FN_FIELD_VOFFSET(thisfn, n) ((thisfn)[n].voffset-2) #define TYPE_FN_FIELD_VIRTUAL_P(thisfn, n) ((thisfn)[n].voffset > 1) diff --git a/gdb/gnu-v2-abi.c b/gdb/gnu-v2-abi.c index 0af684f4546..dd6820b0afa 100644 --- a/gdb/gnu-v2-abi.c +++ b/gdb/gnu-v2-abi.c @@ -40,7 +40,7 @@ gnuv2_is_destructor_name (const char *name) || startswith (name, "__dt__")) return complete_object_dtor; else - return (enum dtor_kinds) 0; + return not_dtor; } static enum ctor_kinds @@ -51,7 +51,7 @@ gnuv2_is_constructor_name (const char *name) || startswith (name, "__ct__")) return complete_object_ctor; else - return (enum ctor_kinds) 0; + return not_ctor; } static int diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index 38bfb41fdff..e39d3162bf5 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -1356,7 +1356,7 @@ gnuv3_is_constructor_name (const char *mangled_name) switch (libiberty_kind) { case 0: - kind = (enum ctor_kinds) 0; + kind = not_ctor; break; case gnu_v3_complete_object_ctor: kind = complete_object_ctor; @@ -1393,7 +1393,7 @@ gnuv3_is_destructor_name (const char *mangled_name) switch (libiberty_kind) { case 0: - kind = (enum dtor_kinds) 0; + kind = not_dtor; break; case gnu_v3_deleting_dtor: kind = deleting_dtor; diff --git a/gdb/language.h b/gdb/language.h index 2bf677c43e7..4c4468d52b8 100644 --- a/gdb/language.h +++ b/gdb/language.h @@ -35,7 +35,11 @@ struct value_print_options; struct type_print_options; struct lang_varobj_ops; struct parser_state; -struct compile_instance; + +namespace compile +{ + class compile_instance; +}; #define MAX_FORTRAN_DIMS 7 /* Maximum number of F77 array dims. */ @@ -400,7 +404,7 @@ struct language_defn instance is owned by its caller and must be deallocated by calling its 'destroy' method. */ - struct compile_instance *(*la_get_compile_instance) (void); + compile::compile_instance *(*la_get_compile_instance) (void); /* This method must be defined if 'la_get_gcc_context' is defined. If 'la_get_gcc_context' is not defined, then this method is @@ -416,7 +420,7 @@ struct language_defn parsed. EXPR_PC is the PC at which the expression is being parsed. */ - std::string (*la_compute_program) (struct compile_instance *inst, + std::string (*la_compute_program) (compile::compile_instance *inst, const char *input, struct gdbarch *gdbarch, const struct block *expr_block, diff --git a/gdb/linespec.c b/gdb/linespec.c index 5031c6a63f0..d15d6f2bc73 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -2864,114 +2864,6 @@ lookup_prefix_sym (struct linespec_state *state, VEC (symtab_ptr) *file_symtabs, return collector.symbols; } -/* See cp-support.h for description. This function is defined here because all - the support routines for it are defined in this file. */ - -struct fn_field * -cp_find_method_field (struct symbol *method_symbol, int xtor_only) -{ - struct linespec_state state; - VEC (block_symbol_d) *syms; - VEC (symtab_ptr) *file_symtabs = NULL; - struct cleanup *cleanup; - struct block_symbol *class_sym; - char *class_name, *method_name; - const char *last, *p, *method_fullname; - - /* Sanity check: if the symbol's type isn't actually a method, do not - bother attempting to find a fn_field for it. */ - if (TYPE_CODE (SYMBOL_TYPE (method_symbol)) != TYPE_CODE_METHOD) - return NULL; - - /* Find class/method names. */ - method_fullname = SYMBOL_NATURAL_NAME (method_symbol); - last = NULL; - p = find_toplevel_string (method_fullname, "::"); - while (p != NULL) - { - last = p; - p = find_toplevel_string (p + 2, "::"); - } - - class_name = XNEWVEC (char, last - method_fullname + 1); - cleanup = make_cleanup (xfree, class_name); - strncpy (class_name, method_fullname, last - method_fullname); - class_name[last - method_fullname] = '\0'; - last += 2; - method_name = XNEWVEC (char, strlen (last) + 1); - make_cleanup (xfree, method_name); - strcpy (method_name, last); - - if (xtor_only) - { - int len; - char *n = class_name; - char *raw_class = cp_func_name (class_name); - - if (raw_class != NULL) - n = raw_class; - - /* !!keiths; This test isn't perfect in the general case, but it - should be enough for our compiler-centric case which is always - well-defined. Consider moving this code to compile/ somewhere. */ - len = strlen (method_name); - if (!(strncmp (method_name, n, len) == 0 - && (n[len] == '\0' || n[len] == '<')) - || method_name[0] != '~') - { - /* Not a constructor or destructor -- return. */ - xfree (raw_class); - do_cleanups (cleanup); - return NULL; - } - - xfree (raw_class); - } - - memset (&state, 0, sizeof (struct linespec_state)); - state.language = language_def (language_cplus); - VEC_safe_push (symtab_ptr, file_symtabs, symbol_symtab (method_symbol)); - cleanup = make_cleanup (VEC_cleanup (symtab_ptr), &file_symtabs); - syms = lookup_prefix_sym (&state, file_symtabs, class_name); - make_cleanup (VEC_cleanup (block_symbol_d), &syms); - - if (!VEC_empty (block_symbol_d, syms)) - { - int i; - struct type *class_type; - - /* !!keiths: Can we expect more than one? I don't think so. */ - gdb_assert (VEC_length (block_symbol_d, syms) == 1); - class_sym = VEC_index (block_symbol_d, syms, 0); - class_type = SYMBOL_TYPE (class_sym->symbol); - - /* CLASS_SYM is the parent class... Loop over fn_fields defined in this - class looking for the one of matching name and type. */ - for (i = 0; i < TYPE_NFN_FIELDS (class_type); ++i) - { - int j; - const char *name = TYPE_FN_FIELDLIST_NAME (class_type, i); - struct fn_field *fields = TYPE_FN_FIELDLIST1 (class_type, i); - - if (!streq (name, method_name)) - continue; - - for (j = 0; j < TYPE_FN_FIELDLIST_LENGTH (class_type, i); ++j) - { - if (streq (SYMBOL_LINKAGE_NAME (method_symbol), - TYPE_FN_FIELD_PHYSNAME (fields, j))) - { - do_cleanups (cleanup); - return &TYPE_FN_FIELD (fields, j); - } - } - } - } - - do_cleanups (cleanup); - return NULL; -} - /* A qsort comparison function for symbols. The resulting order does not actually matter; we just need to be able to sort them so that symbols with the same program space end up next to each other. */ diff --git a/gdb/symtab.h b/gdb/symtab.h index c1177d40a68..3f6029c47c0 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -24,7 +24,6 @@ #include "gdb_vecs.h" #include "gdbtypes.h" #include "common/enum-flags.h" -#include "cp-abi.h" /* !!keiths; YUCK! Need enum template_argument_kinds! */ /* Opaque declarations. */ struct ui_file; @@ -1704,9 +1703,14 @@ void initialize_objfile_symbol (struct symbol *); struct template_symbol *allocate_template_symbol (struct objfile *); +/* Result of a multi-symbol search. */ + struct search_multiple_result { + /* Matching debug symbols. */ VEC (block_symbol_d) *symbols; + + /* Matching non-debug symbols. */ VEC (bound_minimal_symbol_d) *minimal_symbols; }; @@ -1723,12 +1727,10 @@ extern struct search_multiple_result /* Free the result of search_symbols_multiple. */ -extern void - free_search_multiple_result (struct search_multiple_result *); +extern void free_search_multiple_result (struct search_multiple_result *); /* A cleanup function for the return result of search_symbols_multiple. */ -extern void - search_multiple_result_cleanup (void *); +extern void search_multiple_result_cleanup (void *); #endif /* !defined(SYMTAB_H) */ diff --git a/gdb/testsuite/gdb.compile/compile-cplus-print.exp b/gdb/testsuite/gdb.compile/compile-cplus-print.exp index 7ac4d0b610e..cb453a4e184 100644 --- a/gdb/testsuite/gdb.compile/compile-cplus-print.exp +++ b/gdb/testsuite/gdb.compile/compile-cplus-print.exp @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -load_lib compiler-support.exp +load_lib compile-support.exp standard_testfile diff --git a/gdb/testsuite/gdb.compile/compile-cplus.c b/gdb/testsuite/gdb.compile/compile-cplus.c index 97714ca7a6d..3ba46ce947d 100644 --- a/gdb/testsuite/gdb.compile/compile-cplus.c +++ b/gdb/testsuite/gdb.compile/compile-cplus.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2016 Free Software Foundation, Inc. + Copyright 2014-2017 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -163,10 +163,10 @@ struct VirtualBase : virtual VirtualOnly }; struct VirtualBase2 : VirtualBase {}; - + VirtualBase::VirtualBase (void) { - z = 24; + z = 24; } VirtualBase::~VirtualBase (void) @@ -178,7 +178,7 @@ class Foo { int var; static const int public_static_var = 12; - + private: int private_var = 0; int private_method (void); diff --git a/gdb/testsuite/gdb.compile/compile-cplus.exp b/gdb/testsuite/gdb.compile/compile-cplus.exp index 8aefbe74b4d..04849ba3947 100644 --- a/gdb/testsuite/gdb.compile/compile-cplus.exp +++ b/gdb/testsuite/gdb.compile/compile-cplus.exp @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -load_lib compiler-support.exp +load_lib compile-support.exp standard_testfile .c compile-shlib.c compile-constvar.S compile-nodebug.c @@ -339,5 +339,3 @@ if { $srcfile3 != "" } { } else { untested "print constvar value" } - - diff --git a/gdb/testsuite/gdb.compile/compile-ifunc.exp b/gdb/testsuite/gdb.compile/compile-ifunc.exp index 68c1830d56b..dc442ffc8ac 100644 --- a/gdb/testsuite/gdb.compile/compile-ifunc.exp +++ b/gdb/testsuite/gdb.compile/compile-ifunc.exp @@ -13,8 +13,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -load_lib compiler-support.exp - standard_testfile with_test_prefix "nodebug" { diff --git a/gdb/testsuite/gdb.compile/compile-ops.exp b/gdb/testsuite/gdb.compile/compile-ops.exp index f92ee3a002b..6e178b06749 100644 --- a/gdb/testsuite/gdb.compile/compile-ops.exp +++ b/gdb/testsuite/gdb.compile/compile-ops.exp @@ -17,7 +17,6 @@ # integration. load_lib dwarf.exp -load_lib compiler-support.exp # This test can only be run on targets which support DWARF-2 and use gas. if {![dwarf2_support]} { diff --git a/gdb/testsuite/gdb.compile/compile-print.exp b/gdb/testsuite/gdb.compile/compile-print.exp index 3870e10a752..42213944405 100644 --- a/gdb/testsuite/gdb.compile/compile-print.exp +++ b/gdb/testsuite/gdb.compile/compile-print.exp @@ -13,8 +13,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -load_lib compiler-support.exp - standard_testfile if { [prepare_for_testing "failed to prepare" "$testfile"] } { diff --git a/gdb/testsuite/gdb.compile/compile-setjmp.exp b/gdb/testsuite/gdb.compile/compile-setjmp.exp index 031551e7335..3692d6815c4 100644 --- a/gdb/testsuite/gdb.compile/compile-setjmp.exp +++ b/gdb/testsuite/gdb.compile/compile-setjmp.exp @@ -13,8 +13,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -load_lib compiler-support.exp - standard_testfile .c compile-setjmp-mod.c if { [prepare_for_testing "failed to prepare" $testfile] } { diff --git a/gdb/testsuite/gdb.compile/compile-tls.exp b/gdb/testsuite/gdb.compile/compile-tls.exp index 09d9db8cc56..7e52ad92a2f 100644 --- a/gdb/testsuite/gdb.compile/compile-tls.exp +++ b/gdb/testsuite/gdb.compile/compile-tls.exp @@ -13,8 +13,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . */ -load_lib compiler-support.exp - standard_testfile .c if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ diff --git a/gdb/testsuite/gdb.compile/compile.exp b/gdb/testsuite/gdb.compile/compile.exp index 072129572ab..b2218704cb4 100644 --- a/gdb/testsuite/gdb.compile/compile.exp +++ b/gdb/testsuite/gdb.compile/compile.exp @@ -13,8 +13,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -load_lib compiler-support.exp - standard_testfile .c compile-shlib.c compile-constvar.S compile-nodebug.c get_compiler_info diff --git a/gdb/testsuite/gdb.compile/cp-namespace-template.cc b/gdb/testsuite/gdb.compile/cp-namespace-template.cc index d0094846e36..18bbab4d666 100644 --- a/gdb/testsuite/gdb.compile/cp-namespace-template.cc +++ b/gdb/testsuite/gdb.compile/cp-namespace-template.cc @@ -136,4 +136,3 @@ main (void) + A::stempmethod () + A::stempmethod (0); // break here } - diff --git a/gdb/testsuite/gdb.compile/cp-namespace-template.exp b/gdb/testsuite/gdb.compile/cp-namespace-template.exp index a320d29f8cc..19eabe97595 100644 --- a/gdb/testsuite/gdb.compile/cp-namespace-template.exp +++ b/gdb/testsuite/gdb.compile/cp-namespace-template.exp @@ -15,7 +15,7 @@ # Namespace-qualified template tests. -load_lib compiler-support.exp +load_lib compile-support.exp standard_testfile .cc diff --git a/gdb/testsuite/gdb.compile/cp-simple-anonymous.exp b/gdb/testsuite/gdb.compile/cp-simple-anonymous.exp index 6ee1fbad25a..094c07be0c8 100644 --- a/gdb/testsuite/gdb.compile/cp-simple-anonymous.exp +++ b/gdb/testsuite/gdb.compile/cp-simple-anonymous.exp @@ -15,7 +15,7 @@ # (Very) simple method tests. -load_lib compiler-support.exp +load_lib compile-support.exp standard_testfile .cc diff --git a/gdb/testsuite/gdb.compile/cp-simple-inherit.exp b/gdb/testsuite/gdb.compile/cp-simple-inherit.exp index f4561bc09dd..64c89064269 100644 --- a/gdb/testsuite/gdb.compile/cp-simple-inherit.exp +++ b/gdb/testsuite/gdb.compile/cp-simple-inherit.exp @@ -15,7 +15,7 @@ # (Very) simple inheritance tests. -load_lib compiler-support.exp +load_lib compile-support.exp standard_testfile .cc diff --git a/gdb/testsuite/gdb.compile/cp-simple-member.exp b/gdb/testsuite/gdb.compile/cp-simple-member.exp index 7fd734d8d00..c9320d7c2f2 100644 --- a/gdb/testsuite/gdb.compile/cp-simple-member.exp +++ b/gdb/testsuite/gdb.compile/cp-simple-member.exp @@ -15,7 +15,7 @@ # (Very) simple method tests. -load_lib compiler-support.exp +load_lib compile-support.exp standard_testfile .cc diff --git a/gdb/testsuite/gdb.compile/cp-simple-method.exp b/gdb/testsuite/gdb.compile/cp-simple-method.exp index 506dca605bd..ebb1273b6ce 100644 --- a/gdb/testsuite/gdb.compile/cp-simple-method.exp +++ b/gdb/testsuite/gdb.compile/cp-simple-method.exp @@ -15,7 +15,7 @@ # (Very) simple method tests. -load_lib compiler-support.exp +load_lib compile-support.exp standard_testfile .cc diff --git a/gdb/testsuite/gdb.compile/cp-simple-nested.cc b/gdb/testsuite/gdb.compile/cp-simple-nested.cc index 75d5e03d216..50db34f1494 100644 --- a/gdb/testsuite/gdb.compile/cp-simple-nested.cc +++ b/gdb/testsuite/gdb.compile/cp-simple-nested.cc @@ -56,4 +56,3 @@ main (void) return a.get (); } - diff --git a/gdb/testsuite/gdb.compile/cp-simple-nested.exp b/gdb/testsuite/gdb.compile/cp-simple-nested.exp index 74d3d6a962a..be3619740f4 100644 --- a/gdb/testsuite/gdb.compile/cp-simple-nested.exp +++ b/gdb/testsuite/gdb.compile/cp-simple-nested.exp @@ -15,7 +15,7 @@ # (Very) simple virtual method/inheritance tests. -load_lib compiler-support.exp +load_lib compile-support.exp standard_testfile .cc diff --git a/gdb/testsuite/gdb.compile/cp-simple-ns.cc b/gdb/testsuite/gdb.compile/cp-simple-ns.cc index 720c06efdb9..56923edba14 100644 --- a/gdb/testsuite/gdb.compile/cp-simple-ns.cc +++ b/gdb/testsuite/gdb.compile/cp-simple-ns.cc @@ -35,4 +35,3 @@ main (void) var += s.s4int_; /* break here */ return S4::get_svar () - 10 * s.get_var (); } - diff --git a/gdb/testsuite/gdb.compile/cp-simple-ns.exp b/gdb/testsuite/gdb.compile/cp-simple-ns.exp index 216621bd136..5d51a3d3d61 100644 --- a/gdb/testsuite/gdb.compile/cp-simple-ns.exp +++ b/gdb/testsuite/gdb.compile/cp-simple-ns.exp @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -load_lib compiler-support.exp +load_lib compile-support.exp standard_testfile .cc diff --git a/gdb/testsuite/gdb.compile/cp-simple-template.cc b/gdb/testsuite/gdb.compile/cp-simple-template.cc index 706fda6acec..ec46694757b 100644 --- a/gdb/testsuite/gdb.compile/cp-simple-template.cc +++ b/gdb/testsuite/gdb.compile/cp-simple-template.cc @@ -178,4 +178,3 @@ main (void) + defaultvals () + deduct (0); // break here } - diff --git a/gdb/testsuite/gdb.compile/cp-simple-template.exp b/gdb/testsuite/gdb.compile/cp-simple-template.exp index 9919c24b42d..7261eed332a 100644 --- a/gdb/testsuite/gdb.compile/cp-simple-template.exp +++ b/gdb/testsuite/gdb.compile/cp-simple-template.exp @@ -15,7 +15,7 @@ # (Very) simple template tests. -load_lib compiler-support.exp +load_lib compile-support.exp standard_testfile .cc diff --git a/gdb/testsuite/gdb.compile/cp-simple-virtual.cc b/gdb/testsuite/gdb.compile/cp-simple-virtual.cc index 264d6efb773..f778d70a9b3 100644 --- a/gdb/testsuite/gdb.compile/cp-simple-virtual.cc +++ b/gdb/testsuite/gdb.compile/cp-simple-virtual.cc @@ -63,4 +63,3 @@ main (void) return 0; } - diff --git a/gdb/testsuite/gdb.compile/cp-simple-virtual.exp b/gdb/testsuite/gdb.compile/cp-simple-virtual.exp index f56fe0414ff..44bb3dd7250 100644 --- a/gdb/testsuite/gdb.compile/cp-simple-virtual.exp +++ b/gdb/testsuite/gdb.compile/cp-simple-virtual.exp @@ -15,7 +15,7 @@ # (Very) simple virtual method/inheritance tests. -load_lib compiler-support.exp +load_lib compile-support.exp standard_testfile .cc diff --git a/gdb/testsuite/gdb.compile/cp-special-function.exp b/gdb/testsuite/gdb.compile/cp-special-function.exp index 26d4de5fbcf..fcbbfcea65e 100644 --- a/gdb/testsuite/gdb.compile/cp-special-function.exp +++ b/gdb/testsuite/gdb.compile/cp-special-function.exp @@ -15,7 +15,7 @@ # (Very) simple method tests. -load_lib compiler-support.exp +load_lib compile-support.exp standard_testfile .cc diff --git a/gdb/testsuite/lib/compiler-support.exp b/gdb/testsuite/lib/compile-support.exp similarity index 100% rename from gdb/testsuite/lib/compiler-support.exp rename to gdb/testsuite/lib/compile-support.exp diff --git a/gdb/valops.c b/gdb/valops.c index f2aab92d573..fcd3cfbfca1 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -2026,7 +2026,7 @@ search_struct_method (const char *name, struct value **arg1p, /* Count the number of non-aliased/duplicated methods. */ for (k = 0; k < TYPE_FN_FIELDLIST_LENGTH (type, i); ++k) { - if (!TYPE_FN_FIELD_DUPLICATE (f, k)) + if (!TYPE_FN_FIELD_ALIAS (f, k)) ++j; } --j; @@ -3442,14 +3442,14 @@ value_struct_elt_for_reference (struct type *domain, int offset, j = -1; for (ii = 0; ii < len; ++ii) { - /* Skip artificial methods. This is necessary if, - for example, the user wants to "print + /* Skip artificial and aliased methods. This is necessary + if, for example, the user wants to "print subclass::subclass" with only one user-defined constructor. There is no ambiguity in this case. We are careful here to allow artificial methods if they are the unique result. */ if (TYPE_FN_FIELD_ARTIFICIAL (f, ii) - || TYPE_FN_FIELD_DUPLICATE (f, ii)) + || TYPE_FN_FIELD_ALIAS (f, ii)) { if (j == -1) j = ii; @@ -3459,7 +3459,7 @@ value_struct_elt_for_reference (struct type *domain, int offset, /* Desired method is ambiguous if more than one method is defined. */ if (j != -1 && !TYPE_FN_FIELD_ARTIFICIAL (f, j) - && !TYPE_FN_FIELD_DUPLICATE (f, j)) + && !TYPE_FN_FIELD_ALIAS (f, j)) error (_("non-unique member `%s' requires " "type instantiation"), name);