diff options
author | Tom Tromey <tom@tromey.com> | 2023-03-10 11:48:25 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2024-01-28 10:58:16 -0700 |
commit | d4f48c1e26a550a8b3ba8312268b706454b00ee2 (patch) | |
tree | 3786f16258d93de316cb05a8f4cbf3504bd75fa1 | |
parent | d4bf9040be06250a0ee07d5bd6dc8a1e42590415 (diff) | |
download | gdb-d4f48c1e26a550a8b3ba8312268b706454b00ee2.zip gdb-d4f48c1e26a550a8b3ba8312268b706454b00ee2.tar.gz gdb-d4f48c1e26a550a8b3ba8312268b706454b00ee2.tar.bz2 |
Split up a big 'if' in symtab.c
global_symbol_searcher::add_matching_symbols in symtab.c has a
gigantic 'if' statement -- 33 lines of conditional expression. This
patch splits it up into a series of separate 'if's.
-rw-r--r-- | gdb/symtab.c | 83 |
1 files changed, 50 insertions, 33 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c index b408941..2020210 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -4855,39 +4855,56 @@ global_symbol_searcher::add_matching_symbols /* Check first sole REAL_SYMTAB->FILENAME. It does not need to be a substring of symtab_to_fullname as it may contain "./" etc. */ - if ((file_matches (real_symtab->filename, filenames, false) - || ((basenames_may_differ - || file_matches (lbasename (real_symtab->filename), - filenames, true)) - && file_matches (symtab_to_fullname (real_symtab), - filenames, false))) - && ((!preg.has_value () - || preg->exec (sym->natural_name (), 0, - NULL, 0) == 0) - && ((kind == VARIABLES_DOMAIN - && sym->aclass () != LOC_TYPEDEF - && sym->aclass () != LOC_UNRESOLVED - && sym->aclass () != LOC_BLOCK - /* LOC_CONST can be used for more than - just enums, e.g., c++ static const - members. We only want to skip enums - here. */ - && !(sym->aclass () == LOC_CONST - && (sym->type ()->code () - == TYPE_CODE_ENUM)) - && (!treg.has_value () - || treg_matches_sym_type_name (*treg, sym))) - || (kind == FUNCTIONS_DOMAIN - && sym->aclass () == LOC_BLOCK - && (!treg.has_value () - || treg_matches_sym_type_name (*treg, - sym))) - || (kind == TYPES_DOMAIN - && sym->aclass () == LOC_TYPEDEF - && sym->domain () != MODULE_DOMAIN) - || (kind == MODULES_DOMAIN - && sym->domain () == MODULE_DOMAIN - && sym->line () != 0)))) + if (!(file_matches (real_symtab->filename, filenames, false) + || ((basenames_may_differ + || file_matches (lbasename (real_symtab->filename), + filenames, true)) + && file_matches (symtab_to_fullname (real_symtab), + filenames, false)))) + continue; + + if (preg.has_value () && !preg->exec (sym->natural_name (), 0, + nullptr, 0) == 0) + continue; + + bool matches = false; + if (!matches && kind == VARIABLES_DOMAIN) + { + if (sym->aclass () != LOC_TYPEDEF + && sym->aclass () != LOC_UNRESOLVED + && sym->aclass () != LOC_BLOCK + /* LOC_CONST can be used for more than + just enums, e.g., c++ static const + members. We only want to skip enums + here. */ + && !(sym->aclass () == LOC_CONST + && (sym->type ()->code () + == TYPE_CODE_ENUM)) + && (!treg.has_value () + || treg_matches_sym_type_name (*treg, sym))) + matches = true; + } + if (!matches && kind == FUNCTIONS_DOMAIN) + { + if (sym->aclass () == LOC_BLOCK + && (!treg.has_value () + || treg_matches_sym_type_name (*treg, + sym))) + matches = true; + } + if (!matches && kind == TYPES_DOMAIN) + { + if (sym->aclass () == LOC_TYPEDEF + && sym->domain () != MODULE_DOMAIN) + matches = true; + } + if (!matches && kind == MODULES_DOMAIN) + { + if (sym->domain () == MODULE_DOMAIN + && sym->line () != 0) + matches = true; + } + if (matches) { if (result_set->size () < m_max_search_results) { |