]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
2003-01-28 David Carlton <carlton@math.stanford.edu>
authorDavid Carlton <carlton@bactrian.org>
Wed, 29 Jan 2003 01:23:20 +0000 (01:23 +0000)
committerDavid Carlton <carlton@bactrian.org>
Wed, 29 Jan 2003 01:23:20 +0000 (01:23 +0000)
* valops.c (find_overload_match): Calculate func_name via
SYMBOL_CPLUS_DEMANGLED_NAME + remove_params.
* symtab.c (remove_params): Make extern.
* symtab.h: Add declaration for remove_params.
* symtab.c (overload_list_add_symbol): Change second arg to const
char *.
* valops.c (find_overload_match) Update call to
make_symbol_overload_list.
* symtab.h: Update declaration for make_symbol_overload_list.
* symtab.c (make_symbol_overload_list): Change arguments.
* valops.c (find_overload_match): Rename cleanups to old_cleanups;
handle freeing func_name via cleanups.

gdb/ChangeLog
gdb/symtab.c
gdb/symtab.h
gdb/valops.c

index 682a91c155cfbd059763601b04600d3a7c636cff..052f9a34364e021e458beeb60eb55e23828a42da 100644 (file)
@@ -1,3 +1,18 @@
+2003-01-28  David Carlton  <carlton@math.stanford.edu>
+
+       * valops.c (find_overload_match): Calculate func_name via
+       SYMBOL_CPLUS_DEMANGLED_NAME + remove_params.
+       * symtab.c (remove_params): Make extern.
+       * symtab.h: Add declaration for remove_params.
+       * symtab.c (overload_list_add_symbol): Change second arg to const
+       char *.
+       * valops.c (find_overload_match) Update call to
+       make_symbol_overload_list.
+       * symtab.h: Update declaration for make_symbol_overload_list.
+       * symtab.c (make_symbol_overload_list): Change arguments.
+       * valops.c (find_overload_match): Rename cleanups to old_cleanups;
+       handle freeing func_name via cleanups.
+
 2003-01-27  David Carlton  <carlton@math.stanford.edu>
 
        * objfiles.h: Add comments about objfile->msymbols being NULL.
index 730e27085d15fa48169e95a177f658a35003bd0a..3b83aeba4b79344f49792777d818a6bac1f634d6 100644 (file)
@@ -164,7 +164,8 @@ static void print_msymbol_info (struct minimal_symbol *);
 
 static void symtab_symbol_info (char *, namespace_enum, int);
 
-static void overload_list_add_symbol (struct symbol *sym, char *oload_name);
+static void overload_list_add_symbol (struct symbol *sym,
+                                     const char *oload_name);
 
 void _initialize_symtab (void);
 
@@ -3857,7 +3858,7 @@ in_prologue (CORE_ADDR pc, CORE_ADDR func_start)
 
 /* Begin overload resolution functions */
 
-static char *
+char *
 remove_params (const char *demangled_name)
 {
   const char *argp;
@@ -3910,7 +3911,7 @@ static struct symbol **sym_return_val;
    characters.  If so, add it to the current completion list. */
 
 static void
-overload_list_add_symbol (struct symbol *sym, char *oload_name)
+overload_list_add_symbol (struct symbol *sym, const char *oload_name)
 {
   int newsize;
   int i;
@@ -3952,13 +3953,16 @@ overload_list_add_symbol (struct symbol *sym, char *oload_name)
 }
 
 /* Return a null-terminated list of pointers to function symbols that
- * match name of the supplied symbol FSYM.
- * This is used in finding all overloaded instances of a function name.
- * This has been modified from make_symbol_completion_list.  */
-
+   match name of the supplied symbol FSYM and that occur within the
+   namespace given by the initial substring of NAMESPACE_NAME of
+   length NAMESPACE_LEN.  Apply using directives from BLOCK.  This is
+   used in finding all overloaded instances of a function name.  This
+   has been modified from make_symbol_completion_list.  */
 
 struct symbol **
-make_symbol_overload_list (struct symbol *fsym)
+make_symbol_overload_list (const char *func_name,
+                          const char *namespace_name,
+                          int namespace_len, const struct block *block)
 {
   register struct symbol *sym;
   register struct symtab *s;
@@ -3967,24 +3971,7 @@ make_symbol_overload_list (struct symbol *fsym)
   register struct block *b, *surrounding_static_block = 0;
   struct dict_iterator iter;
   /* The name we are completing on. */
-  char *oload_name = NULL;
-  /* Length of name.  */
-  int oload_name_len = 0;
-
-  /* Look for the symbol we are supposed to complete on.  */
-
-  oload_name = remove_params (SYMBOL_DEMANGLED_NAME (fsym));
-  if (!oload_name)
-    {
-      sym_return_val_size = 1;
-      sym_return_val =
-       (struct symbol **) xmalloc (2 * sizeof (struct symbol *));
-      sym_return_val[0] = fsym;
-      sym_return_val[1] = NULL;
-
-      return sym_return_val;
-    }
-  oload_name_len = strlen (oload_name);
+  const char *oload_name = func_name;
 
   sym_return_val_size = 100;
   sym_return_val_index = 0;
@@ -4070,8 +4057,6 @@ make_symbol_overload_list (struct symbol *fsym)
     }
   }
 
