static void c_type_print_template_args (const struct type_print_options *flags, struct type *type, struct ui_file *stream) { int first = 1, i; if (flags->raw) return; for (i = 0; i < TYPE_N_TEMPLATE_ARGUMENTS (type); ++i) { struct symbol *sym = TYPE_TEMPLATE_ARGUMENT (type, i); if (SYMBOL_CLASS (sym) != LOC_TYPEDEF) continue; if (first) { wrap_here (" "); fprintf_filtered (stream, _("[with %s = "), SYMBOL_LINKAGE_NAME (sym)); first = 0; } else { fputs_filtered (", ", stream); wrap_here (" "); fprintf_filtered (stream, "%s = ", SYMBOL_LINKAGE_NAME (sym)); } c_print_type (SYMBOL_TYPE (sym), "", stream, -1, 0, flags); } if (!first) fputs_filtered (_("] "), stream); }
struct block_symbol cp_lookup_symbol_imports_or_template (const char *scope, const char *name, const struct block *block, const domain_enum domain) { struct symbol *function = BLOCK_FUNCTION (block); struct block_symbol result; if (symbol_lookup_debug) { fprintf_unfiltered (gdb_stdlog, "cp_lookup_symbol_imports_or_template" " (%s, %s, %s, %s)\n", scope, name, host_address_to_string (block), domain_name (domain)); } if (function != NULL && SYMBOL_LANGUAGE (function) == language_cplus) { /* Search the function's template parameters. */ if (SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION (function)) { struct template_symbol *templ = (struct template_symbol *) function; struct symbol *sym = search_symbol_list (name, templ->n_template_arguments, templ->template_arguments); if (sym != NULL) { if (symbol_lookup_debug) { fprintf_unfiltered (gdb_stdlog, "cp_lookup_symbol_imports_or_template" " (...) = %s\n", host_address_to_string (sym)); } return (struct block_symbol) {sym, block}; } } /* Search the template parameters of the function's defining context. */ if (SYMBOL_NATURAL_NAME (function)) { struct type *context; char *name_copy = xstrdup (SYMBOL_NATURAL_NAME (function)); struct cleanup *cleanups = make_cleanup (xfree, name_copy); const struct language_defn *lang = language_def (language_cplus); struct gdbarch *arch = symbol_arch (function); const struct block *parent = BLOCK_SUPERBLOCK (block); struct symbol *sym; while (1) { unsigned int prefix_len = cp_entire_prefix_len (name_copy); if (prefix_len == 0) context = NULL; else { name_copy[prefix_len] = '\0'; context = lookup_typename (lang, arch, name_copy, parent, 1); } if (context == NULL) break; sym = search_symbol_list (name, TYPE_N_TEMPLATE_ARGUMENTS (context), TYPE_TEMPLATE_ARGUMENTS (context)); if (sym != NULL) { do_cleanups (cleanups); if (symbol_lookup_debug) { fprintf_unfiltered (gdb_stdlog, "cp_lookup_symbol_imports_or_template (...) = %s\n", host_address_to_string (sym)); } return (struct block_symbol) {sym, parent}; } } do_cleanups (cleanups); } }