From 25f31e1820dcec2f0c073c28cbf88646c7c2af97 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Thu, 2 Mar 2023 15:20:29 -0700 Subject: Add domain_search_flags This adds a new flag enum type, domain_search_flags, which is the flag version of domain_enum. Nothing uses this yet, but the goal here is to have all symbol searches and lookups use these flags. The new names are chosen to exactly parallel domain_enum. --- gdb/symtab.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'gdb/symtab.c') diff --git a/gdb/symtab.c b/gdb/symtab.c index b1deb9d..779e1ff 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -331,6 +331,21 @@ search_domain_name (enum search_domain e) /* See symtab.h. */ +std::string +domain_name (domain_search_flags flags) +{ + static constexpr domain_search_flags::string_mapping mapping[] = { +#define DOMAIN(X) \ + MAP_ENUM_FLAG (SEARCH_ ## X ## _DOMAIN), +#include "sym-domains.def" +#undef DOMAIN + }; + + return flags.to_string (mapping); +} + +/* See symtab.h. */ + CORE_ADDR linetable_entry::pc (const struct objfile *objfile) const { @@ -2666,6 +2681,41 @@ symbol_matches_domain (enum language symbol_language, /* See symtab.h. */ +bool +symbol::matches (domain_search_flags flags) const +{ + if (language () != language_c + && language () != language_objc + && language () != language_opencl) + { + /* Only C languages distinguish tag and type namespaces. */ + if ((flags & SEARCH_TYPE_DOMAIN) != 0) + flags |= SEARCH_STRUCT_DOMAIN; + } + + if ((flags & SEARCH_FUNCTION_DOMAIN) != 0 + && domain () == VAR_DOMAIN + && aclass () == LOC_BLOCK) + return true; + + if ((flags & SEARCH_VAR_DOMAIN) != 0 + && domain () == VAR_DOMAIN) + return true; + + if ((flags & SEARCH_TYPE_DOMAIN) != 0 + && domain () == VAR_DOMAIN + && aclass () == LOC_TYPEDEF) + return true; + + if ((flags & SEARCH_STRUCT_DOMAIN) != 0 + && domain () == STRUCT_DOMAIN) + return true; + + return search_flags_matches (flags, m_domain); +} + +/* See symtab.h. */ + struct type * lookup_transparent_type (const char *name) { -- cgit v1.1