1 //===-- SBType.h ------------------------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLDB_API_SBTYPE_H 10 #define LLDB_API_SBTYPE_H 11 12 #include "lldb/API/SBDefines.h" 13 14 namespace lldb { 15 16 class SBTypeList; 17 18 class LLDB_API SBTypeMember { 19 public: 20 SBTypeMember(); 21 22 SBTypeMember(const lldb::SBTypeMember &rhs); 23 24 ~SBTypeMember(); 25 26 lldb::SBTypeMember &operator=(const lldb::SBTypeMember &rhs); 27 28 explicit operator bool() const; 29 30 bool IsValid() const; 31 32 const char *GetName(); 33 34 lldb::SBType GetType(); 35 36 uint64_t GetOffsetInBytes(); 37 38 uint64_t GetOffsetInBits(); 39 40 bool IsBitfield(); 41 42 uint32_t GetBitfieldSizeInBits(); 43 44 bool GetDescription(lldb::SBStream &description, 45 lldb::DescriptionLevel description_level); 46 47 protected: 48 friend class SBType; 49 50 void reset(lldb_private::TypeMemberImpl *); 51 52 lldb_private::TypeMemberImpl &ref(); 53 54 const lldb_private::TypeMemberImpl &ref() const; 55 56 std::unique_ptr<lldb_private::TypeMemberImpl> m_opaque_up; 57 }; 58 59 class SBTypeMemberFunction { 60 public: 61 SBTypeMemberFunction(); 62 63 SBTypeMemberFunction(const lldb::SBTypeMemberFunction &rhs); 64 65 ~SBTypeMemberFunction(); 66 67 lldb::SBTypeMemberFunction &operator=(const lldb::SBTypeMemberFunction &rhs); 68 69 explicit operator bool() const; 70 71 bool IsValid() const; 72 73 const char *GetName(); 74 75 const char *GetDemangledName(); 76 77 const char *GetMangledName(); 78 79 lldb::SBType GetType(); 80 81 lldb::SBType GetReturnType(); 82 83 uint32_t GetNumberOfArguments(); 84 85 lldb::SBType GetArgumentTypeAtIndex(uint32_t); 86 87 lldb::MemberFunctionKind GetKind(); 88 89 bool GetDescription(lldb::SBStream &description, 90 lldb::DescriptionLevel description_level); 91 92 protected: 93 friend class SBType; 94 95 void reset(lldb_private::TypeMemberFunctionImpl *); 96 97 lldb_private::TypeMemberFunctionImpl &ref(); 98 99 const lldb_private::TypeMemberFunctionImpl &ref() const; 100 101 lldb::TypeMemberFunctionImplSP m_opaque_sp; 102 }; 103 104 class SBType { 105 public: 106 SBType(); 107 108 SBType(const lldb::SBType &rhs); 109 SBType(const lldb::TypeImplSP &); 110 111 ~SBType(); 112 113 explicit operator bool() const; 114 115 bool IsValid() const; 116 117 uint64_t GetByteSize(); 118 119 bool IsPointerType(); 120 121 bool IsReferenceType(); 122 123 bool IsFunctionType(); 124 125 bool IsPolymorphicClass(); 126 127 bool IsArrayType(); 128 129 bool IsVectorType(); 130 131 bool IsTypedefType(); 132 133 bool IsAnonymousType(); 134 135 bool IsScopedEnumerationType(); 136 137 bool IsAggregateType(); 138 139 lldb::SBType GetPointerType(); 140 141 lldb::SBType GetPointeeType(); 142 143 lldb::SBType GetReferenceType(); 144 145 lldb::SBType GetTypedefedType(); 146 147 lldb::SBType GetDereferencedType(); 148 149 lldb::SBType GetUnqualifiedType(); 150 151 lldb::SBType GetArrayElementType(); 152 153 lldb::SBType GetArrayType(uint64_t size); 154 155 lldb::SBType GetVectorElementType(); 156 157 lldb::SBType GetCanonicalType(); 158 159 lldb::SBType GetEnumerationIntegerType(); 160 161 // Get the "lldb::BasicType" enumeration for a type. If a type is not a basic 162 // type eBasicTypeInvalid will be returned 163 lldb::BasicType GetBasicType(); 164 165 // The call below confusing and should really be renamed to "CreateBasicType" 166 lldb::SBType GetBasicType(lldb::BasicType type); 167 168 uint32_t GetNumberOfFields(); 169 170 uint32_t GetNumberOfDirectBaseClasses(); 171 172 uint32_t GetNumberOfVirtualBaseClasses(); 173 174 lldb::SBTypeMember GetFieldAtIndex(uint32_t idx); 175 176 lldb::SBTypeMember GetDirectBaseClassAtIndex(uint32_t idx); 177 178 lldb::SBTypeMember GetVirtualBaseClassAtIndex(uint32_t idx); 179 180 lldb::SBTypeEnumMemberList GetEnumMembers(); 181 182 uint32_t GetNumberOfTemplateArguments(); 183 184 lldb::SBType GetTemplateArgumentType(uint32_t idx); 185 186 /// Return the TemplateArgumentKind of the template argument at index idx. 187 /// Variadic argument packs are automatically expanded. 188 lldb::TemplateArgumentKind GetTemplateArgumentKind(uint32_t idx); 189 190 lldb::SBType GetFunctionReturnType(); 191 192 lldb::SBTypeList GetFunctionArgumentTypes(); 193 194 uint32_t GetNumberOfMemberFunctions(); 195 196 lldb::SBTypeMemberFunction GetMemberFunctionAtIndex(uint32_t idx); 197 198 lldb::SBModule GetModule(); 199 200 const char *GetName(); 201 202 const char *GetDisplayTypeName(); 203 204 lldb::TypeClass GetTypeClass(); 205 206 bool IsTypeComplete(); 207 208 uint32_t GetTypeFlags(); 209 210 bool GetDescription(lldb::SBStream &description, 211 lldb::DescriptionLevel description_level); 212 213 lldb::SBType &operator=(const lldb::SBType &rhs); 214 215 bool operator==(lldb::SBType &rhs); 216 217 bool operator!=(lldb::SBType &rhs); 218 219 protected: 220 lldb_private::TypeImpl &ref(); 221 222 const lldb_private::TypeImpl &ref() const; 223 224 lldb::TypeImplSP GetSP(); 225 226 void SetSP(const lldb::TypeImplSP &type_impl_sp); 227 228 lldb::TypeImplSP m_opaque_sp; 229 230 friend class SBFunction; 231 friend class SBModule; 232 friend class SBTarget; 233 friend class SBTypeEnumMember; 234 friend class SBTypeEnumMemberList; 235 friend class SBTypeNameSpecifier; 236 friend class SBTypeMember; 237 friend class SBTypeMemberFunction; 238 friend class SBTypeList; 239 friend class SBValue; 240 241 SBType(const lldb_private::CompilerType &); 242 SBType(const lldb::TypeSP &); 243 }; 244 245 class SBTypeList { 246 public: 247 SBTypeList(); 248 249 SBTypeList(const lldb::SBTypeList &rhs); 250 251 ~SBTypeList(); 252 253 lldb::SBTypeList &operator=(const lldb::SBTypeList &rhs); 254 255 explicit operator bool() const; 256 257 bool IsValid(); 258 259 void Append(lldb::SBType type); 260 261 lldb::SBType GetTypeAtIndex(uint32_t index); 262 263 uint32_t GetSize(); 264 265 private: 266 std::unique_ptr<lldb_private::TypeListImpl> m_opaque_up; 267 friend class SBModule; 268 friend class SBCompileUnit; 269 }; 270 271 } // namespace lldb 272 273 #endif // LLDB_API_SBTYPE_H 274