38#include "llvm/ADT/StringRef.h"
46 rhs.
Dump(lldb_stream);
51 if (type_class == eTypeClassAny)
54 if (type_class & (lldb::eTypeClassClass | lldb::eTypeClassStruct))
56 if (type_class & lldb::eTypeClassUnion)
58 if (type_class & lldb::eTypeClassEnumeration)
60 if (type_class & lldb::eTypeClassFunction)
62 if (type_class & lldb::eTypeClassTypedef)
69 if (std::optional<Type::ParsedName> parsed_name =
71 llvm::ArrayRef scope = parsed_name->scope;
73 if (scope[0] ==
"::") {
75 scope = scope.drop_front();
77 for (llvm::StringRef s : scope) {
90 ConstString type_basename, TypeQueryOptions options)
99 const llvm::ArrayRef<lldb_private::CompilerContext> &context,
100 TypeQueryOptions options)
130 llvm::ArrayRef<CompilerContext> context_chain)
const {
131 auto ctx = context_chain.rbegin(), ctx_end = context_chain.rend();
156 if (ctx->name != pat->name)
172 ctx = std::find_if_not(ctx, ctx_end, should_skip);
180 return ctx == ctx_end;
212 s <<
"TranslationUnit";
221 s <<
"ClassOrStruct";
242 s <<
"(" <<
name <<
")";
250 m_type_list.Append(std::make_shared<TypeImpl>(type));
272 m_type_sp = resolved_type->shared_from_this();
281 ResolveState compiler_type_resolve_state, uint32_t opaque_payload)
299 : std::enable_shared_from_this<
Type>(),
UserID(0),
m_name(
"<INVALID TYPE>"),
307 *s <<
"id = " << (
const UserID &)*
this;
313 *s <<
", name = \"" << type_name <<
'"';
315 if (qualified_type_name != type_name) {
316 *s <<
", qualified = \"" << qualified_type_name <<
'"';
325 m_decl.Dump(s, show_fullpaths);
328 *s <<
", compiler_type = \"";
358 s->
PutCString(
" (unresolved L value reference)");
361 s->
PutCString(
" (unresolved R value reference)");
374 s->
Printf(
"%p: ",
static_cast<void *
>(
this));
376 *s <<
"Type" <<
static_cast<const UserID &
>(*this) <<
' ';
378 *s <<
", name = \"" <<
m_name <<
"\"";
383 if (show_context &&
m_context !=
nullptr) {
389 bool show_fullpaths =
false;
390 m_decl.Dump(s, show_fullpaths);
393 *s <<
", compiler_type = " <<
m_compiler_type.GetOpaqueQualType() <<
' ';
422 s->
PutCString(
" (unresolved L value reference)");
425 s->
PutCString(
" (unresolved R value reference)");
465 return llvm::createStringError(
"could not get type size: invalid encoding");
468 return llvm::createStringError(
469 "could not get type size: synthetic encoding");
479 if (std::optional<uint64_t> size =
480 llvm::expectedToOptional(encoding_type->
GetByteSize(exe_scope))) {
488 return size_or_err.takeError();
506 return llvm::createStringError(
507 "could not get type size: unexpected encoding");
527 type_sp = typedef_type->shared_from_this();
547 const uint64_t byte_size =
548 llvm::expectedToOptional(
557 uint8_t *dst =
const_cast<uint8_t *
>(data.
PeekData(0, byte_size));
558 if (dst !=
nullptr) {
563 memcpy(dst,
reinterpret_cast<uint8_t *
>(addr), byte_size);
588 Type *encoding_type =
nullptr;
596 if (encoding_compiler_type.
IsValid()) {
625 m_name.AsCString(
"__lldb_invalid_typedef_name"),
652 llvm_unreachable(
"Unhandled encoding_data_type.");
656 auto type_system_or_err =
658 if (
auto err = type_system_or_err.takeError()) {
661 "Unable to construct void type from TypeSystemClang: {0}");
664 auto ts = *type_system_or_err;
690 m_name.AsCString(
"__lldb_invalid_typedef_name"),
707 llvm_unreachable(
"Cannot handle eEncodingIsLLVMPtrAuthUID without "
708 "valid encoding_type");
711 llvm_unreachable(
"Unhandled encoding_data_type.");
741 if (encoding_type ==
nullptr)
745 compiler_type_resolve_state;
766 assert(encoding_type !=
this);
769 return encoding_mask;
791std::optional<Type::ParsedName>
798 if (name.consume_front(
"struct "))
800 else if (name.consume_front(
"class "))
802 else if (name.consume_front(
"union "))
804 else if (name.consume_front(
"enum "))
806 else if (name.consume_front(
"typedef "))
809 if (name.consume_front(
"::"))
810 result.
scope.push_back(
"::");
812 bool prev_is_colon =
false;
813 size_t template_depth = 0;
814 size_t name_begin = 0;
815 for (
const auto &pos : llvm::enumerate(name)) {
816 switch (pos.value()) {
818 if (prev_is_colon && template_depth == 0) {
819 llvm::StringRef scope_name = name.slice(name_begin, pos.index() - 1);
823 if (scope_name ==
"(anonymous namespace)" ||
824 scope_name ==
"`anonymous namespace'" ||
825 scope_name ==
"`anonymous-namespace'")
827 result.
scope.push_back(scope_name);
828 name_begin = pos.index() + 1;
835 if (template_depth == 0)
840 prev_is_colon = pos.value() ==
':';
843 if (name_begin < name.size() && template_depth == 0)
844 result.
basename = name.substr(name_begin);
862 SymbolFile *symbol_file = ts->GetSymbolFile();
891 return !(*
this == other);
961 SetType(static_type, dynamic_type);
1011 module_sp = input_module_wp.lock();
1019 if (empty_module_wp.owner_before(input_module_wp) ||
1020 input_module_wp.owner_before(empty_module_wp)) {
1036 return !(*
this == rhs);
1169 if (prefer_dynamic) {
1181 if (prefer_dynamic) {
1195 strm.
Printf(
"Dynamic:\n");
1197 strm.
Printf(
"\nStatic:\n");
1201 strm.
PutCString(
"Invalid TypeImpl module for type has been deleted\n");
1220 return m_decl.GetMangledName();
1234 stream.
Printf(
"constructor for %s",
1235 m_type.GetTypeName().AsCString(
"<unknown>"));
1238 stream.
Printf(
"destructor for %s",
1239 m_type.GetTypeName().AsCString(
"<unknown>"));
1242 stream.
Printf(
"instance method %s of type %s",
m_name.AsCString(),
1243 m_decl.GetDeclContext().GetName().AsCString());
1246 stream.
Printf(
"static method %s of type %s",
m_name.AsCString(),
1247 m_decl.GetDeclContext().GetName().AsCString());
1255 return m_type.GetFunctionReturnType();
1256 return m_decl.GetFunctionReturnType();
1261 return m_type.GetNumberOfFunctionArguments();
1263 return m_decl.GetNumFunctionArguments();
1268 return m_type.GetFunctionArgumentAtIndex(idx);
1270 return m_decl.GetFunctionArgumentType(idx);
1275 const llvm::APSInt &value)
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOG_ERROR(log, error,...)
static CompilerContextKind ConvertTypeClass(lldb::TypeClass type_class)
bool operator()(const lldb::TypeSP &type)
TypeListImpl & m_type_list
TypeAppendVisitor(TypeListImpl &type_list)
An architecture specification class.
Represents a generic declaration context in a program.
std::vector< lldb_private::CompilerContext > GetCompilerContext() const
Populate a valid compiler context from the current decl context.
Represents a generic declaration such as a function declaration.
std::vector< lldb_private::CompilerContext > GetCompilerContext() const
Populate a valid compiler context from the current declaration.
This is a minimal wrapper of a TypeSystem shared pointer as returned by CompilerType which conventien...
Generic representation of a type in a programming language.
CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) const
Create related types using the current type's AST.
CompilerType AddConstModifier() const
Return a new CompilerType adds a const modifier to this type if this type is valid and the type syste...
lldb::Encoding GetEncoding(uint64_t &count) const
CompilerType GetRValueReferenceType() const
Return a new CompilerType that is a R value reference to this type if this type is valid and the type...
CompilerType GetPointerType() const
Return a new CompilerType that is a pointer to this type.
llvm::Expected< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
CompilerType AddVolatileModifier() const
Return a new CompilerType adds a volatile modifier to this type if this type is valid and the type sy...
CompilerType AddRestrictModifier() const
Return a new CompilerType adds a restrict modifier to this type if this type is valid and the type sy...
CompilerType GetDirectNestedTypeWithName(llvm::StringRef name) const
CompilerType GetLValueReferenceType() const
Return a new CompilerType that is a L value reference to this type if this type is valid and the type...
ConstString GetTypeName(bool BaseOnly=false) const
bool IsAggregateType() const
lldb::Format GetFormat() const
llvm::Expected< uint32_t > GetNumChildren(bool omit_empty_base_classes, const ExecutionContext *exe_ctx) const
CompilerType CreateTypedef(const char *name, const CompilerDeclContext &decl_ctx, uint32_t payload) const
Create a typedef to this type using "name" as the name of the typedef this type is valid and the type...
CompilerType GetAtomicType() const
Return a new CompilerType that is the atomic type of this type.
bool IsTemplateType() const
void DumpTypeDescription(lldb::DescriptionLevel level=lldb::eDescriptionLevelFull) const
Dump to stdout.
CompilerType AddPtrAuthModifier(uint32_t payload) const
Return a new CompilerType adds a ptrauth modifier from the given 32-bit opaque payload to this type i...
A uniqued constant string class.
void Dump(Stream *s, const char *value_if_empty=nullptr) const
Dump the object description to a stream.
A subclass of DataBuffer that stores a data buffer on the heap.
A class that describes the declaration location of a lldb object.
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
ExecutionContextScope * GetBestExecutionContextScope() const
Process * GetProcessPtr() const
Returns a pointer to the process object.
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
A plug-in interface definition class for debugging a process.
virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error)
Read of memory from a process.
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
void Format(const char *format, Args &&... args)
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
size_t EOL()
Output and End of Line character to the stream.
"lldb/Symbol/SymbolContextScope.h" Inherit from this if your object is part of a symbol context and c...
SymbolFile & m_symbol_file
SymbolFileType(SymbolFile &symbol_file, lldb::user_id_t uid)
Provides public interface for all SymbolFiles.
virtual ObjectFile * GetObjectFile()=0
void SetName(ConstString type_name)
bool operator!=(const TypeAndOrName &other) const
bool operator==(const TypeAndOrName &other) const
ConstString GetName() const
bool HasCompilerType() const
void SetCompilerType(CompilerType compiler_type)
void SetTypeSP(lldb::TypeSP type_sp)
CompilerType m_compiler_type
lldb::TypeImplSP m_integer_type_sp
CompilerType GetCompilerType(bool prefer_dynamic)
bool operator!=(const TypeImpl &rhs) const
bool CheckExeModule(lldb::ModuleSP &module_sp) const
bool GetDescription(lldb_private::Stream &strm, lldb::DescriptionLevel description_level)
bool operator==(const TypeImpl &rhs) const
bool CheckModuleCommon(const lldb::ModuleWP &input_module_wp, lldb::ModuleSP &module_sp) const
TypeImpl GetCanonicalType() const
void SetType(const lldb::TypeSP &type_sp)
TypeImpl GetUnqualifiedType() const
TypeImpl GetPointeeType() const
CompilerType m_dynamic_type
CompilerType::TypeSystemSPWrapper GetTypeSystem(bool prefer_dynamic)
CompilerType m_static_type
bool CheckModule(lldb::ModuleSP &module_sp) const
lldb::ModuleSP GetModule() const
TypeImpl GetDereferencedType() const
TypeImpl GetPointerType() const
lldb::ModuleWP m_exe_module_wp
TypeImpl GetReferenceType() const
TypeImpl GetTypedefedType() const
lldb::ModuleWP m_module_wp
ConstString GetName() const
CompilerType FindDirectNestedType(llvm::StringRef name)
ConstString GetDisplayTypeName() const
void Append(const lldb::TypeImplSP &type)
void ForEach(std::function< bool(const lldb::TypeSP &type_sp)> const &callback) const
size_t GetNumArguments() const
CompilerType GetReturnType() const
ConstString GetMangledName() const
CompilerType GetType() const
ConstString GetName() const
CompilerType GetArgumentAtIndex(size_t idx) const
bool GetDescription(Stream &stream)
lldb::MemberFunctionKind GetKind() const
lldb::MemberFunctionKind m_kind
A class that contains all state required for type lookups.
std::vector< lldb_private::CompilerContext > m_context
A full or partial compiler context array where the parent declaration contexts appear at the top of t...
void AddLanguage(lldb::LanguageType language)
Add a language family to the list of languages that should produce a match.
bool GetStrictNamespaces() const
TypeQueryOptions m_options
An options bitmask that contains enabled options for the type query.
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 SetLanguages(LanguageSet languages)
Set the list of languages that should produce a match to only the ones specified in languages.
std::optional< LanguageSet > m_languages
If this variable has a value, then the language family must match at least one of the specified langu...
ConstString GetTypeBasename() const
Get the type basename to use when searching the type indexes in each SymbolFile object.
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.
bool GetFindOne() const
Returns true if the type query is supposed to find only a single matching type.
bool InsertUnique(const lldb::TypeSP &type_sp)
When types that match a TypeQuery are found, this API is used to insert the matching types.
llvm::DenseSet< lldb_private::SymbolFile * > m_searched_symbol_files
This set is used to track and make sure we only perform lookups in a symbol file one time.
bool Done(const TypeQuery &query) const
Check if the type matching has found all of the matches that it needs.
bool AlreadySearched(lldb_private::SymbolFile *sym_file)
Check if a SymbolFile object has already been searched by this type match object.
TypeMap m_type_map
Matching types get added to this map as type search continues.
CompilerType m_compiler_type
CompilerType GetForwardCompilerType()
const lldb_private::Declaration & GetDeclaration() const
uint64_t m_byte_size_has_value
ResolveState m_compiler_type_resolve_state
uint32_t GetEncodingMask()
void GetDescription(Stream *s, lldb::DescriptionLevel level, bool show_name, ExecutionContextScope *exe_scope)
llvm::Expected< uint32_t > GetNumChildren(bool omit_empty_base_classes)
SymbolContextScope * m_context
The symbol context in which this type is defined.
lldb::user_id_t m_encoding_uid
@ eEncodingIsRestrictUID
This type is the type whose UID is m_encoding_uid with the restrict qualifier added.
@ eEncodingIsConstUID
This type is the type whose UID is m_encoding_uid with the const qualifier added.
@ eEncodingIsVolatileUID
This type is the type whose UID is m_encoding_uid with the volatile qualifier added.
@ eEncodingIsAtomicUID
This type is the type whose UID is m_encoding_uid as an atomic type.
@ eEncodingIsLLVMPtrAuthUID
This type is a signed pointer.
@ eEncodingIsSyntheticUID
This type is the synthetic type whose UID is m_encoding_uid.
@ eEncodingInvalid
Invalid encoding.
@ eEncodingIsTypedefUID
This type is alias to a type whose UID is m_encoding_uid.
@ eEncodingIsPointerUID
This type is pointer to a type whose UID is m_encoding_uid.
@ eEncodingIsLValueReferenceUID
This type is L value reference to a type whose UID is m_encoding_uid.
@ eEncodingIsRValueReferenceUID
This type is R value reference to a type whose UID is m_encoding_uid.
@ eEncodingIsUID
This type is the type whose UID is m_encoding_uid.
Payload m_payload
Language-specific flags.
SymbolFile * GetSymbolFile()
void Dump(Stream *s, bool show_context, lldb::DescriptionLevel level=lldb::eDescriptionLevelFull)
CompilerType GetLayoutCompilerType()
lldb::Encoding GetEncoding(uint64_t &count)
lldb::ModuleSP GetExeModule()
GetModule may return module for compile unit's object file.
void DumpTypeName(Stream *s)
static std::optional< ParsedName > GetTypeScopeAndBasename(llvm::StringRef name)
lldb::TypeSP GetTypedefType()
bool ResolveCompilerType(ResolveState compiler_type_resolve_state)
SymbolFile * m_symbol_file
EncodingDataType m_encoding_uid_type
bool ReadFromMemory(ExecutionContext *exe_ctx, lldb::addr_t address, AddressType address_type, DataExtractor &data)
ConstString GetBaseName()
Type(lldb::user_id_t uid, SymbolFile *symbol_file, ConstString name, std::optional< uint64_t > byte_size, SymbolContextScope *context, lldb::user_id_t encoding_uid, EncodingDataType encoding_uid_type, const Declaration &decl, const CompilerType &compiler_qual_type, ResolveState compiler_type_resolve_state, uint32_t opaque_payload=0)
ConstString GetQualifiedName()
CompilerType GetFullCompilerType()
llvm::Expected< uint64_t > GetByteSize(ExecutionContextScope *exe_scope)
lldb::ModuleSP GetModule()
Since Type instances only keep a "SymbolFile *" internally, other classes like TypeImpl need make sur...
bool WriteToMemory(ExecutionContext *exe_ctx, lldb::addr_t address, AddressType address_type, DataExtractor &data)
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
@ AnyDeclContext
Math any declaration context.
Stream & operator<<(Stream &s, const Mangled &obj)
@ eAddressTypeFile
Address is an address as found in an object or symbol file.
@ eAddressTypeHost
Address is an address in the process that is running this code.
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
@ eDescriptionLevelVerbose
std::weak_ptr< lldb_private::Module > ModuleWP
Format
Display format definitions.
LanguageType
Programming language type.
@ eLanguageTypeC
Non-standardized C, such as K&R.
std::shared_ptr< lldb_private::Type > TypeSP
Encoding
Register encoding definitions.
MemberFunctionKind
Kind of member function.
@ eMemberFunctionKindInstanceMethod
A function that applies to a specific instance.
@ eMemberFunctionKindConstructor
A function used to create instances.
@ eMemberFunctionKindUnknown
Not sure what the type of this is.
@ eMemberFunctionKindDestructor
A function used to tear down existing instances.
@ eMemberFunctionKindStaticMethod
A function that applies to a type rather than any instance.
std::shared_ptr< lldb_private::DataBuffer > DataBufferSP
std::shared_ptr< lldb_private::TypeImpl > TypeImplSP
std::shared_ptr< lldb_private::Module > ModuleSP
CompilerContext allows an array of these items to be passed to perform detailed lookups in SymbolVend...
void Dump(Stream &s) const
A SmallBitVector that represents a set of source languages (lldb::LanguageType).
llvm::SmallVector< llvm::StringRef > scope
lldb::TypeClass type_class
UserID(lldb::user_id_t uid=LLDB_INVALID_UID)
Construct with optional user ID.
lldb::user_id_t GetID() const
Get accessor for the user ID.