From f2ca87a808ca1a31fbb3b7afdf1376488a59eaec Mon Sep 17 00:00:00 2001 From: Alexandre Oliva Date: Thu, 26 Jan 2017 19:33:42 -0200 Subject: [PATCH] libcp1: revamp the interface Narrow the oracle lookups to identifiers only, unifying symbols and tags, and dropping labels. Adjust the gdb client code, pending simplification. Rename most entry points into a more consistent naming scheme. Adjust the gdb client code. Bump the interface version. Comment out support for default args for functions. Drop support for strong using directives, introduce simpler interface for inline namespaces. --- gdb/compile/compile-cplus-symbols.c | 54 +++-- gdb/compile/compile-cplus-templates.c | 38 ++-- gdb/compile/compile-cplus-types.c | 256 +++++++++++----------- gdb/compile/compile-cplus.h | 92 ++++---- include/gcc-cp-fe.def | 302 ++++++++++++++------------ include/gcc-cp-interface.h | 42 ++-- 6 files changed, 405 insertions(+), 379 deletions(-) diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c index f33937b9ee2..2a9e91367c3 100644 --- a/gdb/compile/compile-cplus-symbols.c +++ b/gdb/compile/compile-cplus-symbols.c @@ -266,13 +266,13 @@ convert_one_symbol (compile_cplus_instance *instance, struct template_symbol *tsymbol = (struct template_symbol *) sym.symbol; - instance->specialize_function_template (tsymbol, addr, - filename, line); + instance->build_function_template_specialization (tsymbol, addr, + filename, line); } else { - instance->new_decl ("variable", name.c_str (), kind, sym_type, - symbol_name, addr, filename, line); + instance->build_decl ("variable", name.c_str (), kind, sym_type, + symbol_name, addr, filename, line); } /* Pop scope for non-local symbols. */ @@ -397,9 +397,9 @@ convert_symbol_bmsym (compile_cplus_instance *instance, information for the symbol. While we have access to the demangled name, we still don't know what A::B::C::D::E::F means without debug info, no? */ - instance->new_decl ("minsym", MSYMBOL_NATURAL_NAME (msym), kind, sym_type, - NULL, addr, NULL, 0); - instance->pop_namespace (""); + instance->build_decl ("minsym", MSYMBOL_NATURAL_NAME (msym), kind, sym_type, + NULL, addr, NULL, 0); + instance->pop_binding_level (""); } /* Do a regular expression search of the symbol table for any symbol @@ -471,7 +471,6 @@ gcc_cplus_convert_symbol (void *datum, { compile_cplus_instance *instance = (compile_cplus_instance *) datum; - domain_enum domain; int found = 0; struct search_multiple_result search_result; struct cleanup *cleanups; @@ -479,14 +478,9 @@ gcc_cplus_convert_symbol (void *datum, switch (request) { - case GCC_CP_ORACLE_SYMBOL: - domain = VAR_DOMAIN; - break; - case GCC_CP_ORACLE_TAG: - domain = STRUCT_DOMAIN; - break; - case GCC_CP_ORACLE_LABEL: - domain = LABEL_DOMAIN; + case GCC_CP_ORACLE_IDENTIFIER: + /* FIXME: This used to be separate SYMBOL and TAG. Check for + simplification opportunities below. -lxo */ break; default: gdb_assert_not_reached ("Unrecognized oracle request."); @@ -496,8 +490,7 @@ gcc_cplus_convert_symbol (void *datum, is to simply emit a gcc error. */ if (debug_compile_oracle) { - printf ("got oracle request for \"%s\" in domain %s\n", identifier, - domain_name (domain)); + printf ("got oracle request for \"%s\"\n", identifier); } memset (&search_result, 0, sizeof (search_result)); @@ -522,11 +515,11 @@ gcc_cplus_convert_symbol (void *datum, 4. Finally, if all else fails, fall back to minsyms. */ - if (domain == VAR_DOMAIN) + if (1) { search_result = search_symbols_multiple (identifier, current_language, - domain, NULL, NULL); + VAR_DOMAIN, NULL, NULL); if (!VEC_empty (block_symbol_d, search_result.symbols)) { struct block_symbol *elt; @@ -539,7 +532,7 @@ gcc_cplus_convert_symbol (void *datum, VEC_iterate (block_symbol_d, search_result.symbols, ix, elt); ++ix) { - convert_symbol_sym (instance, identifier, *elt, domain); + convert_symbol_sym (instance, identifier, *elt, VAR_DOMAIN); } found = 1; } @@ -549,10 +542,22 @@ gcc_cplus_convert_symbol (void *datum, { struct block_symbol sym; - sym = lookup_symbol (identifier, instance->block (), domain, NULL); + sym = lookup_symbol (identifier, instance->block (), VAR_DOMAIN, NULL); + if (sym.symbol != NULL) + { + convert_symbol_sym (instance, identifier, sym, VAR_DOMAIN); + found = 1; + } + } + + if (1) + { + struct block_symbol sym; + + sym = lookup_symbol (identifier, instance->block (), STRUCT_DOMAIN, NULL); if (sym.symbol != NULL) { - convert_symbol_sym (instance, identifier, sym, domain); + convert_symbol_sym (instance, identifier, sym, STRUCT_DOMAIN); found = 1; } } @@ -560,7 +565,8 @@ gcc_cplus_convert_symbol (void *datum, if (!found) { /* Try a regexp search of the program's symbols. */ - found = regexp_search_symbols (instance, identifier, domain); + found = regexp_search_symbols (instance, identifier, VAR_DOMAIN) + + regexp_search_symbols (instance, identifier, STRUCT_DOMAIN); /* One last attempt: fall back to minsyms. */ if (!found && !VEC_empty (bound_minimal_symbol_d, diff --git a/gdb/compile/compile-cplus-templates.c b/gdb/compile/compile-cplus-templates.c index f1922f932cf..57658644a0c 100644 --- a/gdb/compile/compile-cplus-templates.c +++ b/gdb/compile/compile-cplus-templates.c @@ -708,7 +708,7 @@ get_template_argument_value (compile_cplus_instance *instance, { /* !!keiths: More (incomplete) fun. */ case LOC_CONST: - value = instance->literal_expr (type, SYMBOL_VALUE (arg)); + value = instance->build_literal_expr (type, SYMBOL_VALUE (arg)); break; case LOC_COMPUTED: @@ -728,7 +728,7 @@ get_template_argument_value (compile_cplus_instance *instance, /* !!keiths: This is a hack, but I don't want to write yet another linkage name translation function. At least not just yet. */ - value = instance->literal_expr (type, value_address (val)); + value = instance->build_literal_expr (type, value_address (val)); } break; @@ -772,7 +772,7 @@ define_template_parameters_generic } gcc_type abstract_type - = instance->new_template_typename_parm (id, is_pack, + = instance->build_type_template_parameter (id, is_pack, default_type, filename, line); defn->set_parameter_abstract_type (i, abstract_type); } @@ -795,8 +795,8 @@ define_template_parameters_generic defn->default_argument (i)); } - instance->new_template_value_parm (abstract_type, id, - default_value, filename, line); + instance->build_value_template_parameter (abstract_type, id, + default_value, filename, line); } break; @@ -1109,7 +1109,7 @@ class function_template_definer /* Start the new template declaration. */ m_instance->enter_scope (scope); - m_instance->start_new_template_decl (defn->generic ().c_str ()); + m_instance->start_template_decl (defn->generic ().c_str ()); /* Get the parameters' generic kinds and types. */ define_template_parameters_generic (m_instance, defn, @@ -1280,10 +1280,10 @@ class function_template_definer /* Finally, define the new generic template declaration. */ gcc_decl decl - = m_instance->new_decl ("function template", name, sym_kind, - func_type, 0, 0, - symbol_symtab (&(tsym->base))->filename, - SYMBOL_LINE (&(tsym->base))); + = m_instance->build_decl ("function template", name, sym_kind, + func_type, 0, 0, + symbol_symtab (&(tsym->base))->filename, + SYMBOL_LINE (&(tsym->base))); defn->set_decl (decl); m_instance->leave_scope (); @@ -1350,7 +1350,7 @@ class class_template_definer m_instance->enter_scope (scope); /* Start a new template list for this template. */ - m_instance->start_new_template_decl (defn->generic ().c_str ()); + m_instance->start_template_decl (defn->generic ().c_str ()); /* Get the parameters' generic kinds and types. */ define_template_parameters_generic (m_instance, defn, arg_info, @@ -1365,11 +1365,11 @@ class class_template_definer if (TYPE_CODE (defn->type ()) == TYPE_CODE_STRUCT) { gcc_decl decl - = m_instance->new_decl ("class template", defn->decl_name (), - GCC_CP_SYMBOL_CLASS /* | nested_access? */ - | (TYPE_DECLARED_CLASS (defn->type ()) - ? GCC_CP_FLAG_CLASS_NOFLAG - : GCC_CP_FLAG_CLASS_IS_STRUCT), + = m_instance->build_decl ("class template", defn->decl_name (), + GCC_CP_SYMBOL_CLASS /* | nested_access? */ + | (TYPE_DECLARED_CLASS (defn->type ()) + ? GCC_CP_FLAG_CLASS_NOFLAG + : GCC_CP_FLAG_CLASS_IS_STRUCT), 0, NULL, 0, /*filename*/ NULL, /*line*/ 0); defn->set_decl (decl); @@ -1378,9 +1378,9 @@ class class_template_definer { gdb_assert (TYPE_CODE (defn->type ()) == TYPE_CODE_UNION); gcc_decl decl - = m_instance->new_decl ("union template", defn->decl_name (), - GCC_CP_SYMBOL_UNION /* | nested_access? */, - 0, NULL, 0, /*fileanme*/NULL, /*line*/0); + = m_instance->build_decl ("union template", defn->decl_name (), + GCC_CP_SYMBOL_UNION /* | nested_access? */, + 0, NULL, 0, /*fileanme*/NULL, /*line*/0); defn->set_decl (decl); } diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c index 973ea5a6ee3..7381e938262 100644 --- a/gdb/compile/compile-cplus-types.c +++ b/gdb/compile/compile-cplus-types.c @@ -381,11 +381,11 @@ compile_cplus_instance::leave_scope () (current.begin (),current.end () - 1, [this] (const auto &comp) { gdb_assert (TYPE_CODE (SYMBOL_TYPE (comp.bsymbol.symbol)) == TYPE_CODE_NAMESPACE); - this->pop_namespace (comp.name.c_str ()); + this->pop_binding_level (comp.name.c_str ()); }); /* Pop global namespace. */ - pop_namespace (""); + pop_binding_level (""); } else { @@ -595,12 +595,12 @@ ccp_convert_typedef (compile_cplus_instance *instance, /* Convert the typedef's real type. */ gcc_type typedef_type = instance->convert_type (check_typedef (type)); - instance->new_decl ("typedef", name, - GCC_CP_SYMBOL_TYPEDEF | nested_access, - typedef_type, - 0, 0, - /* !!keiths: Wow. More of this! */ - NULL, 0); + instance->build_decl ("typedef", name, + GCC_CP_SYMBOL_TYPEDEF | nested_access, + typedef_type, + 0, 0, + /* !!keiths: Wow. More of this! */ + NULL, 0); /* Completed this scope. */ instance->leave_scope (); @@ -676,11 +676,11 @@ ccp_convert_struct_or_union_members (compile_cplus_instance *instance, { physaddr = TYPE_FIELD_STATIC_PHYSADDR (type, i); - instance->new_decl ("field physaddr", field_name, - (GCC_CP_SYMBOL_VARIABLE - | get_field_access_flag (type, i)), - field_type, NULL, physaddr, - NULL, 0); + instance->build_decl ("field physaddr", field_name, + (GCC_CP_SYMBOL_VARIABLE + | get_field_access_flag (type, i)), + field_type, NULL, physaddr, + NULL, 0); } break; @@ -702,11 +702,11 @@ ccp_convert_struct_or_union_members (compile_cplus_instance *instance, filename = symbol_symtab (sym.symbol)->filename; line = SYMBOL_LINE (sym.symbol); physaddr = SYMBOL_VALUE_ADDRESS (sym.symbol); - instance->new_decl ("field physname", field_name, - (GCC_CP_SYMBOL_VARIABLE - | get_field_access_flag (type, i)), - field_type, NULL, physaddr, - filename, line); + instance->build_decl ("field physname", field_name, + (GCC_CP_SYMBOL_VARIABLE + | get_field_access_flag (type, i)), + field_type, NULL, physaddr, + filename, line); } break; @@ -733,8 +733,8 @@ ccp_convert_struct_or_union_members (compile_cplus_instance *instance, /* FIXME: We have to save the returned decl somewhere, so that we can refer to it in expressions, in context for lambdas, etc. */ - instance->new_field (field_name, field_type, field_flags, - bitsize, TYPE_FIELD_BITPOS (type, i)); + instance->build_field (field_name, field_type, field_flags, + bitsize, TYPE_FIELD_BITPOS (type, i)); } } } @@ -1193,14 +1193,14 @@ ccp_convert_struct_or_union_methods (compile_cplus_instance *instance, = ccp_convert_method (instance, type, TYPE_FN_FIELD_TYPE (methods, j)); - instance->new_decl("pure virtual method", name, - (sym_kind - | get_method_access_flag (type, i, j) - | GCC_CP_FLAG_VIRTUAL_FUNCTION - | GCC_CP_FLAG_PURE_VIRTUAL_FUNCTION), - method_type, NULL, 0, - NULL /* FIXME: filename */, - 0 /* FIXME: line number */); + instance->build_decl("pure virtual method", name, + (sym_kind + | get_method_access_flag (type, i, j) + | GCC_CP_FLAG_VIRTUAL_FUNCTION + | GCC_CP_FLAG_PURE_VIRTUAL_FUNCTION), + method_type, NULL, 0, + NULL /* FIXME: filename */, + 0 /* FIXME: line number */); do_cleanups (back_to); continue; } @@ -1230,8 +1230,8 @@ ccp_convert_struct_or_union_methods (compile_cplus_instance *instance, struct template_symbol *tsymbol = (struct template_symbol *) sym.symbol; - instance->specialize_function_template (tsymbol, address, - filename, line); + instance->build_function_template_specialization (tsymbol, address, + filename, line); do_cleanups (back_to); continue; } @@ -1254,7 +1254,7 @@ ccp_convert_struct_or_union_methods (compile_cplus_instance *instance, if (TYPE_FN_FIELD_VIRTUAL_P (methods, j)) sym_kind |= GCC_CP_FLAG_VIRTUAL_FUNCTION; - /* FIXME: for cdtors, we must call new_decl with a zero + /* FIXME: for cdtors, we must call build_decl with a zero address, if we haven't created the base declaration yet, and then define_cdtor_clone with the address of each clone. When we leave the address out, GCC uses @@ -1276,9 +1276,9 @@ ccp_convert_struct_or_union_methods (compile_cplus_instance *instance, } } - instance->new_decl (kind, name, - sym_kind | get_method_access_flag (type, i, j), - method_type, NULL, address, filename, line); + instance->build_decl (kind, name, + sym_kind | get_method_access_flag (type, i, j), + method_type, NULL, address, filename, line); do_cleanups (back_to); } @@ -1334,24 +1334,24 @@ ccp_convert_struct_or_union (compile_cplus_instance *instance, it go once we separate declaration from definition (see below). -lxo */ if (TYPE_N_TEMPLATE_ARGUMENTS (type)) - resuld = instance->specialize_class_template (type, filename, line); + resuld = instance->build_class_template_specialization (type, filename, line); else if (TYPE_CODE (type) == TYPE_CODE_STRUCT) { const char *what = TYPE_DECLARED_CLASS (type) ? "struct" : "class"; - resuld = instance->new_decl (what, name, - GCC_CP_SYMBOL_CLASS | nested_access - | (TYPE_DECLARED_CLASS (type) - ? GCC_CP_FLAG_CLASS_NOFLAG - : GCC_CP_FLAG_CLASS_IS_STRUCT), - 0, NULL, 0, filename, line); + resuld = instance->build_decl (what, name, + GCC_CP_SYMBOL_CLASS | nested_access + | (TYPE_DECLARED_CLASS (type) + ? GCC_CP_FLAG_CLASS_NOFLAG + : GCC_CP_FLAG_CLASS_IS_STRUCT), + 0, NULL, 0, filename, line); } else { gdb_assert (TYPE_CODE (type) == TYPE_CODE_UNION); - resuld = instance->new_decl ("union", name, - GCC_CP_SYMBOL_UNION | nested_access, - 0, NULL, 0, filename, line); + resuld = instance->build_decl ("union", name, + GCC_CP_SYMBOL_UNION | nested_access, + 0, NULL, 0, filename, line); } /* FIXME: we should be able to pop the scope at this point, rather @@ -1386,8 +1386,8 @@ ccp_convert_struct_or_union (compile_cplus_instance *instance, } } - result = instance->start_class_definition (name, resuld, &bases, - filename, line); + result = instance->start_class_type (name, resuld, &bases, + filename, line); xfree (bases.flags); xfree (bases.elements); } @@ -1395,8 +1395,8 @@ ccp_convert_struct_or_union (compile_cplus_instance *instance, { gdb_assert (TYPE_CODE (type) == TYPE_CODE_UNION); result - = instance->start_class_definition (name, resuld, NULL, - filename, line); + = instance->start_class_type (name, resuld, NULL, + filename, line); } instance->insert_type (type, result); @@ -1411,7 +1411,7 @@ ccp_convert_struct_or_union (compile_cplus_instance *instance, ccp_convert_struct_or_union_members (instance, type, result); /* All finished. */ - instance->finish_record_or_union (name, TYPE_LENGTH (type)); + instance->finish_class_type (name, TYPE_LENGTH (type)); /* Pop all scopes. */ instance->leave_scope (); @@ -1454,15 +1454,15 @@ ccp_convert_enum (compile_cplus_instance *instance, struct type *type, /* Push all scopes. */ instance->enter_scope (scope); - int_type = instance->int_type (TYPE_UNSIGNED (type), - TYPE_LENGTH (type), NULL); + int_type = instance->get_int_type (TYPE_UNSIGNED (type), + TYPE_LENGTH (type), NULL); gcc_type result - = instance->start_new_enum_type (name, int_type, - GCC_CP_SYMBOL_ENUM | nested_access - | (scoped_enum_p - ? GCC_CP_FLAG_ENUM_SCOPED - : GCC_CP_FLAG_ENUM_NOFLAG), - filename, line); + = instance->start_enum_type (name, int_type, + GCC_CP_SYMBOL_ENUM | nested_access + | (scoped_enum_p + ? GCC_CP_FLAG_ENUM_SCOPED + : GCC_CP_FLAG_ENUM_NOFLAG), + filename, line); for (i = 0; i < TYPE_NFIELDS (type); ++i) { char *fname = cp_func_name (TYPE_FIELD_NAME (type, i)); @@ -1474,8 +1474,8 @@ ccp_convert_enum (compile_cplus_instance *instance, struct type *type, continue; } - instance->build_add_enum_constant (result, fname, - TYPE_FIELD_ENUMVAL (type, i)); + instance->build_enum_constant (result, fname, + TYPE_FIELD_ENUMVAL (type, i)); xfree (fname); } @@ -1539,11 +1539,11 @@ ccp_convert_int (compile_cplus_instance *instance, struct type *type) if (TYPE_NOSIGN (type)) { gdb_assert (TYPE_LENGTH (type) == 1); - return instance->char_type (); + return instance->get_char_type (); } - return instance->int_type (TYPE_UNSIGNED (type), TYPE_LENGTH (type), - TYPE_NAME (type)); + return instance->get_int_type (TYPE_UNSIGNED (type), TYPE_LENGTH (type), + TYPE_NAME (type)); } /* Convert a floating-point type to its gcc representation. */ @@ -1551,7 +1551,7 @@ ccp_convert_int (compile_cplus_instance *instance, struct type *type) static gcc_type ccp_convert_float (compile_cplus_instance *instance, struct type *type) { - return instance->float_type (TYPE_LENGTH (type), TYPE_NAME (type)); + return instance->get_float_type (TYPE_LENGTH (type), TYPE_NAME (type)); } /* Convert the 'void' type to its gcc representation. */ @@ -1559,7 +1559,7 @@ ccp_convert_float (compile_cplus_instance *instance, struct type *type) static gcc_type ccp_convert_void (compile_cplus_instance *instance, struct type *type) { - return instance->void_type (); + return instance->get_void_type (); } /* Convert a boolean type to its gcc representation. */ @@ -1567,7 +1567,7 @@ ccp_convert_void (compile_cplus_instance *instance, struct type *type) static gcc_type ccp_convert_bool (compile_cplus_instance *instance, struct type *type) { - return instance->bool_type (); + return instance->get_bool_type (); } /* See description in compile-cplus.h. */ @@ -1643,7 +1643,7 @@ ccp_convert_namespace (compile_cplus_instance *instance, /* Convert this namespace. */ instance->push_namespace (name); - instance->pop_namespace (name); + instance->pop_binding_level (name); /* Pop scope. */ instance->leave_scope (); @@ -1837,7 +1837,7 @@ compile_cplus_instance::build_constant (gcc_type type, const char *name, /* See description in gcc-cp-fe.def. */ gcc_decl -compile_cplus_instance::specialize_function_template +compile_cplus_instance::build_function_template_specialization (struct template_symbol *concrete, gcc_address address, const char *filename, unsigned int line_number) { @@ -1858,7 +1858,7 @@ compile_cplus_instance::specialize_function_template make_cleanup (xfree, targs.elements); enumerate_template_arguments (&targs, defn, concrete->template_arguments); - DECLARE_FORWARD (specialize_function_template, defn->decl (), &targs, + DECLARE_FORWARD (build_function_template_specialization, defn->decl (), &targs, address, filename, line_number); gcc_decl result = forward ("%s", SYMBOL_NATURAL_NAME (&concrete->base)); @@ -1869,9 +1869,9 @@ compile_cplus_instance::specialize_function_template /* See description in gcc-cp-fe.def. */ gcc_decl -compile_cplus_instance::specialize_class_template (struct type *concrete, - const char *filename, - unsigned int line_number) +compile_cplus_instance::build_class_template_specialization (struct type *concrete, + const char *filename, + unsigned int line_number) { class_template_defn *defn = find_class_template_defn (concrete); @@ -1891,7 +1891,7 @@ compile_cplus_instance::specialize_class_template (struct type *concrete, enumerate_template_arguments (&targs, defn, TYPE_TEMPLATE_ARGUMENT_INFO (concrete)); - DECLARE_FORWARD (specialize_class_template, defn->decl (), &targs, + DECLARE_FORWARD (build_class_template_specialization, defn->decl (), &targs, filename, line_number); gcc_decl result @@ -1904,15 +1904,15 @@ compile_cplus_instance::specialize_class_template (struct type *concrete, /* See description in gcc-cp-fe.def. */ gcc_decl -compile_cplus_instance::new_decl (const char *decl_type, - const char *name, - enum gcc_cp_symbol_kind sym_kind, - gcc_type sym_type, - const char *substitution_name, - gcc_address address, const char *filename, - unsigned int line_number) -{ - DECLARE_FORWARD (new_decl, name, sym_kind, sym_type, +compile_cplus_instance::build_decl (const char *decl_type, + const char *name, + enum gcc_cp_symbol_kind sym_kind, + gcc_type sym_type, + const char *substitution_name, + gcc_address address, const char *filename, + unsigned int line_number) +{ + DECLARE_FORWARD (build_decl, name, sym_kind, sym_type, substitution_name, address, filename, line_number); return forward ("%s %s %d %s", decl_type, name, (int) sym_kind, @@ -1932,9 +1932,9 @@ compile_cplus_instance::push_namespace (const char *name) /* See description in gcc-cp-fe.def. */ bool -compile_cplus_instance::pop_namespace (const char *opt_name) +compile_cplus_instance::pop_binding_level (const char *opt_name) { - DECLARE_FORWARD (pop_namespace); + DECLARE_FORWARD (pop_binding_level); return forward ("\"%s\"", opt_name); } @@ -2007,11 +2007,11 @@ compile_cplus_instance::build_array_type (gcc_type element_type, /* See description in gcc-cp-fe.def. */ gcc_decl -compile_cplus_instance::new_field (const char *field_name, gcc_type field_type, - enum gcc_cp_symbol_kind field_flags, - unsigned long bitsize, unsigned long bitpos) +compile_cplus_instance::build_field (const char *field_name, gcc_type field_type, + enum gcc_cp_symbol_kind field_flags, + unsigned long bitsize, unsigned long bitpos) { - DECLARE_FORWARD (new_field, field_name, field_type, field_flags, + DECLARE_FORWARD (build_field, field_name, field_type, field_flags, bitsize, bitpos); return forward ("%s %lld", field_name, field_type); @@ -2033,12 +2033,12 @@ compile_cplus_instance::build_method_type (gcc_type class_type, /* See description in gcc-cp-fe.def. */ gcc_type -compile_cplus_instance::start_class_definition +compile_cplus_instance::start_class_type (const char *name, gcc_decl typedecl, const struct gcc_vbase_array *base_classes, const char *filename, unsigned int line_number) { - DECLARE_FORWARD (start_class_definition, typedecl, base_classes, + DECLARE_FORWARD (start_class_type, typedecl, base_classes, filename, line_number); return forward ("%s", name); @@ -2047,10 +2047,10 @@ compile_cplus_instance::start_class_definition /* See description in gcc-cp-fe.def. */ bool -compile_cplus_instance::finish_record_or_union (const char *name, - unsigned long size_in_bytes) +compile_cplus_instance::finish_class_type (const char *name, + unsigned long size_in_bytes) { - DECLARE_FORWARD (finish_record_or_union, size_in_bytes); + DECLARE_FORWARD (finish_class_type, size_in_bytes); return forward ("%s (%ld)", name, size_in_bytes); } @@ -2058,10 +2058,10 @@ compile_cplus_instance::finish_record_or_union (const char *name, /* See description in gcc-cp-fe.def. */ gcc_type -compile_cplus_instance::int_type (bool is_unsigned, unsigned long size_in_bytes, - const char *builtin_name) +compile_cplus_instance::get_int_type (bool is_unsigned, unsigned long size_in_bytes, + const char *builtin_name) { - DECLARE_FORWARD (int_type, is_unsigned, size_in_bytes, builtin_name); + DECLARE_FORWARD (get_int_type, is_unsigned, size_in_bytes, builtin_name); return forward ("%d %ld %s", is_unsigned, size_in_bytes, builtin_name); } @@ -2069,13 +2069,13 @@ compile_cplus_instance::int_type (bool is_unsigned, unsigned long size_in_bytes, /* See description in gcc-cp-fe.def. */ gcc_type -compile_cplus_instance::start_new_enum_type (const char *name, - gcc_type underlying_int_type, - enum gcc_cp_symbol_kind flags, - const char *filename, - unsigned int line_number) +compile_cplus_instance::start_enum_type (const char *name, + gcc_type underlying_int_type, + enum gcc_cp_symbol_kind flags, + const char *filename, + unsigned int line_number) { - DECLARE_FORWARD (start_new_enum_type, name, underlying_int_type, + DECLARE_FORWARD (start_enum_type, name, underlying_int_type, flags, filename, line_number); return forward ("%s", name); @@ -2084,11 +2084,11 @@ compile_cplus_instance::start_new_enum_type (const char *name, /* See description in gcc-cp-fe.def. */ gcc_decl -compile_cplus_instance::build_add_enum_constant (gcc_type enum_type, - const char *name, - unsigned long value) +compile_cplus_instance::build_enum_constant (gcc_type enum_type, + const char *name, + unsigned long value) { - DECLARE_FORWARD (build_add_enum_constant, enum_type, name, value); + DECLARE_FORWARD (build_enum_constant, enum_type, name, value); return forward ("%s = %ld", name, value); } @@ -2119,9 +2119,9 @@ compile_cplus_instance::build_function_type /* See description in gcc-cp-fe.def. */ gcc_type -compile_cplus_instance::char_type () +compile_cplus_instance::get_char_type () { - DECLARE_FORWARD (char_type); + DECLARE_FORWARD (get_char_type); return forward (""); } @@ -2129,10 +2129,10 @@ compile_cplus_instance::char_type () /* See description in gcc-cp-fe.def. */ gcc_type -compile_cplus_instance::float_type (unsigned long size_in_bytes, - const char *builtin_name) +compile_cplus_instance::get_float_type (unsigned long size_in_bytes, + const char *builtin_name) { - DECLARE_FORWARD (float_type, size_in_bytes, builtin_name); + DECLARE_FORWARD (get_float_type, size_in_bytes, builtin_name); return forward ("%ld %s", size_in_bytes, builtin_name); } @@ -2140,9 +2140,9 @@ compile_cplus_instance::float_type (unsigned long size_in_bytes, /* See description in gcc-cp-fe.def. */ gcc_type -compile_cplus_instance::void_type () +compile_cplus_instance::get_void_type () { - DECLARE_FORWARD (void_type); + DECLARE_FORWARD (get_void_type); return forward (""); } @@ -2150,9 +2150,9 @@ compile_cplus_instance::void_type () /* See description in gcc-cp-fe.def. */ gcc_type -compile_cplus_instance::bool_type () +compile_cplus_instance::get_bool_type () { - DECLARE_FORWARD (bool_type); + DECLARE_FORWARD (get_bool_type); return forward (""); } @@ -2181,9 +2181,9 @@ compile_cplus_instance::build_complex_type (gcc_type element_type) /* See description in gcc-cp-fe.def. */ gcc_expr -compile_cplus_instance::literal_expr (gcc_type type, unsigned long value) +compile_cplus_instance::build_literal_expr (gcc_type type, unsigned long value) { - DECLARE_FORWARD (literal_expr, type, value); + DECLARE_FORWARD (build_literal_expr, type, value); return forward ("%lld %ld", type, value); } @@ -2191,12 +2191,12 @@ compile_cplus_instance::literal_expr (gcc_type type, unsigned long value) /* See description in gcc-cp-fe.def. */ gcc_type -compile_cplus_instance::new_template_typename_parm (const char *id, bool pack_p, - gcc_type default_type, - const char *filename, - unsigned int line_number) +compile_cplus_instance::build_type_template_parameter (const char *id, bool pack_p, + gcc_type default_type, + const char *filename, + unsigned int line_number) { - DECLARE_FORWARD (new_template_typename_parm, id, pack_p, + DECLARE_FORWARD (build_type_template_parameter, id, pack_p, default_type, filename, line_number); return forward ("%s %d %lld %s %d", id, pack_p, default_type, @@ -2206,12 +2206,12 @@ compile_cplus_instance::new_template_typename_parm (const char *id, bool pack_p, /* See description in gcc-cp-fe.def. */ gcc_decl -compile_cplus_instance::new_template_value_parm (gcc_type type, const char *id, - gcc_expr default_value, - const char *filename, - unsigned int line_number) +compile_cplus_instance::build_value_template_parameter (gcc_type type, const char *id, + gcc_expr default_value, + const char *filename, + unsigned int line_number) { - DECLARE_FORWARD (new_template_value_parm, type, id, + DECLARE_FORWARD (build_value_template_parameter, type, id, default_value, filename, line_number); return forward ("%lld %s %lld %s %d", type, id, default_value, @@ -2221,9 +2221,9 @@ compile_cplus_instance::new_template_value_parm (gcc_type type, const char *id, /* See description in gcc-cp-fe.def. */ bool -compile_cplus_instance::start_new_template_decl (const char *generic) +compile_cplus_instance::start_template_decl (const char *generic) { - DECLARE_FORWARD (start_new_template_decl); + DECLARE_FORWARD (start_template_decl); return forward ("for generic %s\n", generic); } diff --git a/gdb/compile/compile-cplus.h b/gdb/compile/compile-cplus.h index a633fb8687d..5d7a7b67777 100644 --- a/gdb/compile/compile-cplus.h +++ b/gdb/compile/compile-cplus.h @@ -185,10 +185,10 @@ namespace compile /* !!keiths: YUCK! Plug-in forwards */ - gcc_type bool_type (); + gcc_type get_bool_type (); - gcc_decl build_add_enum_constant (gcc_type enum_type, const char *name, - unsigned long value); + gcc_decl build_enum_constant (gcc_type enum_type, const char *name, + unsigned long value); gcc_type build_array_type (gcc_type element_type, int num_elements); @@ -221,73 +221,73 @@ namespace compile gcc_type build_vector_type (gcc_type element_type, int num_elements); - gcc_type char_type (); + gcc_type get_char_type (); gcc_type error (const char *message); bool finish_enum_type (gcc_type enum_type); /* NAME for debugging */ - bool finish_record_or_union (const char *name, unsigned long size_in_bytes); + bool finish_class_type (const char *name, unsigned long size_in_bytes); - gcc_type float_type (unsigned long size_in_bytes, const char *builtin_name); + gcc_type get_float_type (unsigned long size_in_bytes, const char *builtin_name); - gcc_type int_type (bool is_unsigned, unsigned long size_in_bytes, + gcc_type get_int_type (bool is_unsigned, unsigned long size_in_bytes, const char *builtin_name); - gcc_expr literal_expr (gcc_type type, unsigned long value); + gcc_expr build_literal_expr (gcc_type type, unsigned long value); /* DECL_DESC for debugging only */ - gcc_decl new_decl (const char *decl_desc, const char *name, - enum gcc_cp_symbol_kind sym_kind, - gcc_type sym_type, const char *substitution_name, - gcc_address address, - const char *filename, unsigned int line_number); - - gcc_decl new_field (const char *field_name, gcc_type field_type, - enum gcc_cp_symbol_kind field_flags, - unsigned long bitsize, unsigned long bitpos); - - gcc_type new_template_typename_parm (const char *id, bool pack_p, - gcc_type default_type, - const char *filename, - unsigned int line_number); - - gcc_decl new_template_value_parm (gcc_type type, const char *id, - gcc_expr default_value, - const char *filename, - unsigned int line_number); + 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, + gcc_address address, + const char *filename, unsigned int line_number); + + gcc_decl build_field (const char *field_name, gcc_type field_type, + enum gcc_cp_symbol_kind field_flags, + unsigned long bitsize, unsigned long bitpos); + + gcc_type build_type_template_parameter (const char *id, bool pack_p, + gcc_type default_type, + const char *filename, + unsigned int line_number); + + gcc_decl build_value_template_parameter (gcc_type type, const char *id, + gcc_expr default_value, + const char *filename, + unsigned int line_number); /* NAME is for debugging only */ - bool pop_namespace (const char *name); + bool pop_binding_level (const char *name); bool push_namespace (const char *name); - gcc_decl specialize_class_template (struct type *concrete, - const char *filename, - unsigned int line_number); + gcc_decl build_class_template_specialization (struct type *concrete, + const char *filename, + unsigned int line_number); - gcc_decl specialize_function_template (struct template_symbol *concrete, - gcc_address address, - const char *filename, - unsigned int line_number); + gcc_decl build_function_template_specialization (struct template_symbol *concrete, + gcc_address address, + const char *filename, + unsigned int line_number); /* NAME only for debugging */ - gcc_type start_class_definition (const char *name, gcc_decl typedecl, - const struct gcc_vbase_array *base_classes, - const char *filename, - unsigned int line_number); + gcc_type start_class_type (const char *name, gcc_decl typedecl, + const struct gcc_vbase_array *base_classes, + const char *filename, + unsigned int line_number); - gcc_type start_new_enum_type (const char *name, - gcc_type underlying_int_type, - enum gcc_cp_symbol_kind flags, - const char *filename, - unsigned int line_number); + gcc_type start_enum_type (const char *name, + gcc_type underlying_int_type, + enum gcc_cp_symbol_kind flags, + const char *filename, + unsigned int line_number); /* GENERIC only for debugging */ - bool start_new_template_decl (const char *generic); + bool start_template_decl (const char *generic); - gcc_type void_type (); + gcc_type get_void_type (); private: diff --git a/include/gcc-cp-fe.def b/include/gcc-cp-fe.def index 7fcd484cee7..f6d0a41d98d 100644 --- a/include/gcc-cp-fe.def +++ b/include/gcc-cp-fe.def @@ -1,6 +1,6 @@ /* Interface between GCC C++ FE and GDB -*- c -*- - Copyright (C) 2014-2016 Free Software Foundation, Inc. + Copyright (C) 2014-2017 Free Software Foundation, Inc. This file is part of GCC. @@ -25,11 +25,8 @@ namespace. A namespace named NAME is created in the current scope, if needed. - If the newly-created namespace is to be an inline namespace, after - push_namespace, get the nested namespace decl with - get_current_binding_level, pop back to the enclosing namespace, - call using_namespace with INLINE_P, and then push to the inline - namespace again. */ + If the newly-created namespace is to be an inline namespace, see + make_namespace_inline. */ GCC_METHOD1 (int /* bool */, push_namespace, const char *) /* Argument NAME. */ @@ -151,8 +148,8 @@ GCC_METHOD1 (int /* bool */, push_function, scope will have to be reentered in order to define the class. . If the code snippet is at point 2, we don't need to (re)activate - anything declaration: nothing from any local scope is visible. - Just entering the scope of the class containing member function f + any declaration: nothing from any local scope is visible. Just + entering the scope of the class containing member function f reactivates the names of its members, including the class name itself. */ @@ -165,22 +162,26 @@ GCC_METHOD2 (int /* bool */, reactivate_decl, push_function, restoring the binding level in effect before the matching push_* call. */ -GCC_METHOD0 (int /* bool */, pop_namespace) +GCC_METHOD0 (int /* bool */, pop_binding_level) /* Return the NAMESPACE_DECL, TYPE_DECL or FUNCTION_DECL of the - binding level that would be popped by pop_namespace. */ + binding level that would be popped by pop_scope. */ -GCC_METHOD0 (gcc_decl, get_current_binding_level) +GCC_METHOD0 (gcc_decl, get_current_binding_level_decl) + +/* Make the current binding level an inline namespace. It must be a + namespace to begin with. It is safe to call this more than once + for the same namespace, but after the first call, subsequent ones + will not return a success status. */ + +GCC_METHOD0 (int /* bool */, make_namespace_inline) /* Add USED_NS to the namespaces used by the current binding level. - Use get_current_binding_level to obtain USED_NS's gcc_decl. - INLINE_P indicates USED_NS was declared as an inline namespace, or - the presence of attribute strong in the using directive, which - is an older but equivalent GCC extension. */ + Use get_current_binding_level_decl to obtain USED_NS's + gcc_decl. */ -GCC_METHOD2 (int /* bool */, using_namespace, - gcc_decl, /* Argument USED_NS. */ - int /* bool */) /* Argument INLINE_P. */ +GCC_METHOD1 (int /* bool */, add_using_namespace, + gcc_decl) /* Argument USED_NS. */ /* Introduce a namespace alias declaration, as in: @@ -188,9 +189,9 @@ GCC_METHOD2 (int /* bool */, using_namespace, After this call, namespace TARGET will be visible as ALIAS within the current namespace. Get the declaration for TARGET by calling - get_current_binding_level after pushing into it. */ + get_current_binding_level_decl after pushing into it. */ -GCC_METHOD2 (int /* bool */, new_namespace_alias, +GCC_METHOD2 (int /* bool */, add_namespace_alias, const char *, /* Argument ALIAS. */ gcc_decl) /* Argument TARGET. */ @@ -209,9 +210,9 @@ GCC_METHOD2 (int /* bool */, new_namespace_alias, Even when TARGET is template dependent, we don't need to specify whether or not it is a typename: the supplied declaration (that could be a template-dependent type converted to declaration by - type_decl) indicates so. */ + get_type_decl) indicates so. */ -GCC_METHOD2 (int /* bool */, new_using_decl, +GCC_METHOD2 (int /* bool */, add_using_decl, enum gcc_cp_symbol_kind, /* Argument FLAGS. */ gcc_decl) /* Argument TARGET. */ @@ -232,6 +233,9 @@ GCC_METHOD2 (int /* bool */, new_using_decl, Use this function to register typedefs, functions and variables to namespace and local binding levels, and typedefs, member functions (static or not), and static data members to class binding levels. + Class members must have their access controls specified with + GCC_CP_ACCESS_* flags in SYM_KIND. + Note that, since access controls are disabled, we have no means to express private, protected and public. @@ -264,18 +268,18 @@ GCC_METHOD2 (int /* bool */, new_using_decl, Constructors and destructors need special care, because for each constructor and destructor there may be multiple clones defined - internally by the compiler. With new_decl, you can introduce the + internally by the compiler. With build_decl, you can introduce the base declaration of a constructor or a destructor, setting GCC_CP_FLAG_SPECIAL_FUNCTION the flag and using names starting with capital "C" or "D", respectively, followed by a digit (see below), a blank, or NUL ('\0'). DO NOT supply an ADDRESS or a - SUBSTITUTION_NAME to new_decl, it would be meaningless (and + SUBSTITUTION_NAME to build_decl, it would be meaningless (and rejected) for the base declaration; use define_cdtor_clone to introduce the address of each clone. For constructor templates, - declare the template with new_decl, and then, for each - specialization, introduce it with specialize_function_template, and - then define the addresses of each of its clones with - define_cdtor_clone. + declare the template with build_decl, and then, for each + specialization, introduce it with + build_function_template_specialization, and then define the + addresses of each of its clones with define_cdtor_clone. NAMEs for GCC_CP_FLAG_SPECIAL_FUNCTION: @@ -334,7 +338,7 @@ GCC_METHOD2 (int /* bool */, new_using_decl, FIXME: How about attributes? */ -GCC_METHOD7 (gcc_decl, new_decl, +GCC_METHOD7 (gcc_decl, build_decl, const char *, /* Argument NAME. */ enum gcc_cp_symbol_kind, /* Argument SYM_KIND. */ gcc_type, /* Argument SYM_TYPE. */ @@ -344,8 +348,8 @@ GCC_METHOD7 (gcc_decl, new_decl, unsigned int) /* Argument LINE_NUMBER. */ /* Supply the ADDRESS of one of the multiple clones of constructor or - destructor CDTOR. The clone is selected using the following - name mangling conventions: + destructor CDTOR. The clone is specified by NAME, using the + following name mangling conventions: C1 in-charge constructor C2 not-in-charge constructor @@ -372,8 +376,8 @@ GCC_METHOD7 (gcc_decl, new_decl, The [CD]4 manglings (and symbol definitions) are non-standard, but GCC uses them in some cases: rather than assuming they are in-charge or not-in-charge, they test the implicit argument that - the others ignore to tell how to behave. These are defined in very - rare cases of virtual inheritance and cdtor prototypes. */ + the others ignore to tell how to behave. These are used instead of + cloning when we just can't use aliases. */ GCC_METHOD3 (gcc_decl, define_cdtor_clone, const char *, /* Argument NAME. */ @@ -383,18 +387,18 @@ GCC_METHOD3 (gcc_decl, define_cdtor_clone, /* Return the type associated with the given declaration. This is most useful to obtain the type associated with a forward-declared class, because it is the gcc_type, rather than the gcc_decl, that - has to be used to build other types, but new_decl returns a + has to be used to build other types, but build_decl returns a gcc_decl rather than a gcc_type. This call can in theory be used to obtain the type from any other declaration; it is supposed to return the same type that was supplied when the declaration was created. */ -GCC_METHOD1 (gcc_type, decl_type, +GCC_METHOD1 (gcc_type, get_decl_type, gcc_decl) /* Argument DECL. */ /* Return the declaration for a type. */ -GCC_METHOD1 (gcc_decl, type_decl, +GCC_METHOD1 (gcc_decl, get_type_decl, gcc_type) /* Argument TYPE. */ /* Declare DECL as a friend of the current class scope, if TYPE is @@ -437,11 +441,11 @@ GCC_METHOD1 (gcc_decl, type_decl, In order to simplify such friend declarations, and to enable incremental friend declarations as template specializations are - introduced, new_friend can be called after the befriended class is + introduced, new_friend can be called after the befriending class is fully defined, passing it a non-NULL TYPE argument naming the - befriended class type. */ + befriending class type. */ -GCC_METHOD2 (int /* bool */, new_friend, +GCC_METHOD2 (int /* bool */, add_friend, gcc_decl, /* Argument DECL. */ gcc_type) /* Argument TYPE. */ @@ -467,14 +471,14 @@ GCC_METHOD2 (gcc_type, build_pointer_to_member_type, gcc_type) /* Argument MEMBER_TYPE. */ /* Start a template parameter list, so that subsequent - build_template_typename_parm and build_template_value_parm calls - create template parameters in the list. The list is closed by a - new_decl call with GCC_CP_SYMBOL_FUNCTION or GCC_CP_SYMBOL_CLASS, - that, when the scope is a template parameter list, closes the - parameter list and declares a template function or a template class - with the parameter list. */ + build_type_template_parameter and build_value_template_parameter + calls create template parameters in the list. The list is closed + by a build_decl call with GCC_CP_SYMBOL_FUNCTION or + GCC_CP_SYMBOL_CLASS, that, when the scope is a template parameter + list, closes the parameter list and declares a template function or + a template class with the parameter list. */ -GCC_METHOD0 (int /* bool */, start_new_template_decl) +GCC_METHOD0 (int /* bool */, start_template_decl) /* Build a typename template-parameter (e.g., the T in template ). Either PACK_P should be nonzero, to indicate an @@ -484,7 +488,7 @@ GCC_METHOD0 (int /* bool */, start_new_template_decl) parameter. FILENAME and LINE_NUMBER may specify the source location in which the template parameter was declared. */ -GCC_METHOD5 (gcc_type, new_template_typename_parm, +GCC_METHOD5 (gcc_type, build_type_template_parameter, const char *, /* Argument ID. */ int /* bool */, /* Argument PACK_P. */ gcc_type, /* Argument DEFAULT_TYPE. */ @@ -497,7 +501,7 @@ GCC_METHOD5 (gcc_type, new_template_typename_parm, template parameter. FILENAME and LINE_NUMBER may specify the source location in which the template parameter was declared. */ -GCC_METHOD5 (gcc_utempl, new_template_template_parm, +GCC_METHOD5 (gcc_utempl, build_template_template_parameter, const char *, /* Argument ID. */ int /* bool */, /* Argument PACK_P. */ gcc_utempl, /* Argument DEFAULT_TEMPL. */ @@ -510,7 +514,7 @@ GCC_METHOD5 (gcc_utempl, new_template_template_parm, X). FILENAME and LINE_NUMBER may specify the source location in which the template parameter was declared. */ -GCC_METHOD5 (gcc_decl, new_template_value_parm, +GCC_METHOD5 (gcc_decl, build_value_template_parameter, gcc_type, /* Argument TYPE. */ const char *, /* Argument ID. */ gcc_expr, /* Argument DEFAULT_VALUE. */ @@ -525,13 +529,13 @@ GCC_METHOD5 (gcc_decl, new_template_value_parm, (e.g. ) iff ID is to name a class template. In this and other calls, a template-dependent nested name specifier - may be a template class parameter (new_template_typename_parm), a - specialization (returned by new_dependent_typespec) of a template - template parameter (returned by new_template_template_parm) or a - member type thereof (returned by new_dependent_typename - itself). */ + may be a template class parameter (build_type_template_parameter), + a specialization (returned by build_dependent_type_template_id) of + a template template parameter (returned by + build_template_template_parameter) or a member type thereof + (returned by build_dependent_typename itself). */ -GCC_METHOD3 (gcc_type, new_dependent_typename, +GCC_METHOD3 (gcc_type, build_dependent_typename, gcc_type, /* Argument ENCLOSING_TYPE. */ const char *, /* Argument ID. */ const struct gcc_cp_template_args *) /* Argument TARGS. */ @@ -541,21 +545,21 @@ GCC_METHOD3 (gcc_type, new_dependent_typename, specifier (e.g., T), ID should be the name of the class template member of the ENCLOSING_TYPE (e.g., bart). */ -GCC_METHOD2 (gcc_utempl, new_dependent_class_template, +GCC_METHOD2 (gcc_utempl, build_dependent_class_template, gcc_type, /* Argument ENCLOSING_TYPE. */ const char *) /* Argument ID. */ -/* Build a template-dependent template type specialization (e.g., - T). TEMPLATE_DECL should be a template template parameter - (e.g., the T in template