[21/29] Simplify some symbol searches in linespec.c

Message ID 20231120-submit-domain-hacks-2-v1-21-29650d01b198@tromey.com
State New
Headers
Series Restructure symbol domains |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed

Commit Message

Tom Tromey Nov. 21, 2023, 3:53 a.m. UTC
  This simplifies some symbol searches in linespec.c.  In particular,
two separate searches here can now be combined into one, due to the
new use of flags.

Arguably the STRUCT_DOMAIN searches should perhaps not even be done.
Only C really has these, and C doesn't have member functions.
However, it seems relatively harmless -- and clearly compatible -- to
leave this in.
---
 gdb/linespec.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
  

Patch

diff --git a/gdb/linespec.c b/gdb/linespec.c
index e840a137cfb..c7e6c7444d5 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -3438,14 +3438,9 @@  lookup_prefix_sym (struct linespec_state *state,
   for (const auto &elt : file_symtabs)
     {
       if (elt == nullptr)
-	{
-	  iterate_over_all_matching_symtabs (state, lookup_name,
-					     SEARCH_STRUCT_DOMAIN,
-					     NULL, false, collector);
-	  iterate_over_all_matching_symtabs (state, lookup_name,
-					     SEARCH_VFT,
-					     NULL, false, collector);
-	}
+	iterate_over_all_matching_symtabs (state, lookup_name,
+					   SEARCH_STRUCT_DOMAIN | SEARCH_VFT,
+					   NULL, false, collector);
       else
 	{
 	  /* Program spaces that are executing startup should have
@@ -3455,10 +3450,7 @@  lookup_prefix_sym (struct linespec_state *state,
 	  gdb_assert (!pspace->executing_startup);
 	  set_current_program_space (pspace);
 	  iterate_over_file_blocks (elt, lookup_name,
-				    SEARCH_STRUCT_DOMAIN,
-				    collector);
-	  iterate_over_file_blocks (elt, lookup_name,
-				    SEARCH_VFT,
+				    SEARCH_STRUCT_DOMAIN | SEARCH_VFT,
 				    collector);
 	}
     }