23#include "gdbsupport/gdb_obstack.h"
41 const char *nested_name,
42 const char *concatenated_name,
45 int basic_lookup,
int is_in_anonymous);
62 unsigned int previous_component;
63 unsigned int next_component;
71 previous_component = 0;
74 while (
name[next_component] ==
':')
76 if (((next_component - previous_component)
78 && strncmp (
name + previous_component,
82 int dest_len = (previous_component == 0
83 ? 0 : previous_component - 2);
84 int src_len = next_component;
86 char *dest = (
char *) alloca (dest_len + 1);
87 char *src = (
char *) alloca (src_len + 1);
89 memcpy (dest,
name, dest_len);
90 memcpy (src,
name, src_len);
92 dest[dest_len] =
'\0';
101 std::vector<const char *> excludes;
103 dest, src, NULL, NULL, excludes, 0,
107 previous_component = next_component + 2;
108 next_component = (previous_component
110 + previous_component));
181 gdb_assert (strpbrk (
"<>()",
name) !=
nullptr
182 || strstr (
name,
"::") ==
nullptr);
223 if (lang_this.
symbol == NULL)
254 unsigned int prefix_len,
258 if (prefix_len + 2 > strlen (
name) ||
name[prefix_len + 1] !=
':')
267 const char *nested =
name + prefix_len + 2;
276 if (scope_sym.
symbol == NULL)
278 if (scope_sym.
symbol == NULL)
285 if ((scope_type->
code () == TYPE_CODE_FUNC
286 || scope_type->
code () == TYPE_CODE_METHOD)
295 block, domain, 0, is_in_anonymous);
312 char *concatenated_name = NULL;
314 unsigned int prefix_len;
317 if (the_namespace[0] !=
'\0')
320 = (
char *) alloca (strlen (the_namespace) + 2 + strlen (
name) + 1);
321 strcpy (concatenated_name, the_namespace);
322 strcat (concatenated_name,
"::");
323 strcat (concatenated_name,
name);
324 name = concatenated_name;
385 const int search_scope_first,
386 const int declaration_only,
387 const int search_parents,
388 std::map<std::string,
402 if (search_scope_first)
406 if (sym.
symbol !=
nullptr)
419 current = current->
next)
421 const char **excludep;
428 directive_match = (search_parents
432 || scope[len] ==
'\0'))
437 if (directive_match && !current->
searched)
441 scoped_restore reset_directive_searched
442 = make_scoped_restore (¤t->
searched, 1);
468 for (excludep = current->
excludes; *excludep; excludep++)
469 if (strcmp (
name, *excludep) == 0)
474 if (current->
alias != NULL
485 else if (current->
alias == NULL)
491 block, domain, 1, 0, 0,
506 const int declaration_only,
507 const int search_parents)
509 std::map<std::string, struct block_symbol> found_symbols;
512 declaration_only, search_parents,
515 if (found_symbols.size () > 1)
517 auto itr = found_symbols.cbegin ();
518 std::string error_str =
"Reference to \"";
520 error_str +=
"\" is ambiguous, possibilities are: ";
521 error_str += itr->second.symbol->print_name ();
522 for (itr++; itr != found_symbols.end (); itr++)
524 error_str +=
" and ";
525 error_str += itr->second.symbol->print_name ();
527 error (_(
"%s"), error_str.c_str ());
530 if (found_symbols.size() == 1)
531 return found_symbols.cbegin ()->second;
545 for (i = 0; i < num; ++i)
567 (
"cp_lookup_symbol_imports_or_template (%s, %s, %s, %s)",
584 (
"cp_lookup_symbol_imports_or_template (...) = %s",
585 host_address_to_string (sym));
594 struct type *context;
602 unsigned int prefix_len
609 name_copy.erase (prefix_len);
625 (
"cp_lookup_symbol_imports_or_template (...) = %s",
626 host_address_to_string (sym));
637 ? host_address_to_string (result.
symbol) :
"NULL");
652 while (
block != NULL)
655 if (sym.
symbol !=
nullptr)
678 scope,
name, host_address_to_string (
block),
690 ? host_address_to_string (sym.
symbol) :
"NULL");
719 if (
scope[scope_len] !=
'\0')
724 int new_scope_len = scope_len;
727 if (new_scope_len != 0)
729 gdb_assert (scope[new_scope_len] ==
':');
734 scope, new_scope_len);
750 if (scope_len == 0 && strchr (
name,
':') == NULL)
753 the_namespace = (
char *) alloca (scope_len + 1);
754 strncpy (the_namespace, scope, scope_len);
755 the_namespace[scope_len] =
'\0';
776 (
"cp_lookup_symbol_non_local (%s, %s (scope %s), %s)",
789 ? host_address_to_string (sym.
symbol)
807 const char *base_name =
type->
name ();
809 if (base_name == NULL)
812 if (streq (tdef_name,
name) || streq (base_name,
name))
839 if (base_name == NULL)
842 std::string concatenated_name = std::string (base_name) +
"::" +
name;
845 concatenated_name.c_str (),
846 block, domain, 1, is_in_anonymous);
868 const char *nested_name,
869 const char *concatenated_name,
872 int basic_lookup,
int is_in_anonymous)
906 if (!is_in_anonymous)
918 domain, is_in_anonymous);
933 const char *nested_name,
939 struct type *saved_parent_type = parent_type;
945 const char *type_name = saved_parent_type->
name ();
948 type_name != NULL ? type_name :
"unnamed",
949 nested_name, host_address_to_string (
block),
953 switch (parent_type->code ())
955 case TYPE_CODE_STRUCT:
956 case TYPE_CODE_NAMESPACE:
957 case TYPE_CODE_UNION:
962 case TYPE_CODE_MODULE:
967 char *concatenated_name;
970 size = strlen (parent_name) + 2 + strlen (nested_name) + 1;
971 concatenated_name = (
char *) alloca (
size);
972 xsnprintf (concatenated_name,
size,
"%s::%s",
973 parent_name, nested_name);
977 concatenated_name,
block, domain,
982 ? host_address_to_string (sym.
symbol)
988 case TYPE_CODE_METHOD:
990 (
"cp_lookup_nested_symbol (...) = NULL (func/method)");
994 internal_error (_(
"cp_lookup_nested_symbol called "
995 "on a non-aggregate type."));
1031 if (scope[0] ==
'\0')
1051 if (scope[scope_length] ==
':')
1061 full_name = (
char *) alloca (scope_length + 2 + strlen (
name) + 1);
1062 strncpy (full_name, scope, scope_length);
1063 memcpy (full_name + scope_length,
"::", 2);
1064 strcpy (full_name + scope_length + 2,
name);
1075 gdb_printf (_(
"The `maint namespace' command was removed.\n"));
1086 _(
"Deprecated placeholder for removed functionality."),
struct gdbarch * target_gdbarch(void)
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
struct cmd_list_element * deprecate_cmd(struct cmd_list_element *cmd, const char *replacement)
struct block_symbol cp_lookup_symbol_imports_or_template(const char *scope, const char *name, const struct block *block, const domain_enum domain)
static struct block_symbol find_symbol_in_baseclass(struct type *parent_type, const char *name, const struct block *block, const domain_enum domain, int is_in_anonymous)
static void maintenance_cplus_namespace(const char *args, int from_tty)
static struct block_symbol cp_search_static_and_baseclasses(const char *name, const struct block *block, const domain_enum domain, unsigned int prefix_len, int is_in_anonymous)
static struct block_symbol cp_lookup_nested_symbol_1(struct type *container_type, const char *nested_name, const char *concatenated_name, const struct block *block, const domain_enum domain, int basic_lookup, int is_in_anonymous)
static struct block_symbol lookup_namespace_scope(const struct language_defn *langdef, const char *name, const struct block *block, const domain_enum domain, const char *scope, int scope_len)
static void cp_lookup_symbol_via_imports(const char *scope, const char *name, const struct block *block, const domain_enum domain, const int search_scope_first, const int declaration_only, const int search_parents, std::map< std::string, struct block_symbol > &found_symbols)
static struct block_symbol cp_basic_lookup_symbol(const char *name, const struct block *block, const domain_enum domain, int is_in_anonymous)
void cp_scan_for_anonymous_namespaces(struct buildsym_compunit *compunit, const struct symbol *const symbol, struct objfile *const objfile)
static struct block_symbol cp_lookup_bare_symbol(const struct language_defn *langdef, const char *name, const struct block *block, const domain_enum domain, int search)
struct type * cp_lookup_transparent_type(const char *name)
static struct block_symbol cp_lookup_symbol_via_all_imports(const char *scope, const char *name, const struct block *block, const domain_enum domain)
static struct type * cp_lookup_transparent_type_loop(const char *name, const char *scope, int scope_len)
struct type * cp_find_type_baseclass_by_name(struct type *parent_type, const char *name)
struct block_symbol cp_lookup_symbol_namespace(const char *scope, const char *name, const struct block *block, const domain_enum domain)
struct block_symbol cp_lookup_symbol_nonlocal(const struct language_defn *langdef, const char *name, const struct block *block, const domain_enum domain)
void _initialize_cp_namespace()
struct block_symbol cp_lookup_nested_symbol(struct type *parent_type, const char *nested_name, const struct block *block, const domain_enum domain)
int cp_is_in_anonymous(const char *symbol_name)
static struct block_symbol cp_lookup_symbol_in_namespace(const char *the_namespace, const char *name, const struct block *block, const domain_enum domain, int search)
static struct symbol * search_symbol_list(const char *name, int num, struct symbol **syms)
unsigned int cp_find_first_component(const char *name)
unsigned int cp_entire_prefix_len(const char *name)
struct cmd_list_element * maint_cplus_cmd_list
#define CP_ANONYMOUS_NAMESPACE_LEN
#define CP_ANONYMOUS_NAMESPACE_STR
const struct block * get_selected_block(CORE_ADDR *addr_in_block)
struct type * lookup_typename(const struct language_defn *language, const char *name, const struct block *block, int noerr)
const char * type_name_or_error(struct type *type)
struct type * check_typedef(struct type *type)
#define TYPE_BASECLASS_NAME(thistype, index)
#define TYPE_TEMPLATE_ARGUMENTS(thistype)
#define TYPE_BASECLASS(thistype, index)
#define TYPE_N_TEMPLATE_ARGUMENTS(thistype)
#define TYPE_N_BASECLASSES(thistype)
const struct language_defn * language_def(enum language lang)
struct symbol * language_lookup_primitive_type_as_symbol(const struct language_defn *la, struct gdbarch *gdbarch, const char *name)
void add_using_directive(struct using_direct **using_directives, const char *dest, const char *src, const char *alias, const char *declaration, const std::vector< const char * > &excludes, unsigned int decl_line, int copy_names, struct obstack *obstack)
const struct block * block
const block * superblock() const
const struct block * global_block() const
struct gdbarch * gdbarch() const
symbol * function() const
struct using_direct * get_using() const
const char * scope() const
struct using_direct ** get_local_using_directives()
const char * natural_name() const
const char * demangled_name
enum language language() const
auto_obstack objfile_obstack
const block * value_block() const
struct type * type() const
domain_enum domain() const
bool is_cplus_template_function() const
struct symbol ** template_arguments
struct type * target_type() const
const char * name() const
struct using_direct * next
bool valid_line(unsigned int boundary) const
const char * domain_name(domain_enum e)
struct block_symbol lookup_static_symbol(const char *name, const domain_enum domain)
struct block_symbol lookup_symbol(const char *name, const struct block *block, domain_enum domain, struct field_of_this_result *is_a_field_of_this)
struct block_symbol lookup_global_symbol(const char *name, const struct block *block, const domain_enum domain)
struct type * basic_lookup_transparent_type(const char *name)
struct symbol * lookup_symbol_in_block(const char *name, symbol_name_match_type match_type, const struct block *block, const domain_enum domain)
struct block_symbol lookup_symbol_in_static_block(const char *name, const struct block *block, const domain_enum domain)
unsigned int symbol_lookup_debug
struct symtab_and_line find_pc_line(CORE_ADDR pc, int notcurrent)
struct block_symbol lookup_language_this(const struct language_defn *lang, const struct block *block)
#define symbol_lookup_debug_printf(fmt,...)
void gdb_printf(struct ui_file *stream, const char *format,...)