33#include "llvm/ADT/StringRef.h"
39 llvm::ArrayRef<CompilerContext> pattern) {
40 auto ctx = context_chain.begin();
41 auto ctx_end = context_chain.end();
48 if (pat.kind == CompilerContextKind::AnyModule) {
51 return ctx.
kind != CompilerContextKind::Module;
56 if (((uint16_t)ctx->kind & (uint16_t)pat.kind) == 0)
59 if (pat.kind != CompilerContextKind::AnyModule && ctx->name != pat.name)
73 s <<
"TranslationUnit";
109 s <<
"(" <<
name <<
")";
133 m_symbol_file(symbol_file), m_type_sp(type_sp) {}
139 m_type_sp = resolved_type->shared_from_this();
148 ResolveState compiler_type_resolve_state, uint32_t opaque_payload)
149 : std::enable_shared_from_this<
Type>(),
UserID(uid), m_name(name),
150 m_symbol_file(symbol_file), m_context(context),
151 m_encoding_uid(encoding_uid), m_encoding_uid_type(encoding_uid_type),
152 m_decl(decl), m_compiler_type(compiler_type),
153 m_compiler_type_resolve_state(compiler_type ? compiler_type_resolve_state
155 m_payload(opaque_payload) {
166 : std::enable_shared_from_this<
Type>(),
UserID(0), m_name(
"<INVALID TYPE>"),
174 *s <<
"id = " << (
const UserID &)*
this;
180 *s <<
", name = \"" << type_name <<
'"';
182 if (qualified_type_name != type_name) {
183 *s <<
", qualified = \"" << qualified_type_name <<
'"';
195 *s <<
", compiler_type = \"";
225 s->
PutCString(
" (unresolved L value reference)");
228 s->
PutCString(
" (unresolved R value reference)");
238 s->
Printf(
"%p: ",
static_cast<void *
>(
this));
240 *s <<
"Type" <<
static_cast<const UserID &
>(*this) <<
' ';
242 *s <<
", name = \"" <<
m_name <<
"\"";
247 if (show_context &&
m_context !=
nullptr) {
253 bool show_fullpaths =
false;
286 s->
PutCString(
" (unresolved L value reference)");
289 s->
PutCString(
" (unresolved R value reference)");
337 if (std::optional<uint64_t> size =
344 if (std::optional<uint64_t> size =
383 type_sp = typedef_type->shared_from_this();
403 const uint64_t byte_size =
411 uint8_t *dst =
const_cast<uint8_t *
>(data.
PeekData(0, byte_size));
412 if (dst !=
nullptr) {
417 memcpy(dst,
reinterpret_cast<uint8_t *
>(addr), byte_size);
442 Type *encoding_type =
nullptr;
450 if (encoding_compiler_type.
IsValid()) {
500 llvm_unreachable(
"Unhandled encoding_data_type.");
504 auto type_system_or_err =
506 if (
auto err = type_system_or_err.takeError()) {
509 "Unable to construct void type from TypeSystemClang: {0}");
512 auto ts = *type_system_or_err;
555 llvm_unreachable(
"Unhandled encoding_data_type.");
585 if (encoding_type ==
nullptr)
589 compiler_type_resolve_state;
610 assert(encoding_type !=
this);
613 return encoding_mask;
636 llvm::StringRef &scope,
637 llvm::StringRef &basename,
638 TypeClass &type_class) {
639 type_class = eTypeClassAny;
645 if (basename.consume_front(
"struct "))
646 type_class = eTypeClassStruct;
647 else if (basename.consume_front(
"class "))
648 type_class = eTypeClassClass;
649 else if (basename.consume_front(
"union "))
650 type_class = eTypeClassUnion;
651 else if (basename.consume_front(
"enum "))
652 type_class = eTypeClassEnumeration;
653 else if (basename.consume_front(
"typedef "))
654 type_class = eTypeClassTypedef;
656 size_t namespace_separator = basename.find(
"::");
657 if (namespace_separator == llvm::StringRef::npos)
660 size_t template_begin = basename.find(
'<');
661 while (namespace_separator != llvm::StringRef::npos) {
662 if (template_begin != llvm::StringRef::npos &&
663 namespace_separator > template_begin) {
664 size_t template_depth = 1;
665 llvm::StringRef template_arg =
666 basename.drop_front(template_begin + 1);
667 while (template_depth > 0 && !template_arg.empty()) {
668 if (template_arg.front() ==
'<')
670 else if (template_arg.front() ==
'>')
672 template_arg = template_arg.drop_front(1);
674 if (template_depth != 0)
676 if (template_arg.empty())
678 basename = template_arg;
680 basename = basename.drop_front(namespace_separator + 2);
682 template_begin = basename.find(
'<');
683 namespace_separator = basename.find(
"::");
685 if (basename.size() < name.size()) {
686 scope = name.take_front(name.size() - basename.size());
703 SymbolFile *symbol_file = ts->GetSymbolFile();
718 : m_type_name(in_type_str) {}
721 : m_type_name(in_type_const_string) {}
732 return !(*
this == other);
785 : m_module_wp(), m_static_type(), m_dynamic_type() {
790 : m_module_wp(), m_static_type(), m_dynamic_type() {
795 : m_module_wp(), m_static_type(), m_dynamic_type(dynamic) {
801 : m_module_wp(), m_static_type(), m_dynamic_type() {
802 SetType(static_type, dynamic_type);
852 module_sp = input_module_wp.lock();
860 if (empty_module_wp.owner_before(input_module_wp) ||
861 input_module_wp.owner_before(empty_module_wp)) {
877 return !(*
this == rhs);
888TypeImpl::operator bool()
const {
return IsValid(); }
1010 if (prefer_dynamic) {
1022 if (prefer_dynamic) {
1036 strm.
Printf(
"Dynamic:\n");
1038 strm.
Printf(
"\nStatic:\n");
1042 strm.
PutCString(
"Invalid TypeImpl module for type has been deleted\n");
1051 auto *symbol_file = type_system->GetSymbolFile();
1052 auto decl_context = type_system->GetCompilerDeclContextForType(
m_static_type);
1053 if (!decl_context.IsValid())
1055 llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
1058 searched_symbol_files, search_result);
1059 if (search_result.
Empty())
1085 stream.
Printf(
"constructor for %s",
1089 stream.
Printf(
"destructor for %s",
1126 const llvm::APSInt &value)
1127 : m_integer_type_sp(integer_type_sp), m_name(name), m_value(value),
1128 m_valid((bool)name && (bool)integer_type_sp)
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOG_ERROR(log, error,...)
bool operator()(const lldb::TypeSP &type)
TypeListImpl & m_type_list
TypeAppendVisitor(TypeListImpl &type_list)
An architecture specification class.
ConstString GetName() const
ConstString GetMangledName() const
CompilerType GetFunctionArgumentType(size_t arg_idx) const
CompilerType GetFunctionReturnType() const
CompilerDeclContext GetDeclContext() const
size_t GetNumFunctionArguments() const
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.
TypeSystemSPWrapper GetTypeSystem() const
Accessors.
CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) const
Create related types using the current type's AST.
std::optional< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
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
ConstString GetDisplayTypeName() 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.
lldb::opaque_compiler_type_t GetOpaqueQualType() const
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 GetFunctionArgumentAtIndex(const size_t index) 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...
size_t GetNumberOfFunctionArguments() const
CompilerType GetNonReferenceType() const
If this type is a reference to a type (L value or R value reference), return a new type with the refe...
uint32_t GetNumChildren(bool omit_empty_base_classes, const ExecutionContext *exe_ctx) const
ConstString GetTypeName(bool BaseOnly=false) const
CompilerType GetTypedefedType() const
If the current object represents a typedef type, get the underlying type.
bool IsAggregateType() const
lldb::Format GetFormat() const
CompilerType GetFullyUnqualifiedType() const
CompilerType GetPointeeType() const
If this type is a pointer type, return the type that the pointer points to, else return an invalid ty...
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 GetFunctionReturnType() const
CompilerType GetAtomicType() const
Return a new CompilerType that is the atomic type of this type.
bool IsTemplateType() const
CompilerType GetCanonicalType() const
void DumpTypeDescription(lldb::DescriptionLevel level=lldb::eDescriptionLevelFull) const
Dump to stdout.
A uniqued constant string class.
void SetCString(const char *cstr)
Set the C string value.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
void Dump(Stream *s, const char *value_if_empty=nullptr) const
Dump the object description to a stream.
void SetString(llvm::StringRef s)
void Clear()
Clear this object's state.
A subclass of DataBuffer that stores a data buffer on the heap.
A class that describes the declaration location of a lldb object.
void Dump(Stream *s, bool show_fullpaths) const
Dump a description of this object to a Stream.
"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.
virtual ArchSpec GetArchitecture()=0
Get the ArchSpec for this object file.
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.
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...
virtual void DumpSymbolContext(Stream *s)=0
Dump the object's symbol context to the stream s.
SymbolFile & m_symbol_file
SymbolFileType(SymbolFile &symbol_file, lldb::user_id_t uid)
Provides public interface for all SymbolFiles.
virtual bool CompleteType(CompilerType &compiler_type)=0
virtual Type * ResolveTypeUID(lldb::user_id_t type_uid)=0
virtual llvm::Expected< lldb::TypeSystemSP > GetTypeSystemForLanguage(lldb::LanguageType language)=0
virtual ObjectFile * GetObjectFile()=0
Sometimes you can find the name of the type corresponding to an object, but we don't have debug infor...
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
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
TypeMap FindTypes(ConstString name)
lldb::TypeSP GetTypeAtIndex(uint32_t idx)
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
CompilerType m_compiler_type
CompilerType GetForwardCompilerType()
static bool GetTypeScopeAndBasename(llvm::StringRef name, llvm::StringRef &scope, llvm::StringRef &basename, lldb::TypeClass &type_class)
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)
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.
@ 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)
lldb::TypeSP GetTypedefType()
bool ResolveCompilerType(ResolveState compiler_type_resolve_state)
SymbolFile * m_symbol_file
EncodingDataType m_encoding_uid_type
std::optional< uint64_t > GetByteSize(ExecutionContextScope *exe_scope)
bool ReadFromMemory(ExecutionContext *exe_ctx, lldb::addr_t address, AddressType address_type, DataExtractor &data)
ConstString GetBaseName()
ConstString GetQualifiedName()
CompilerType GetFullCompilerType()
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.
@ AnyModule
Match 0..n nested modules.
bool contextMatches(llvm::ArrayRef< CompilerContext > context_chain, llvm::ArrayRef< CompilerContext > pattern)
Match context_chain against pattern, which may contain "Any" kinds.
@ 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.
@ 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 mix in class that contains a generic user ID.
lldb::user_id_t GetID() const
Get accessor for the user ID.