-  xfree (oload_name);
-
   return (sym_return_val);
 }
 
index 11595cc82c2e0b91d1493eb605d33ec6d0692765..8ae48300e9f4b3dfeb37709193efa716cace5d42 100644 (file)
@@ -1229,7 +1229,11 @@ extern char **make_symbol_completion_list (char *, char *);
 
 extern char **make_file_symbol_completion_list (char *, char *, char *);
 
-extern struct symbol **make_symbol_overload_list (struct symbol *);
+extern char *remove_params (const char *demangled_name);
+
+extern struct symbol **make_symbol_overload_list (const char *,
+                                                 const char *, int,
+                                                 const struct block *);
 
 extern char **make_source_files_completion_list (char *, char *);
 
index 77d58fec7507215e10ee801d5e47297e31afa9a7..4a6e3ac498b269d1ce3477e94853f1bb3032bc70 100644 (file)
@@ -2818,7 +2818,7 @@ find_overload_match (struct type **arg_types, int nargs, char *name, int method,
   int boffset;
   register int ix;
   int static_offset;
-  struct cleanup *cleanups = NULL;
+  struct cleanup *old_cleanups = NULL;
 
   const char *obj_type_name = NULL;
   char *func_name = NULL;
@@ -2850,26 +2850,27 @@ find_overload_match (struct type **arg_types, int nargs, char *name, int method,
   else
     {
       int i = -1;
-      func_name = cplus_demangle (SYMBOL_NAME (fsym), DMGL_NO_OPTS);
+      func_name        = remove_params (SYMBOL_CPLUS_DEMANGLED_NAME (fsym));
 
       /* If the name is NULL this must be a C-style function.
          Just return the same symbol. */
-      if (!func_name)
+      if (func_name == NULL)
         {
          *symp = fsym;
           return 0;
         }
 
-      oload_syms = make_symbol_overload_list (fsym);
-      cleanups = make_cleanup (xfree, oload_syms);
+      old_cleanups = make_cleanup (xfree, func_name);
+      oload_syms = make_symbol_overload_list (func_name, "", 0, current_block);
+      make_cleanup (xfree, oload_syms);
       while (oload_syms[++i])
        num_fns++;
       if (!num_fns)
        error ("Couldn't find function %s", func_name);
     }
 
-  oload_champ = find_oload_champ(arg_types, nargs, method, num_fns, fns_ptr,
-                                oload_syms, &oload_champ_bv);
+  oload_champ = find_oload_champ (arg_types, nargs, method, num_fns, fns_ptr,
+                                 oload_syms, &oload_champ_bv);
 
   /* NOTE: dan/2000-03-10: Seems to be a better idea to just pick one
      if they have the exact same goodness. This is because there is no
@@ -2931,7 +2932,6 @@ find_overload_match (struct type **arg_types, int nargs, char *name, int method,
   else
     {
       *symp = oload_syms[oload_champ];
-      xfree (func_name);
     }
 
   if (objp)
@@ -2943,8 +2943,8 @@ find_overload_match (struct type **arg_types, int nargs, char *name, int method,
        }
       *objp = temp;
     }
-  if (cleanups != NULL)
-    do_cleanups (cleanups);
+  if (old_cleanups != NULL)
+    do_cleanups (old_cleanups);
 
   switch (match_quality)
     {