From: Tom Tromey Date: Sat, 7 Dec 2024 22:16:17 +0000 (-0700) Subject: Some small cleanups in add_symbol_overload_list_qualified X-Git-Tag: binutils-2_44~262 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2cf6f57319032ad0a38fc1a5319856428b23d419;p=thirdparty%2Fbinutils-gdb.git Some small cleanups in add_symbol_overload_list_qualified This applies some more cleanups to add_symbol_overload_list_qualified, consolidating calls to get_selected_block. It also moves the symtab expansion call after the code that walks up from the selected block, merging two loops. --- diff --git a/gdb/cp-support.c b/gdb/cp-support.c index 91b024d7fbe..3621d685a56 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -1436,38 +1436,35 @@ static void add_symbol_overload_list_qualified (const char *func_name, std::vector *overload_list) { - const struct block *surrounding_static_block = 0; - - /* Look through the partial symtabs for all symbols which begin by - matching FUNC_NAME. Make sure we read that symbol table in. */ - - for (objfile *objf : current_program_space->objfiles ()) - objf->expand_symtabs_for_function (func_name); + const block *selected_block = get_selected_block (0); /* Search upwards from currently selected frame (so that we can complete on local vars. */ - for (const block *b = get_selected_block (0); - b != nullptr; - b = b->superblock ()) + for (const block *b = selected_block; b != nullptr; b = b->superblock ()) add_symbol_overload_list_block (func_name, b, overload_list); - surrounding_static_block = get_selected_block (0); - surrounding_static_block = (surrounding_static_block == nullptr - ? nullptr - : surrounding_static_block->static_block ()); + const block *surrounding_static_block = (selected_block == nullptr + ? nullptr + : selected_block->static_block ()); /* Go through the symtabs and check the externs and statics for symbols which match. */ - const block *block = get_selected_block (0); - struct objfile *current_objfile = block ? block->objfile () : nullptr; + struct objfile *current_objfile = (selected_block + ? selected_block->objfile () + : nullptr); gdbarch_iterate_over_objfiles_in_search_order (current_objfile ? current_objfile->arch () : current_inferior ()->arch (), [func_name, surrounding_static_block, &overload_list] (struct objfile *obj) { + /* Look through the partial symtabs for all symbols which + begin by matching FUNC_NAME. Make sure we read that + symbol table in. */ + obj->expand_symtabs_for_function (func_name); + for (compunit_symtab *cust : obj->compunits ()) { QUIT;