LLDB mainline
|
A class that contains all state required for type lookups. More...
#include <Type.h>
Public Member Functions | |
TypeQuery ()=delete | |
TypeQuery (llvm::StringRef name, TypeQueryOptions options=e_none) | |
Construct a type match object using a fully- or partially-qualified name. | |
TypeQuery (const CompilerDeclContext &decl_ctx, ConstString type_basename, TypeQueryOptions options=e_none) | |
Construct a type-match object that matches a type basename that exists in the specified declaration context. | |
TypeQuery (const CompilerDecl &decl, TypeQueryOptions options=e_none) | |
Construct a type-match object using a compiler declaration that specifies a typename and a declaration context to use when doing exact type lookups. | |
TypeQuery (const llvm::ArrayRef< lldb_private::CompilerContext > &context, TypeQueryOptions options=e_none) | |
Construct a type-match object using a CompilerContext array. | |
TypeQuery (const TypeQuery &rhs)=default | |
Construct a type-match object that duplicates all matching criterea, but not any searched symbol files or the type map for matches. | |
TypeQuery & | operator= (const TypeQuery &rhs)=default |
Assign a type-match object that duplicates all matching criterea, but not any searched symbol files or the type map for matches. | |
bool | ContextMatches (llvm::ArrayRef< lldb_private::CompilerContext > context) const |
Check of a CompilerContext array from matching type from a symbol file matches the m_context. | |
ConstString | GetTypeBasename () const |
Get the type basename to use when searching the type indexes in each SymbolFile object. | |
bool | HasLanguage () const |
Returns true if any matching languages have been specified in this type matching object. | |
void | AddLanguage (lldb::LanguageType language) |
Add a language family to the list of languages that should produce a match. | |
void | SetLanguages (LanguageSet languages) |
Set the list of languages that should produce a match to only the ones specified in languages. | |
bool | LanguageMatches (lldb::LanguageType language) const |
Check if the language matches any languages that have been added to this match object. | |
bool | GetExactMatch () const |
bool | GetIgnoreModules () const |
void | SetIgnoreModules (bool b) |
bool | GetStrictNamespaces () const |
void | SetStrictNamespaces (bool b) |
bool | GetModuleSearch () const |
The m_context can be used in two ways: normal types searching with the context containing a stanadard declaration context for a type, or with the context being more complete for exact matches in clang modules. | |
bool | GetFindOne () const |
Returns true if the type query is supposed to find only a single matching type. | |
void | SetFindOne (bool b) |
bool | GetSearchByMangledName () const |
Returns true if the type query is supposed to treat the name to be searched as a mangled name. | |
void | SetSearchByMangledName (bool b) |
std::vector< lldb_private::CompilerContext > & | GetContextRef () |
Access the internal compiler context array. | |
Protected Attributes | |
std::vector< lldb_private::CompilerContext > | m_context |
A full or partial compiler context array where the parent declaration contexts appear at the top of the array starting at index zero and the last entry contains the type and name of the type we are looking for. | |
TypeQueryOptions | m_options |
An options bitmask that contains enabled options for the type query. | |
std::optional< LanguageSet > | m_languages |
If this variable has a value, then the language family must match at least one of the specified languages. | |
A class that contains all state required for type lookups.
Using a TypeQuery class for matching types simplifies the internal APIs we need to implement type lookups in LLDB. Type lookups can fully specify the exact typename by filling out a complete or partial CompilerContext array. This technique allows for powerful searches and also allows the SymbolFile classes to use the m_context array to lookup types by basename, then eliminate potential matches without having to resolve types into each TypeSystem. This makes type lookups vastly more efficient and allows the SymbolFile objects to stop looking up types when the type matching is complete, like if we are looking for only a single type in our search.
|
delete |
TypeQuery::TypeQuery | ( | llvm::StringRef | name, |
TypeQueryOptions | options = e_none |
||
) |
Construct a type match object using a fully- or partially-qualified name.
The specified type_name will be chopped up and the m_context will be populated by separating the string by looking for "::". We do this because symbol files have indexes that contain only the type's basename. This also allows symbol files to efficiently not realize types that don't match the specified context. Example of type_name values that can be specified include: "foo": Look for any type whose basename matches "foo". If exact_match is true, then the type can't be contained in any declaration context like a namespace, class, or other containing scope. If exact match is false, then we will find all matches including ones that are contained in other declaration contexts, including top level types. "foo::bar": Look for any type whose basename matches "bar" but make sure its parent declaration context is any named declaration context (namespace, class, struct, etc) whose name matches "foo". If exact_match is true, then the "foo" declaration context must appear at the source file level or inside of a function. If exact match is false, then the "foo" declaration context can be contained in any other declaration contexts. "class foo": Only match types that are classes whose basename matches "foo". "struct foo": Only match types that are structures whose basename matches "foo". "class foo::bar": Only match types that are classes whose basename matches "bar" and that are contained in any named declaration context named "foo".
[in] | type_name | A fully- or partially-qualified type name. This name will be parsed and broken up and the m_context will be populated with the various parts of the name. This typename can be prefixed with "struct ", "class ", "union", "enum " or "typedef " before the actual type name to limit the results of the types that match. The declaration context can be specified with the "::" string. For example, "a::b::my_type". |
[in] | options | A set of boolean enumeration flags from the TypeQueryOptions enumerations. |
Definition at line 66 of file Type.cpp.
References lldb_private::AnyDeclContext, lldb_private::AnyType, ConvertTypeClass(), lldb_private::Type::GetTypeScopeAndBasename(), m_context, and m_options.
TypeQuery::TypeQuery | ( | const CompilerDeclContext & | decl_ctx, |
ConstString | type_basename, | ||
TypeQueryOptions | options = e_none |
||
) |
Construct a type-match object that matches a type basename that exists in the specified declaration context.
This allows the m_context to be first populated using a declaration context to exactly identify the containing declaration context of a type. This can be used when you have a forward declaration to a type and you need to search for its complete type.
[in] | decl_ctx | A declaration context object that comes from a TypeSystem plug-in. This object will be asked to populate the array of CompilerContext objects by adding the top most declaration context first into the array and then adding any containing declaration contexts. |
[in] | type_basename | The basename of the type to lookup in the specified declaration context. |
[in] | options | A set of boolean enumeration flags from the TypeQueryOptions enumerations. |
Definition at line 88 of file Type.cpp.
References lldb_private::AnyType, lldb_private::CompilerDeclContext::GetCompilerContext(), m_context, and m_options.
TypeQuery::TypeQuery | ( | const CompilerDecl & | decl, |
TypeQueryOptions | options = e_none |
||
) |
Construct a type-match object using a compiler declaration that specifies a typename and a declaration context to use when doing exact type lookups.
This allows the m_context to be first populated using a type declaration. The type declaration might have a declaration context and each TypeSystem plug-in can populate the declaration context needed to perform an exact lookup for a type. This can be used when you have a forward declaration to a type and you need to search for its complete type.
[in] | decl | A type declaration context object that comes from a TypeSystem plug-in. This object will be asked to full the array of CompilerContext objects by adding the top most declaration context first into the array and then adding any containing declaration contexts, and ending with the exact typename and the kind of type it is (class, struct, union, enum, etc). |
[in] | options | A set of boolean enumeration flags from the TypeQueryOptions enumerations. |
Definition at line 105 of file Type.cpp.
References lldb_private::CompilerDecl::GetCompilerContext(), m_context, and m_options.
TypeQuery::TypeQuery | ( | const llvm::ArrayRef< lldb_private::CompilerContext > & | context, |
TypeQueryOptions | options = e_none |
||
) |
Construct a type-match object using a CompilerContext array.
Clients can manually create compiler contexts and use these to find matches when searching for types. There are two types of contexts that are supported when doing type searchs: type contexts and clang module contexts. Type contexts have contexts that specify the type and its containing declaration context like namespaces and classes. Clang module contexts specify contexts more completely to find exact matches within clang module debug information. They will include the modules that the type is included in and any functions that the type might be defined in. This allows very fine-grained type resolution.
[in] | context | The compiler context to use when doing the search. |
[in] | options | A set of boolean enumeration flags from the TypeQueryOptions enumerations. |
Definition at line 97 of file Type.cpp.
References m_options.
|
default |
Construct a type-match object that duplicates all matching criterea, but not any searched symbol files or the type map for matches.
This allows the m_context to be modified prior to performing another search.
void TypeQuery::AddLanguage | ( | lldb::LanguageType | language | ) |
Add a language family to the list of languages that should produce a match.
Definition at line 118 of file Type.cpp.
References m_languages.
Referenced by DWARFASTParserClang::ParseTypeFromClangModule().
bool TypeQuery::ContextMatches | ( | llvm::ArrayRef< lldb_private::CompilerContext > | context | ) | const |
Check of a CompilerContext array from matching type from a symbol file matches the m_context.
[in] | context | A fully qualified CompilerContext array for a potential match that is created by the symbol file prior to trying to actually resolve a type. |
Definition at line 128 of file Type.cpp.
References GetExactMatch(), GetIgnoreModules(), GetStrictNamespaces(), m_context, lldb_private::Module, and lldb_private::Namespace.
Referenced by lldb_private::plugin::dwarf::SymbolFileDWARF::FindTypes(), lldb_private::npdb::SymbolFileNativePDB::FindTypes(), SymbolFilePDB::FindTypes(), and lldb_private::plugin::dwarf::DWARFIndex::ProcessTypeDIEMatchQuery().
|
inline |
Access the internal compiler context array.
Clients can use this to populate the context manually.
Definition at line 322 of file Type.h.
Referenced by lldb_private::plugin::dwarf::SymbolFileDWARF::FindTypes(), lldb_private::npdb::SymbolFileNativePDB::FindTypes(), SymbolFilePDB::FindTypes(), lldb_private::plugin::dwarf::DebugNamesDWARFIndex::GetTypeQueryParentContexts(), lldb_private::plugin::dwarf::DebugNamesDWARFIndex::GetTypesWithQuery(), and UpdateCompilerContextForSimpleTemplateNames().
|
inline |
Definition at line 270 of file Type.h.
Referenced by ContextMatches(), and lldb_private::plugin::dwarf::DebugNamesDWARFIndex::GetTypesWithQuery().
|
inline |
Returns true if the type query is supposed to find only a single matching type.
Returns false if the type query should find all matches.
Definition at line 298 of file Type.h.
Referenced by lldb_private::TypeResults::Done().
|
inline |
Definition at line 272 of file Type.h.
Referenced by ContextMatches().
|
inline |
The m_context can be used in two ways: normal types searching with the context containing a stanadard declaration context for a type, or with the context being more complete for exact matches in clang modules.
Set this to true if you wish to search for a type in clang module.
Definition at line 294 of file Type.h.
Referenced by lldb_private::plugin::dwarf::DWARFIndex::ProcessTypeDIEMatchQuery().
|
inline |
Returns true if the type query is supposed to treat the name to be searched as a mangled name.
Definition at line 308 of file Type.h.
Referenced by lldb_private::plugin::dwarf::SymbolFileDWARF::FindTypes(), and lldb_private::plugin::dwarf::DWARFIndex::ProcessTypeDIEMatchQuery().
|
inline |
Definition at line 280 of file Type.h.
Referenced by ContextMatches().
ConstString TypeQuery::GetTypeBasename | ( | ) | const |
Get the type basename to use when searching the type indexes in each SymbolFile object.
Debug information indexes often contain indexes that track the basename of types only, not a fully qualified path. This allows the indexes to be smaller and allows for efficient lookups.
Definition at line 112 of file Type.cpp.
References m_context.
Referenced by lldb_private::SymbolFileCTF::FindTypes(), lldb_private::plugin::dwarf::SymbolFileDWARF::FindTypes(), lldb_private::npdb::SymbolFileNativePDB::FindTypes(), SymbolFilePDB::FindTypes(), lldb_private::plugin::dwarf::DWARFIndex::GetTypesWithQuery(), lldb_private::plugin::dwarf::DebugNamesDWARFIndex::GetTypesWithQuery(), and lldb_private::plugin::dwarf::DWARFIndex::ProcessTypeDIEMatchQuery().
|
inline |
Returns true if any matching languages have been specified in this type matching object.
Definition at line 252 of file Type.h.
Referenced by lldb_private::plugin::dwarf::SymbolFileDWARF::FindTypes(), and lldb_private::plugin::dwarf::DWARFIndex::ProcessTypeDIEMatchQuery().
bool TypeQuery::LanguageMatches | ( | lldb::LanguageType | language | ) | const |
Check if the language matches any languages that have been added to this match object.
Definition at line 182 of file Type.cpp.
References m_languages.
Referenced by lldb_private::plugin::dwarf::DWARFIndex::ProcessTypeDIEMatchQuery().
Assign a type-match object that duplicates all matching criterea, but not any searched symbol files or the type map for matches.
This allows the m_context to be modified prior to performing another search.
|
inline |
Definition at line 299 of file Type.h.
Referenced by lldb_private::ItaniumABILanguageRuntime::GetTypeInfo().
|
inline |
void TypeQuery::SetLanguages | ( | LanguageSet | languages | ) |
Set the list of languages that should produce a match to only the ones specified in languages.
Definition at line 124 of file Type.cpp.
References m_languages.
|
inline |
|
inline |
|
protected |
A full or partial compiler context array where the parent declaration contexts appear at the top of the array starting at index zero and the last entry contains the type and name of the type we are looking for.
Definition at line 330 of file Type.h.
Referenced by ContextMatches(), GetTypeBasename(), and TypeQuery().
|
protected |
If this variable has a value, then the language family must match at least one of the specified languages.
If this variable has no value, then the language of the type doesn't need to match any types that are searched.
Definition at line 337 of file Type.h.
Referenced by AddLanguage(), LanguageMatches(), and SetLanguages().
|
protected |
An options bitmask that contains enabled options for the type query.
Definition at line 333 of file Type.h.
Referenced by TypeQuery().