aboutsummaryrefslogtreecommitdiff
path: root/gdb/objc-lang.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-03-31 12:43:56 -0600
committerTom Tromey <tom@tromey.com>2018-04-05 07:39:37 -0600
commit9b2f85815c57d2eb4322a3d87464b5686cdbb391 (patch)
treea2a2fec1a5e608122aa6232fffba1008139a6ed6 /gdb/objc-lang.c
parent459a2e4ccf9aadfba9819facba1c9be5297c1625 (diff)
downloadgdb-9b2f85815c57d2eb4322a3d87464b5686cdbb391.zip
gdb-9b2f85815c57d2eb4322a3d87464b5686cdbb391.tar.gz
gdb-9b2f85815c57d2eb4322a3d87464b5686cdbb391.tar.bz2
More use of std::vector in linespec.c
This changes some spots in linespec.c to take a std::vector. This patch spilled out to objc-lang.c a bit as well. This change allows for the removal of some cleanups. ChangeLog 2018-04-05 Tom Tromey <tom@tromey.com> * utils.c (compare_strings): Remove. * utils.h (compare_strings): Remove. * objc-lang.h (find_imps): Update. * objc-lang.c (find_methods): Take a std::vector. (uniquify_strings, find_imps): Likewise. * linespec.c (find_methods): Take a std::vector. (decode_objc): Use std::vector. (add_all_symbol_names_from_pspace, find_superclass_methods): Take a std::vector. (find_method, find_function_symbols): Use std::vector.
Diffstat (limited to 'gdb/objc-lang.c')
-rw-r--r--gdb/objc-lang.c44
1 files changed, 12 insertions, 32 deletions
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 4f7dc36..8c24fde3 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -45,6 +45,7 @@
#include "cli/cli-utils.h"
#include <ctype.h>
+#include <algorithm>
struct objc_object {
CORE_ADDR isa;
@@ -974,7 +975,7 @@ parse_method (char *method, char *type, char **theclass,
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;
@@ -1050,7 +1051,7 @@ find_methods (char type, const char *theclass, const char *category,
((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)
@@ -1068,33 +1069,14 @@ find_methods (char type, const char *theclass, const char *category,
/* 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 ());
}
/*
@@ -1128,7 +1110,7 @@ uniquify_strings (VEC (const_char_ptr) **strings)
*/
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;
@@ -1161,22 +1143,20 @@ find_imps (const char *method, VEC (const_char_ptr) **symbol_names)
/* 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));
}
}