struct collect_info *info,
struct program_space *pspace);
-static void add_all_symbol_names_from_pspace (struct collect_info *info,
- struct program_space *pspace,
- VEC (const_char_ptr) *names,
- enum search_domain search_domain);
+static void add_all_symbol_names_from_pspace
+ (struct collect_info *info, struct program_space *pspace,
+ const std::vector<const char *> &names, enum search_domain search_domain);
static VEC (symtab_ptr) *
collect_symtabs_from_filename (const char *file,
static void
find_methods (struct type *t, enum language t_lang, const char *name,
- VEC (const_char_ptr) **result_names,
+ std::vector<const char *> *result_names,
VEC (typep) **superclasses)
{
int ibase;
if (TYPE_FN_FIELD_STUB (f, field_counter))
continue;
phys_name = TYPE_FN_FIELD_PHYSNAME (f, field_counter);
- VEC_safe_push (const_char_ptr, *result_names, phys_name);
+ result_names->push_back (phys_name);
}
}
}
decode_objc (struct linespec_state *self, linespec_p ls, const char *arg)
{
struct collect_info info;
- VEC (const_char_ptr) *symbol_names = NULL;
+ std::vector<const char *> symbol_names;
const char *new_argptr;
- struct cleanup *cleanup = make_cleanup (VEC_cleanup (const_char_ptr),
- &symbol_names);
info.state = self;
info.file_symtabs = NULL;
VEC_safe_push (symtab_ptr, info.file_symtabs, NULL);
- make_cleanup (VEC_cleanup (symtab_ptr), &info.file_symtabs);
+ struct cleanup *cleanup = make_cleanup (VEC_cleanup (symtab_ptr),
+ &info.file_symtabs);
info.result.symbols = NULL;
info.result.minimal_symbols = NULL;
new_argptr = find_imps (arg, &symbol_names);
- if (VEC_empty (const_char_ptr, symbol_names))
+ if (symbol_names.empty ())
{
do_cleanups (cleanup);
return {};
static void
add_all_symbol_names_from_pspace (struct collect_info *info,
struct program_space *pspace,
- VEC (const_char_ptr) *names,
+ const std::vector<const char *> &names,
enum search_domain search_domain)
{
- int ix;
- const char *iter;
-
- for (ix = 0; VEC_iterate (const_char_ptr, names, ix, iter); ++ix)
+ for (const char *iter : names)
add_matching_symbols_to_info (iter,
symbol_name_match_type::FULL,
search_domain, info, pspace);
static void
find_superclass_methods (VEC (typep) *superclasses,
const char *name, enum language name_lang,
- VEC (const_char_ptr) **result_names)
+ std::vector<const char *> *result_names)
{
- int old_len = VEC_length (const_char_ptr, *result_names);
+ size_t old_len = result_names->size ();
VEC (typep) *iter_classes;
struct cleanup *cleanup = make_cleanup (null_cleanup, NULL);
for (ix = 0; VEC_iterate (typep, iter_classes, ix, t); ++ix)
find_methods (t, name_lang, name, result_names, &new_supers);
- if (VEC_length (const_char_ptr, *result_names) != old_len
- || VEC_empty (typep, new_supers))
+ if (result_names->size () != old_len || VEC_empty (typep, new_supers))
break;
iter_classes = new_supers;
struct symbol *sym;
struct cleanup *cleanup = make_cleanup (null_cleanup, NULL);
int ix;
- int last_result_len;
+ size_t last_result_len;
VEC (typep) *superclass_vec;
- VEC (const_char_ptr) *result_names;
+ std::vector<const char *> result_names;
struct collect_info info;
/* Sort symbols so that symbols with the same program space are next
what to do. */
superclass_vec = NULL;
make_cleanup (VEC_cleanup (typep), &superclass_vec);
- result_names = NULL;
- make_cleanup (VEC_cleanup (const_char_ptr), &result_names);
last_result_len = 0;
for (ix = 0; VEC_iterate (symbolp, sym_classes, ix, sym); ++ix)
{
{
/* If we did not find a direct implementation anywhere in
this program space, consider superclasses. */
- if (VEC_length (const_char_ptr, result_names) == last_result_len)
+ if (result_names.size () == last_result_len)
find_superclass_methods (superclass_vec, method_name,
SYMBOL_LANGUAGE (sym), &result_names);
FUNCTIONS_DOMAIN);
VEC_truncate (typep, superclass_vec, 0);
- last_result_len = VEC_length (const_char_ptr, result_names);
+ last_result_len = result_names.size ();
}
}
VEC (bound_minimal_symbol_d) **minsyms)
{
struct collect_info info;
- VEC (const_char_ptr) *symbol_names = NULL;
- struct cleanup *cleanup = make_cleanup (VEC_cleanup (const_char_ptr),
- &symbol_names);
+ std::vector<const char *> symbol_names;
info.state = state;
info.result.symbols = NULL;
/* Try NAME as an Objective-C selector. */
find_imps (name, &symbol_names);
- if (!VEC_empty (const_char_ptr, symbol_names))
+ if (!symbol_names.empty ())
add_all_symbol_names_from_pspace (&info, state->search_pspace,
symbol_names, FUNCTIONS_DOMAIN);
else
add_matching_symbols_to_info (name, name_match_type, FUNCTIONS_DOMAIN,
&info, state->search_pspace);
- do_cleanups (cleanup);
-
if (VEC_empty (symbolp, info.result.symbols))
{
VEC_free (symbolp, info.result.symbols);
#include "cli/cli-utils.h"
#include <ctype.h>
+#include <algorithm>
struct objc_object {
CORE_ADDR isa;
static void
find_methods (char type, const char *theclass, const char *category,
const char *selector,
- VEC (const_char_ptr) **symbol_names)
+ std::vector<const char *> *symbol_names)
{
struct objfile *objfile = NULL;
((nselector == NULL) || (strcmp (selector, nselector) != 0)))
continue;
- VEC_safe_push (const_char_ptr, *symbol_names, symname);
+ symbol_names->push_back (symname);
}
if (objc_csym == NULL)
/* Uniquify a VEC of strings. */
static void
-uniquify_strings (VEC (const_char_ptr) **strings)
+uniquify_strings (std::vector<const char *> *strings)
{
- int ix;
- const char *elem, *last = NULL;
- int out;
-
- /* If the vector is empty, there's nothing to do. This explicit
- check is needed to avoid invoking qsort with NULL. */
- if (VEC_empty (const_char_ptr, *strings))
+ if (strings->empty ())
return;
- qsort (VEC_address (const_char_ptr, *strings),
- VEC_length (const_char_ptr, *strings),
- sizeof (const_char_ptr),
- compare_strings);
- out = 0;
- for (ix = 0; VEC_iterate (const_char_ptr, *strings, ix, elem); ++ix)
- {
- if (last == NULL || strcmp (last, elem) != 0)
- {
- /* Keep ELEM. */
- VEC_replace (const_char_ptr, *strings, out, elem);
- ++out;
- }
- last = elem;
- }
- VEC_truncate (const_char_ptr, *strings, out);
+ std::sort (strings->begin (), strings->end (), compare_cstrings);
+ strings->erase (std::unique (strings->begin (), strings->end (), streq),
+ strings->end ());
}
/*
*/
const char *
-find_imps (const char *method, VEC (const_char_ptr) **symbol_names)
+find_imps (const char *method, std::vector<const char *> *symbol_names)
{
char type = '\0';
char *theclass = NULL;
/* If we hit the "selector" case, and we found some methods, then
add the selector itself as a symbol, if it exists. */
- if (selector_case && !VEC_empty (const_char_ptr, *symbol_names))
+ if (selector_case && !symbol_names->empty ())
{
struct symbol *sym = lookup_symbol (selector, NULL, VAR_DOMAIN,
0).symbol;
if (sym != NULL)
- VEC_safe_push (const_char_ptr, *symbol_names,
- SYMBOL_NATURAL_NAME (sym));
+ symbol_names->push_back (SYMBOL_NATURAL_NAME (sym));
else
{
struct bound_minimal_symbol msym
= lookup_minimal_symbol (selector, 0, 0);
if (msym.minsym != NULL)
- VEC_safe_push (const_char_ptr, *symbol_names,
- MSYMBOL_NATURAL_NAME (msym.minsym));
+ symbol_names->push_back (MSYMBOL_NATURAL_NAME (msym.minsym));
}
}