[v2,1/2] symtab.c: Small refactor

Message ID 1487870642-29926-2-git-send-email-palves@redhat.com
State New, archived
Headers

Commit Message

Pedro Alves Feb. 23, 2017, 5:24 p.m. UTC
  add_symtab_completions does the exact same as the code that it is
replacing.

gdb/ChangeLog:
yyyy-mm-dd  Pedro Alves  <palves@redhat.com>

	* symtab.c (make_file_symbol_completion_list_1): Use
	add_symtab_completions.
---
 gdb/symtab.c | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)
  

Comments

Yao Qi Feb. 23, 2017, 9:45 p.m. UTC | #1
On 17-02-23 17:24:01, Pedro Alves wrote:
> add_symtab_completions does the exact same as the code that it is
> replacing.
> 
> gdb/ChangeLog:
> yyyy-mm-dd  Pedro Alves  <palves@redhat.com>
> 
> 	* symtab.c (make_file_symbol_completion_list_1): Use
> 	add_symtab_completions.

Patch is good to me.
  
Pedro Alves Feb. 24, 2017, 5:45 p.m. UTC | #2
On 02/23/2017 09:45 PM, Yao Qi wrote:
> On 17-02-23 17:24:01, Pedro Alves wrote:
>> add_symtab_completions does the exact same as the code that it is
>> replacing.
>>
>> gdb/ChangeLog:
>> yyyy-mm-dd  Pedro Alves  <palves@redhat.com>
>>
>> 	* symtab.c (make_file_symbol_completion_list_1): Use
>> 	add_symtab_completions.
> 
> Patch is good to me.
> 

Thanks, I've pushed this one in.

Thanks,
Pedro Alves
  

Patch

diff --git a/gdb/symtab.c b/gdb/symtab.c
index b9f4f77..c0fd0fd 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -5391,10 +5391,7 @@  static VEC (char_ptr) *
 make_file_symbol_completion_list_1 (const char *text, const char *word,
 				    const char *srcfile)
 {
-  struct symbol *sym;
   struct symtab *s;
-  struct block *b;
-  struct block_iterator iter;
   /* The symbol we are completing on.  Points in same buffer as text.  */
   const char *sym_text;
   /* Length of sym_text.  */
@@ -5464,18 +5461,9 @@  make_file_symbol_completion_list_1 (const char *text, const char *word,
 
   /* Go through this symtab and check the externs and statics for
      symbols which match.  */
-
-  b = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (s), GLOBAL_BLOCK);
-  ALL_BLOCK_SYMBOLS (b, iter, sym)
-    {
-      COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word);
-    }
-
-  b = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (s), STATIC_BLOCK);
-  ALL_BLOCK_SYMBOLS (b, iter, sym)
-    {
-      COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word);
-    }
+  add_symtab_completions (SYMTAB_COMPUNIT (s),
+			  sym_text, sym_text_len,
+			  text, word, TYPE_CODE_UNDEF);
 
   return (return_val);
 }