23#include "llvm/Support/ErrorExtras.h"
37 return type_system_sp->IsAggregateType(
m_type);
44 return type_system_sp->IsAnonymousType(
m_type);
51 return type_system_sp->IsScopedEnumerationType(
m_type);
56 bool *is_incomplete)
const {
59 return type_system_sp->IsArrayType(
m_type, element_type_ptr, size,
63 element_type_ptr->
Clear();
67 *is_incomplete =
false;
72 uint64_t *size)
const {
75 return type_system_sp->IsVectorType(
m_type, element_type, size);
82 return type_system_sp->IsRuntimeGeneratedType(
m_type);
89 return type_system_sp->IsCharType(
m_type);
96 return type_system_sp->IsCompleteType(
m_type);
103 return type_system_sp->IsForcefullyCompleted(
m_type);
110 return type_system_sp->IsConst(
m_type);
117 return type_system_sp->GetPtrAuthKey(
m_type);
124 return type_system_sp->GetPtrAuthDiscriminator(
m_type);
131 return type_system_sp->GetPtrAuthAddressDiversity(
m_type);
138 return type_system_sp->IsFunctionType(
m_type);
147 return type_system_sp->IsHomogeneousAggregate(
m_type, base_type_ptr);
154 return type_system_sp->GetNumberOfFunctionArguments(
m_type);
169 return type_system_sp->IsFunctionPointerType(
m_type);
176 return type_system_sp->IsMemberFunctionPointerType(
m_type);
183 return type_system_sp->IsMemberDataPointerType(
m_type);
191 return type_system_sp->IsBlockPointerType(
m_type, function_pointer_type_ptr);
198 return type_system_sp->IsIntegerType(
m_type, is_signed);
205 return type_system_sp->IsEnumerationType(
m_type, is_signed);
216 return type_system_sp->IsPointerType(
m_type, pointee_type);
219 pointee_type->
Clear();
226 return type_system_sp->IsPointerOrReferenceType(
m_type, pointee_type);
229 pointee_type->
Clear();
234 bool *is_rvalue)
const {
237 return type_system_sp->IsReferenceType(
m_type, pointee_type, is_rvalue);
240 pointee_type->
Clear();
247 return type_system_sp->ShouldTreatScalarValueAsAddress(
m_type);
259 return type_system_sp->IsFloatingPointType(
m_type);
271 return type_system_sp->IsDefined(
m_type);
278 return type_system_sp->IsPolymorphicClass(
m_type);
284 bool check_cplusplus,
285 bool check_objc)
const {
288 return type_system_sp->IsPossibleDynamicType(
m_type, dynamic_pointee_type,
289 check_cplusplus, check_objc);
296 return type_system_sp->IsScalarType(
m_type);
303 return type_system_sp->IsTemplateType(
m_type);
310 return type_system_sp->IsTypedefType(
m_type);
317 return type_system_sp->IsVoidType(
m_type);
324 return type_system_sp->HasPointerAuthQualifier(
m_type);
331 return type_system_sp->GetTargetAddressSpace(
m_type);
338 return type_system_sp->IsBeingDefined(
m_type);
343 bool is_signed =
false;
348 bool is_signed =
false;
386 return type_system_sp->IsPromotableIntegerType(
m_type);
403 (lldb::eTypeClassClass | lldb::eTypeClassStruct |
404 lldb::eTypeClassUnion);
409 bool carry_virtual)
const {
411 return carry_virtual;
413 if (!carry_virtual) {
415 for (uint32_t i = 0; i < num_virtual_bases; ++i) {
418 if (base.IsVirtualBase(target_base, virtual_base,
421 *virtual_base = base;
429 for (uint32_t i = 0; i < num_direct_bases; ++i) {
432 if (base.IsVirtualBase(target_base, virtual_base, carry_virtual))
451 if (name.IsEmpty() || canonical_name.IsEmpty())
454 if (name == canonical_name)
455 return llvm::formatv(
"'{0}'", name);
457 return llvm::formatv(
"'{0}' (canonically referred to as '{1}')", name,
467 return name == rhs_name;
472 case lldb::eTypeClassClass:
474 case lldb::eTypeClassEnumeration:
476 case lldb::eTypeClassStruct:
478 case lldb::eTypeClassUnion:
483 llvm_unreachable(
"All cases are covered by code above.");
490 for (uint32_t i = 0; i < num_direct_bases; ++i) {
505 return type_system_sp->GetCompleteType(
m_type);
512 return type_system_sp->GetPointerByteSize();
519 return type_system_sp->GetTypeName(
m_type, BaseOnly);
527 return type_system_sp->GetDisplayTypeName(
m_type);
534 return type_system_sp->GetMangledTypeName(
m_type);
543 return type_system_sp->GetTypeInfo(
m_type,
544 pointee_or_element_compiler_type);
551 return type_system_sp->GetMinimumLanguage(
m_type);
558 return type_system_sp->GetTypeClass(
m_type);
559 return lldb::eTypeClassInvalid;
577 return type_system_sp->GetTypeQualifiers(
m_type);
587 return type_system_sp->GetArrayElementType(
m_type, exe_scope);
595 return type_system_sp->GetArrayType(
m_type, size);
624 return type_system_sp->GetFunctionArgumentCount(
m_type);
632 return type_system_sp->GetFunctionArgumentTypeAtIndex(
m_type, idx);
640 return type_system_sp->GetFunctionReturnType(
m_type);
648 return type_system_sp->GetNumMemberFunctions(
m_type);
656 return type_system_sp->GetMemberFunctionAtIndex(
m_type, idx);
671 return type_system_sp->GetPointeeType(
m_type);
679 return type_system_sp->GetPointerType(
m_type);
743 uint32_t payload)
const {
768llvm::Expected<uint64_t>
772 return type_system_sp->GetBitSize(
m_type, exe_scope);
773 return llvm::createStringError(
"invalid type: cannot determine size");
776llvm::Expected<uint64_t>
779 if (!bit_size_or_err)
780 return bit_size_or_err.takeError();
781 return (*bit_size_or_err + 7) / 8;
787 return type_system_sp->GetByteStride(
m_type);
795 return type_system_sp->GetTypeBitAlign(
m_type, exe_scope);
802 return type_system_sp->GetEncoding(
m_type);
809 return type_system_sp->GetFormat(
m_type);
813llvm::Expected<uint32_t>
818 return type_system_sp->GetNumChildren(
m_type, omit_empty_base_classes,
820 return llvm::createStringError(
"invalid type");
826 return type_system_sp->GetBasicTypeEnumeration(
m_type);
833 const llvm::APSInt &value)>
const &callback)
const {
836 return type_system_sp->ForEachEnumerator(
m_type, callback);
842 return type_system_sp->GetNumFields(
m_type);
847 uint64_t *bit_offset_ptr,
848 uint32_t *bitfield_bit_size_ptr,
849 bool *is_bitfield_ptr)
const {
853 bitfield_bit_size_ptr, is_bitfield_ptr);
860 return type_system_sp->GetNumDirectBaseClasses(
m_type);
867 return type_system_sp->GetNumVirtualBaseClasses(
m_type);
873 uint32_t *bit_offset_ptr)
const {
883 uint32_t *bit_offset_ptr)
const {
899 uint32_t &deref_byte_size, int32_t &deref_byte_offset,
ValueObject *valobj,
900 uint64_t &language_flags)
const {
903 return type_system_sp->GetDereferencedType(
904 m_type, exe_ctx, deref_name, deref_byte_size, deref_byte_offset,
905 valobj, language_flags);
911 bool omit_empty_base_classes,
bool ignore_array_bounds,
915 return type_system_sp->GetChildAtIndex(
916 m_type, exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
917 ignore_array_bounds, valobj);
955 llvm::StringRef name,
bool omit_empty_base_classes,
956 std::vector<uint32_t> &child_indexes)
const {
957 if (
IsValid() && !name.empty()) {
959 return type_system_sp->GetIndexOfChildMemberWithName(
960 m_type, name, omit_empty_base_classes, child_indexes);
967 if (
IsValid() && !name.empty()) {
969 return type_system_sp->GetDirectNestedTypeWithName(
m_type, name);
977 return type_system_sp->GetNumTemplateArguments(
m_type, expand_pack);
986 return type_system_sp->GetTemplateArgumentKind(
m_type, idx, expand_pack);
991 bool expand_pack)
const {
994 return type_system_sp->GetTypeTemplateArgument(
m_type, idx, expand_pack);
999std::optional<CompilerType::IntegralTemplateArgument>
1003 return type_system_sp->GetIntegralTemplateArgument(
m_type, idx, expand_pack);
1004 return std::nullopt;
1024 return type_system_sp->ShouldPrintAsOneLiner(
m_type, valobj);
1031 return type_system_sp->IsMeaninglessWithoutDynamicResolution(
m_type);
1039llvm::Expected<uint32_t>
1041 bool omit_empty_base_classes)
const {
1042 if (
IsValid() && !name.empty()) {
1044 return type_system_sp->GetIndexOfChildWithName(
m_type, name,
1045 omit_empty_base_classes);
1047 return llvm::createStringErrorV(
"type has no child named '{0}'", name);
1055 uint32_t bitfield_bit_size,
1056 uint32_t bitfield_bit_offset,
1060 return type_system_sp->DumpTypeValue(
1061 m_type, *s, format, data, byte_offset, byte_size, bitfield_bit_size,
1062 bitfield_bit_offset, exe_scope);
1069 type_system_sp->DumpTypeDescription(
m_type, level);
1076 type_system_sp->DumpTypeDescription(
m_type, *s, level);
1083 return type_system_sp->dump(
m_type);
1084 llvm::errs() <<
"<invalid>\n";
1090 size_t data_byte_size,
Scalar &value,
1105 if (!byte_size_or_err) {
1108 "Cannot get value as scalar: Cannot determine type size: {0}");
1111 uint64_t byte_size = *byte_size_or_err;
1125 if (byte_size <=
sizeof(
unsigned long long)) {
1126 uint64_t uval64 = data.
GetMaxU64(&offset, byte_size);
1127 if (byte_size <=
sizeof(
unsigned int)) {
1128 value = (
unsigned int)uval64;
1130 }
else if (byte_size <=
sizeof(
unsigned long)) {
1131 value = (
unsigned long)uval64;
1133 }
else if (byte_size <=
sizeof(
unsigned long long)) {
1134 value = (
unsigned long long)uval64;
1142 if (byte_size <=
sizeof(
long long)) {
1143 int64_t sval64 = data.
GetMaxS64(&offset, byte_size);
1144 if (byte_size <=
sizeof(
int)) {
1145 value = (int)sval64;
1147 }
else if (byte_size <=
sizeof(
long)) {
1148 value = (long)sval64;
1150 }
else if (byte_size <=
sizeof(
long long)) {
1151 value = (
long long)sval64;
1159 if (byte_size <=
sizeof(
long double)) {
1162 if (byte_size ==
sizeof(
float)) {
1163 if (
sizeof(
float) ==
sizeof(uint32_t)) {
1164 u32 = data.
GetU32(&offset);
1165 value = *((
float *)&u32);
1167 }
else if (
sizeof(
float) ==
sizeof(uint64_t)) {
1168 u64 = data.
GetU64(&offset);
1169 value = *((
float *)&u64);
1172 }
else if (byte_size ==
sizeof(
double)) {
1173 if (
sizeof(
double) ==
sizeof(uint32_t)) {
1174 u32 = data.
GetU32(&offset);
1175 value = *((
double *)&u32);
1177 }
else if (
sizeof(
double) ==
sizeof(uint64_t)) {
1178 u64 = data.
GetU64(&offset);
1179 value = *((
double *)&u64);
1182 }
else if (byte_size ==
sizeof(
long double)) {
1183 if (
sizeof(
long double) ==
sizeof(uint32_t)) {
1184 u32 = data.
GetU32(&offset);
1185 value = *((
long double *)&u32);
1187 }
else if (
sizeof(
long double) ==
sizeof(uint64_t)) {
1188 u64 = data.
GetU64(&offset);
1189 value = *((
long double *)&u64);
1203 assert(
Verify() &&
"verification failed");
1209 assert(
Verify() &&
"verification failed");
1217 return type_system_sp->Verify(
m_type);
1248 return !(lhs == rhs);
#define LLDB_LOG_ERRORV(log, error,...)
Represents a generic declaration context in a program.
Represents a generic declaration such as a function declaration.
This is a minimal wrapper of a TypeSystem shared pointer as returned by CompilerType which conventien...
lldb::TypeSystemSP GetSharedPointer() const
bool operator==(const TypeSystemSPWrapper &other) const
lldb::TypeSystemSP m_typesystem_sp
TypeSystem * operator->() const
Only to be used in a one-off situations like if (typesystem && typesystem->method()) Do not store thi...
Generic representation of a type in a programming language.
uint32_t GetNumberOfNonEmptyBaseClasses()
Go through the base classes and count non-empty ones.
CompilerType GetTypeForFormatters() const
CompilerType GetTypeTemplateArgument(size_t idx, bool expand_pack=false) const
lldb::LanguageType GetMinimumLanguage()
bool GetValueAsScalar(const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, Scalar &value, ExecutionContextScope *exe_scope) const
bool Verify() const
If the type is valid, ask the TypeSystem to verify the integrity of the type to catch CompilerTypes t...
lldb::BasicType GetBasicTypeEnumeration() const
std::optional< IntegralTemplateArgument > GetIntegralTemplateArgument(size_t idx, bool expand_pack=false) const
Returns the value of the template argument and its type.
TypeSystemSPWrapper GetTypeSystem() const
Accessors.
CompilerType GetArrayType(uint64_t size) const
CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) const
Create related types using the current type's AST.
bool IsPossibleDynamicType(CompilerType *target_type, bool check_cplusplus, bool check_objc) const
void SetCompilerType(lldb::TypeSystemWP type_system, lldb::opaque_compiler_type_t type)
CompilerType AddConstModifier() const
Return a new CompilerType adds a const modifier to this type if this type is valid and the type syste...
bool IsArrayType(CompilerType *element_type=nullptr, uint64_t *size=nullptr, bool *is_incomplete=nullptr) const
ConstString GetDisplayTypeName() const
CompilerType GetVirtualBaseClassAtIndex(size_t idx, uint32_t *bit_offset_ptr) const
size_t GetNumMemberFunctions() const
CompilerType GetFunctionArgumentTypeAtIndex(size_t idx) const
uint32_t IsHomogeneousAggregate(CompilerType *base_type_ptr) const
CompilerType GetFieldAtIndex(size_t idx, std::string &name, uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) const
bool IsCompleteType() 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...
bool IsIntegerOrUnscopedEnumerationType() const
size_t GetIndexOfChildMemberWithName(llvm::StringRef name, bool omit_empty_base_classes, std::vector< uint32_t > &child_indexes) const
Lookup a child member given a name.
bool IsScalarOrUnscopedEnumerationType() const
CompilerType GetPointerType() const
Return a new CompilerType that is a pointer to this type.
bool IsContextuallyConvertibleToBool() const
This may only be defined in TypeSystemClang.
llvm::Expected< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
CompilerDecl GetStaticFieldWithName(llvm::StringRef name) const
lldb::TypeClass GetTypeClass() const
lldb::opaque_compiler_type_t GetOpaqueQualType() const
size_t GetNumTemplateArguments(bool expand_pack=false) const
Return the number of template arguments the type has.
CompilerType AddVolatileModifier() const
Return a new CompilerType adds a volatile modifier to this type if this type is valid and the type sy...
bool IsVirtualBase(CompilerType target_base, CompilerType *virtual_base, bool carry_virtual=false) const
Checks whether target_base is a virtual base of type (direct or indirect).
CompilerType AddRestrictModifier() const
Return a new CompilerType adds a restrict modifier to this type if this type is valid and the type sy...
bool IsPointerToVoid() const
bool IsBeingDefined() const
lldb::TypeSystemWP m_type_system
bool HasPointerAuthQualifier() const
CompilerType GetDirectNestedTypeWithName(llvm::StringRef name) const
bool GetPtrAuthAddressDiversity() const
uint32_t GetNumVirtualBaseClasses() const
lldb::Encoding GetEncoding() const
size_t GetPointerByteSize() const
AST related queries.
CompilerType GetFunctionArgumentAtIndex(const size_t index) const
void ForEachEnumerator(std::function< bool(const CompilerType &integer_type, ConstString name, const llvm::APSInt &value)> const &callback) const
If this type is an enumeration, iterate through all of its enumerators using a callback.
bool IsMemberDataPointerType() const
LLVM_DUMP_METHOD void dump() const
Dumping types.
CompilerType GetLValueReferenceType() const
Return a new CompilerType that is a L value reference to this type if this type is valid and the type...
uint32_t GetNumFields() const
bool IsPromotableIntegerType() const
Checks if the type is eligible for integral promotion.
size_t GetNumberOfFunctionArguments() const
bool IsComplexType() const
bool IsIntegerOrEnumerationType(bool &is_signed) const
bool IsScopedEnumerationType() const
bool ShouldTreatScalarValueAsAddress() 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 GetNumDirectBaseClasses() const
bool IsMeaninglessWithoutDynamicResolution() const
bool IsBlockPointerType(CompilerType *function_pointer_type_ptr=nullptr) const
bool IsAnonymousType() const
ConstString GetTypeName(bool BaseOnly=false) const
bool IsEnumerationIntegerTypeSigned() const
CompilerType GetTypedefedType() const
If the current object represents a typedef type, get the underlying type.
bool IsReferenceType(CompilerType *pointee_type=nullptr, bool *is_rvalue=nullptr) const
bool DumpTypeValue(Stream *s, lldb::Format format, const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, ExecutionContextScope *exe_scope)
std::string TypeDescription()
bool IsAggregateType() const
CompilerType GetArrayElementType(ExecutionContextScope *exe_scope) const
Creating related types.
bool IsInteger() const
This is used when you don't care about the signedness of the integer.
CompilerType AddAddressSpaceModifier(uint32_t address_space) const
Return a new CompilerType that qualifies this type with the given target address space if this type i...
llvm::Expected< CompilerType > GetDereferencedType(ExecutionContext *exe_ctx, std::string &deref_name, uint32_t &deref_byte_size, int32_t &deref_byte_offset, ValueObject *valobj, uint64_t &language_flags) const
lldb::Format GetFormat() const
CompilerType GetFullyUnqualifiedType() const
ConstString GetMangledTypeName() const
unsigned GetTypeQualifiers() const
CompilerType GetDirectBaseClassAtIndex(size_t idx, uint32_t *bit_offset_ptr) const
std::optional< size_t > GetTypeBitAlign(ExecutionContextScope *exe_scope) const
const char * GetTypeTag()
bool IsFunctionPointerType() const
CompilerType GetPointeeType() const
If this type is a pointer type, return the type that the pointer points to, else return an invalid ty...
bool IsIntegerType(bool &is_signed) const
bool GetCompleteType() const
Type Completion.
bool IsUnscopedEnumerationType() const
bool IsFloatingPointType() const
Returns true for floating point types (including complex floats).
uint32_t GetTypeInfo(CompilerType *pointee_or_element_compiler_type=nullptr) const
std::optional< uint32_t > GetTargetAddressSpace() const
int GetFunctionArgumentCount() const
Returns -1 if this isn't a function of if the function doesn't have a prototype Returns a value >= 0 ...
llvm::Expected< uint32_t > GetIndexOfChildWithName(llvm::StringRef name, bool omit_empty_base_classes) const
Lookup a child given a name.
unsigned GetPtrAuthDiscriminator() const
bool IsRealFloatingPointType() const
Returns true for non-complex float types.
llvm::Expected< uint32_t > GetNumChildren(bool omit_empty_base_classes, const ExecutionContext *exe_ctx) const
bool IsFunctionType() const
CompilerType GetEnumerationIntegerType() const
lldb::opaque_compiler_type_t m_type
bool CompareTypes(CompilerType rhs) const
llvm::Expected< uint64_t > GetBitSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bits.
bool IsScalarType() const
bool IsForcefullyCompleted() const
bool IsEnumerationType() const
This is used when you don't care about the signedness of the enum.
bool IsPolymorphicClass() const
unsigned GetPtrAuthKey() const
CompilerType GetPromotedIntegerType() const
If the type is promotable, returns the type promoted to a larger integer type according to the type s...
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...
bool IsTypedefType() const
CompilerType GetFunctionReturnType() const
bool IsRecordType() const
bool IsVectorType(CompilerType *element_type=nullptr, uint64_t *size=nullptr) const
bool IsMemberFunctionPointerType() const
llvm::Expected< ChildTypeInfo > GetChildAtIndex(ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers, bool omit_empty_base_classes, bool ignore_array_bounds, ValueObject *valobj) const
Get the child at idx, such as a field, a base class or a pointee.
CompilerType GetAtomicType() const
Return a new CompilerType that is the atomic type of this type.
bool IsTemplateType() const
bool IsNullPtrType() const
CompilerType GetCanonicalType() const
void DumpTypeDescription(lldb::DescriptionLevel level=lldb::eDescriptionLevelFull) const
Dump to stdout.
std::optional< uint64_t > GetByteStride() const
Return the stride of the type in bytes.
bool IsRuntimeGeneratedType() const
lldb::TemplateArgumentKind GetTemplateArgumentKind(size_t idx, bool expand_pack=false) const
LazyBool ShouldPrintAsOneLiner(ValueObject *valobj) const
TypeMemberFunctionImpl GetMemberFunctionAtIndex(size_t idx)
bool IsPointerOrReferenceType(CompilerType *pointee_type=nullptr) const
CompilerType(lldb::TypeSystemWP type_system, lldb::opaque_compiler_type_t type)
Creates a CompilerType with the given TypeSystem and opaque compiler type.
bool IsPointerType(CompilerType *pointee_type=nullptr) const
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.
"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.
A stream class that can stream formatted output to a file.
Interface for representing a type system.
virtual CompilerDecl GetStaticFieldWithName(lldb::opaque_compiler_type_t type, llvm::StringRef name)
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.
bool operator!=(const Address &lhs, const Address &rhs)
bool operator==(const Address &lhs, const Address &rhs)
void * opaque_compiler_type_t
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
BasicType
Basic types enumeration for the public API SBType::GetBasicType().
Format
Display format definitions.
LanguageType
Programming language type.
@ eLanguageTypeC
Non-standardized C, such as K&R.
@ eTemplateArgumentKindNull
Encoding
Register encoding definitions.
@ eEncodingVector
vector registers
@ eEncodingUint
unsigned integer
@ eEncodingSint
signed integer
std::weak_ptr< lldb_private::TypeSystem > TypeSystemWP
A child of a type, as returned by CompilerType::GetChildAtIndex.