Type.h revision 341825
1132718Skan//===-- Type.h --------------------------------------------------*- C++ -*-===// 2132718Skan// 3169689Skan// The LLVM Compiler Infrastructure 4169689Skan// 5132718Skan// This file is distributed under the University of Illinois Open Source 6132718Skan// License. See LICENSE.TXT for details. 7132718Skan// 8132718Skan//===----------------------------------------------------------------------===// 9132718Skan 10132718Skan#ifndef liblldb_Type_h_ 11132718Skan#define liblldb_Type_h_ 12132718Skan 13132718Skan#include "lldb/Core/ClangForward.h" 14132718Skan#include "lldb/Symbol/CompilerDecl.h" 15132718Skan#include "lldb/Symbol/CompilerType.h" 16132718Skan#include "lldb/Symbol/Declaration.h" 17132718Skan#include "lldb/Utility/ConstString.h" 18132718Skan#include "lldb/Utility/UserID.h" 19132718Skan#include "lldb/lldb-private.h" 20169689Skan 21132718Skan#include "llvm/ADT/APSInt.h" 22132718Skan 23132718Skan#include <set> 24132718Skan 25169689Skannamespace lldb_private { 26169689Skan//---------------------------------------------------------------------- 27132718Skan// CompilerContext allows an array of these items to be passed to perform 28132718Skan// detailed lookups in SymbolVendor and SymbolFile functions. 29132718Skan//---------------------------------------------------------------------- 30132718Skanstruct CompilerContext { 31132718Skan CompilerContext(CompilerContextKind t, const ConstString &n) 32132718Skan : type(t), name(n) {} 33132718Skan 34132718Skan bool operator==(const CompilerContext &rhs) const { 35132718Skan return type == rhs.type && name == rhs.name; 36132718Skan } 37132718Skan 38132718Skan void Dump() const; 39132718Skan 40132718Skan CompilerContextKind type; 41169689Skan ConstString name; 42132718Skan}; 43132718Skan 44132718Skanclass SymbolFileType : public std::enable_shared_from_this<SymbolFileType>, 45132718Skan public UserID { 46132718Skanpublic: 47132718Skan SymbolFileType(SymbolFile &symbol_file, lldb::user_id_t uid) 48132718Skan : UserID(uid), m_symbol_file(symbol_file) {} 49169689Skan 50169689Skan SymbolFileType(SymbolFile &symbol_file, const lldb::TypeSP &type_sp); 51132718Skan 52169689Skan ~SymbolFileType() {} 53132718Skan 54132718Skan Type *operator->() { return GetType(); } 55132718Skan 56132718Skan Type *GetType(); 57132718Skan 58132718Skanprotected: 59132718Skan SymbolFile &m_symbol_file; 60132718Skan lldb::TypeSP m_type_sp; 61132718Skan}; 62132718Skan 63132718Skanclass Type : public std::enable_shared_from_this<Type>, public UserID { 64132718Skanpublic: 65132718Skan typedef enum EncodingDataTypeTag { 66132718Skan eEncodingInvalid, 67132718Skan eEncodingIsUID, ///< This type is the type whose UID is m_encoding_uid 68132718Skan eEncodingIsConstUID, ///< This type is the type whose UID is m_encoding_uid 69132718Skan ///with the const qualifier added 70132718Skan eEncodingIsRestrictUID, ///< This type is the type whose UID is 71132718Skan ///m_encoding_uid with the restrict qualifier added 72132718Skan eEncodingIsVolatileUID, ///< This type is the type whose UID is 73132718Skan ///m_encoding_uid with the volatile qualifier added 74132718Skan eEncodingIsTypedefUID, ///< This type is pointer to a type whose UID is 75259666Spfg ///m_encoding_uid 76132718Skan eEncodingIsPointerUID, ///< This type is pointer to a type whose UID is 77132718Skan ///m_encoding_uid 78132718Skan eEncodingIsLValueReferenceUID, ///< This type is L value reference to a type 79132718Skan ///whose UID is m_encoding_uid 80132718Skan eEncodingIsRValueReferenceUID, ///< This type is R value reference to a type 81132718Skan ///whose UID is m_encoding_uid 82132718Skan eEncodingIsSyntheticUID 83132718Skan } EncodingDataType; 84132718Skan 85132718Skan // We must force the underlying type of the enum to be unsigned here. Not 86132718Skan // all compilers behave the same with regards to the default underlying type 87132718Skan // of an enum, but because this enum is used in an enum bitfield and integer 88132718Skan // comparisons are done with the value we need to guarantee that it's always 89132718Skan // unsigned so that, for example, eResolveStateFull doesn't compare less than 90132718Skan // eResolveStateUnresolved when used in a 2-bit bitfield. 91132718Skan typedef enum ResolveStateTag : unsigned { 92132718Skan eResolveStateUnresolved = 0, 93132718Skan eResolveStateForward = 1, 94132718Skan eResolveStateLayout = 2, 95132718Skan eResolveStateFull = 3 96132718Skan } ResolveState; 97132718Skan 98132718Skan Type(lldb::user_id_t uid, SymbolFile *symbol_file, const ConstString &name, 99132718Skan uint64_t byte_size, SymbolContextScope *context, 100132718Skan lldb::user_id_t encoding_uid, EncodingDataType encoding_uid_type, 101132718Skan const Declaration &decl, const CompilerType &compiler_qual_type, 102132718Skan ResolveState compiler_type_resolve_state); 103132718Skan 104132718Skan // This makes an invalid type. Used for functions that return a Type when 105132718Skan // they get an error. 106132718Skan Type(); 107132718Skan 108132718Skan Type(const Type &rhs); 109132718Skan 110132718Skan const Type &operator=(const Type &rhs); 111132718Skan 112132718Skan void Dump(Stream *s, bool show_context); 113132718Skan 114132718Skan void DumpTypeName(Stream *s); 115169689Skan 116132718Skan // Since Type instances only keep a "SymbolFile *" internally, other classes 117132718Skan // like TypeImpl need make sure the module is still around before playing 118132718Skan // with 119132718Skan // Type instances. They can store a weak pointer to the Module; 120169689Skan lldb::ModuleSP GetModule(); 121132718Skan 122132718Skan void GetDescription(Stream *s, lldb::DescriptionLevel level, bool show_name); 123132718Skan 124132718Skan SymbolFile *GetSymbolFile() { return m_symbol_file; } 125132718Skan const SymbolFile *GetSymbolFile() const { return m_symbol_file; } 126169689Skan 127169689Skan TypeList *GetTypeList(); 128132718Skan 129132718Skan const ConstString &GetName(); 130132718Skan 131132718Skan uint64_t GetByteSize(); 132132718Skan 133132718Skan uint32_t GetNumChildren(bool omit_empty_base_classes); 134132718Skan 135169689Skan bool IsAggregateType(); 136132718Skan 137132718Skan bool IsValidType() { return m_encoding_uid_type != eEncodingInvalid; } 138132718Skan 139132718Skan bool IsTypedef() { return m_encoding_uid_type == eEncodingIsTypedefUID; } 140132718Skan 141132718Skan lldb::TypeSP GetTypedefType(); 142132718Skan 143132718Skan const ConstString &GetName() const { return m_name; } 144132718Skan 145132718Skan ConstString GetQualifiedName(); 146132718Skan 147132718Skan void DumpValue(ExecutionContext *exe_ctx, Stream *s, 148132718Skan const DataExtractor &data, uint32_t data_offset, 149169689Skan bool show_type, bool show_summary, bool verbose, 150169689Skan lldb::Format format = lldb::eFormatDefault); 151169689Skan 152132718Skan bool DumpValueInMemory(ExecutionContext *exe_ctx, Stream *s, 153132718Skan lldb::addr_t address, AddressType address_type, 154132718Skan bool show_types, bool show_summary, bool verbose); 155132718Skan 156132718Skan bool ReadFromMemory(ExecutionContext *exe_ctx, lldb::addr_t address, 157132718Skan AddressType address_type, DataExtractor &data); 158132718Skan 159132718Skan bool WriteToMemory(ExecutionContext *exe_ctx, lldb::addr_t address, 160132718Skan AddressType address_type, DataExtractor &data); 161132718Skan 162132718Skan bool GetIsDeclaration() const; 163132718Skan 164132718Skan void SetIsDeclaration(bool b); 165132718Skan 166132718Skan bool GetIsExternal() const; 167132718Skan 168132718Skan void SetIsExternal(bool b); 169169689Skan 170169689Skan lldb::Format GetFormat(); 171169689Skan 172169689Skan lldb::Encoding GetEncoding(uint64_t &count); 173132718Skan 174132718Skan SymbolContextScope *GetSymbolContextScope() { return m_context; } 175132718Skan const SymbolContextScope *GetSymbolContextScope() const { return m_context; } 176132718Skan void SetSymbolContextScope(SymbolContextScope *context) { 177132718Skan m_context = context; 178132718Skan } 179132718Skan 180132718Skan const lldb_private::Declaration &GetDeclaration() const; 181132718Skan 182132718Skan // Get the clang type, and resolve definitions for any 183169689Skan // class/struct/union/enum types completely. 184132718Skan CompilerType GetFullCompilerType(); 185132718Skan 186132718Skan // Get the clang type, and resolve definitions enough so that the type could 187132718Skan // have layout performed. This allows ptrs and refs to 188132718Skan // class/struct/union/enum types remain forward declarations. 189132718Skan CompilerType GetLayoutCompilerType(); 190132718Skan 191132718Skan // Get the clang type and leave class/struct/union/enum types as forward 192132718Skan // declarations if they haven't already been fully defined. 193132718Skan CompilerType GetForwardCompilerType(); 194132718Skan 195132718Skan static int Compare(const Type &a, const Type &b); 196132718Skan 197132718Skan // From a fully qualified typename, split the type into the type basename and 198132718Skan // the remaining type scope (namespaces/classes). 199132718Skan static bool GetTypeScopeAndBasename(const llvm::StringRef& name, 200132718Skan llvm::StringRef &scope, 201132718Skan llvm::StringRef &basename, 202132718Skan lldb::TypeClass &type_class); 203132718Skan void SetEncodingType(Type *encoding_type) { m_encoding_type = encoding_type; } 204169689Skan 205169689Skan uint32_t GetEncodingMask(); 206169689Skan 207169689Skan bool IsCompleteObjCClass() { return m_flags.is_complete_objc_class; } 208169689Skan 209169689Skan void SetIsCompleteObjCClass(bool is_complete_objc_class) { 210169689Skan m_flags.is_complete_objc_class = is_complete_objc_class; 211132718Skan } 212132718Skan 213132718Skanprotected: 214132718Skan ConstString m_name; 215132718Skan SymbolFile *m_symbol_file; 216132718Skan SymbolContextScope 217132718Skan *m_context; // The symbol context in which this type is defined 218132718Skan Type *m_encoding_type; 219132718Skan lldb::user_id_t m_encoding_uid; 220132718Skan EncodingDataType m_encoding_uid_type; 221132718Skan uint64_t m_byte_size; 222132718Skan Declaration m_decl; 223169689Skan CompilerType m_compiler_type; 224169689Skan 225132718Skan struct Flags { 226132718Skan#ifdef __GNUC__ 227132718Skan // using unsigned type here to work around a very noisy gcc warning 228132718Skan unsigned compiler_type_resolve_state : 2; 229132718Skan#else 230132718Skan ResolveState compiler_type_resolve_state : 2; 231132718Skan#endif 232169689Skan bool is_complete_objc_class : 1; 233169689Skan } m_flags; 234132718Skan 235132718Skan Type *GetEncodingType(); 236132718Skan 237132718Skan bool ResolveClangType(ResolveState compiler_type_resolve_state); 238132718Skan}; 239132718Skan 240169689Skan// these classes are used to back the SBType* objects 241169689Skan 242132718Skanclass TypePair { 243132718Skanpublic: 244132718Skan TypePair() : compiler_type(), type_sp() {} 245132718Skan 246132718Skan TypePair(CompilerType type) : compiler_type(type), type_sp() {} 247132718Skan 248132718Skan TypePair(lldb::TypeSP type) : compiler_type(), type_sp(type) { 249132718Skan compiler_type = type_sp->GetForwardCompilerType(); 250132718Skan } 251132718Skan 252132718Skan bool IsValid() const { 253132718Skan return compiler_type.IsValid() || (type_sp.get() != nullptr); 254132718Skan } 255132718Skan 256132718Skan explicit operator bool() const { return IsValid(); } 257132718Skan 258132718Skan bool operator==(const TypePair &rhs) const { 259132718Skan return compiler_type == rhs.compiler_type && 260132718Skan type_sp.get() == rhs.type_sp.get(); 261132718Skan } 262132718Skan 263132718Skan bool operator!=(const TypePair &rhs) const { 264132718Skan return compiler_type != rhs.compiler_type || 265169689Skan type_sp.get() != rhs.type_sp.get(); 266169689Skan } 267169689Skan 268169689Skan void Clear() { 269132718Skan compiler_type.Clear(); 270132718Skan type_sp.reset(); 271132718Skan } 272132718Skan 273132718Skan ConstString GetName() const { 274132718Skan if (type_sp) 275132718Skan return type_sp->GetName(); 276132718Skan if (compiler_type) 277132718Skan return compiler_type.GetTypeName(); 278132718Skan return ConstString(); 279132718Skan } 280132718Skan 281132718Skan ConstString GetDisplayTypeName() const { 282132718Skan if (type_sp) 283132718Skan return type_sp->GetForwardCompilerType().GetDisplayTypeName(); 284132718Skan if (compiler_type) 285132718Skan return compiler_type.GetDisplayTypeName(); 286132718Skan return ConstString(); 287132718Skan } 288132718Skan 289132718Skan void SetType(CompilerType type) { 290132718Skan type_sp.reset(); 291132718Skan compiler_type = type; 292132718Skan } 293132718Skan 294132718Skan void SetType(lldb::TypeSP type) { 295259666Spfg type_sp = type; 296132718Skan if (type_sp) 297132718Skan compiler_type = type_sp->GetForwardCompilerType(); 298132718Skan else 299259666Spfg compiler_type.Clear(); 300132718Skan } 301132718Skan 302132718Skan lldb::TypeSP GetTypeSP() const { return type_sp; } 303132718Skan 304259666Spfg CompilerType GetCompilerType() const { return compiler_type; } 305132718Skan 306132718Skan CompilerType GetPointerType() const { 307132718Skan if (type_sp) 308132718Skan return type_sp->GetForwardCompilerType().GetPointerType(); 309132718Skan return compiler_type.GetPointerType(); 310132718Skan } 311132718Skan 312132718Skan CompilerType GetPointeeType() const { 313132718Skan if (type_sp) 314132718Skan return type_sp->GetForwardCompilerType().GetPointeeType(); 315132718Skan return compiler_type.GetPointeeType(); 316132718Skan } 317132718Skan 318132718Skan CompilerType GetReferenceType() const { 319132718Skan if (type_sp) 320132718Skan return type_sp->GetForwardCompilerType().GetLValueReferenceType(); 321132718Skan else 322132718Skan return compiler_type.GetLValueReferenceType(); 323169689Skan } 324169689Skan 325169689Skan CompilerType GetTypedefedType() const { 326169689Skan if (type_sp) 327169689Skan return type_sp->GetForwardCompilerType().GetTypedefedType(); 328169689Skan else 329169689Skan return compiler_type.GetTypedefedType(); 330169689Skan } 331169689Skan 332169689Skan CompilerType GetDereferencedType() const { 333169689Skan if (type_sp) 334169689Skan return type_sp->GetForwardCompilerType().GetNonReferenceType(); 335132718Skan else 336132718Skan return compiler_type.GetNonReferenceType(); 337132718Skan } 338169689Skan 339132718Skan CompilerType GetUnqualifiedType() const { 340169689Skan if (type_sp) 341132718Skan return type_sp->GetForwardCompilerType().GetFullyUnqualifiedType(); 342132718Skan else 343132718Skan return compiler_type.GetFullyUnqualifiedType(); 344169689Skan } 345132718Skan 346132718Skan CompilerType GetCanonicalType() const { 347132718Skan if (type_sp) 348132718Skan return type_sp->GetForwardCompilerType().GetCanonicalType(); 349132718Skan return compiler_type.GetCanonicalType(); 350132718Skan } 351132718Skan 352169689Skan TypeSystem *GetTypeSystem() const { return compiler_type.GetTypeSystem(); } 353132718Skan 354132718Skan lldb::ModuleSP GetModule() const { 355132718Skan if (type_sp) 356132718Skan return type_sp->GetModule(); 357132718Skan return lldb::ModuleSP(); 358132718Skan } 359169689Skan 360169689Skanprotected: 361132718Skan CompilerType compiler_type; 362169689Skan lldb::TypeSP type_sp; 363132718Skan}; 364132718Skan 365132718Skan// the two classes here are used by the public API as a backend to the SBType 366132718Skan// and SBTypeList classes 367132718Skan 368132718Skanclass TypeImpl { 369169689Skanpublic: 370169689Skan TypeImpl(); 371132718Skan 372132718Skan ~TypeImpl() {} 373132718Skan 374132718Skan TypeImpl(const TypeImpl &rhs); 375132718Skan 376132718Skan TypeImpl(const lldb::TypeSP &type_sp); 377132718Skan 378132718Skan TypeImpl(const CompilerType &compiler_type); 379132718Skan 380132718Skan TypeImpl(const lldb::TypeSP &type_sp, const CompilerType &dynamic); 381132718Skan 382132718Skan TypeImpl(const CompilerType &compiler_type, const CompilerType &dynamic); 383132718Skan 384132718Skan TypeImpl(const TypePair &pair, const CompilerType &dynamic); 385132718Skan 386132718Skan void SetType(const lldb::TypeSP &type_sp); 387132718Skan 388169689Skan void SetType(const CompilerType &compiler_type); 389169689Skan 390132718Skan void SetType(const lldb::TypeSP &type_sp, const CompilerType &dynamic); 391132718Skan 392169689Skan void SetType(const CompilerType &compiler_type, const CompilerType &dynamic); 393132718Skan 394169689Skan void SetType(const TypePair &pair, const CompilerType &dynamic); 395169689Skan 396132718Skan TypeImpl &operator=(const TypeImpl &rhs); 397132718Skan 398132718Skan bool operator==(const TypeImpl &rhs) const; 399132718Skan 400132718Skan bool operator!=(const TypeImpl &rhs) const; 401169689Skan 402169689Skan bool IsValid() const; 403169689Skan 404169689Skan explicit operator bool() const; 405169689Skan 406169689Skan void Clear(); 407169689Skan 408169689Skan ConstString GetName() const; 409169689Skan 410169689Skan ConstString GetDisplayTypeName() const; 411169689Skan 412169689Skan TypeImpl GetPointerType() const; 413169689Skan 414169689Skan TypeImpl GetPointeeType() const; 415169689Skan 416169689Skan TypeImpl GetReferenceType() const; 417169689Skan 418 TypeImpl GetTypedefedType() const; 419 420 TypeImpl GetDereferencedType() const; 421 422 TypeImpl GetUnqualifiedType() const; 423 424 TypeImpl GetCanonicalType() const; 425 426 CompilerType GetCompilerType(bool prefer_dynamic); 427 428 TypeSystem *GetTypeSystem(bool prefer_dynamic); 429 430 bool GetDescription(lldb_private::Stream &strm, 431 lldb::DescriptionLevel description_level); 432 433private: 434 bool CheckModule(lldb::ModuleSP &module_sp) const; 435 436 lldb::ModuleWP m_module_wp; 437 TypePair m_static_type; 438 CompilerType m_dynamic_type; 439}; 440 441class TypeListImpl { 442public: 443 TypeListImpl() : m_content() {} 444 445 void Append(const lldb::TypeImplSP &type) { m_content.push_back(type); } 446 447 class AppendVisitor { 448 public: 449 AppendVisitor(TypeListImpl &type_list) : m_type_list(type_list) {} 450 451 void operator()(const lldb::TypeImplSP &type) { m_type_list.Append(type); } 452 453 private: 454 TypeListImpl &m_type_list; 455 }; 456 457 void Append(const lldb_private::TypeList &type_list); 458 459 lldb::TypeImplSP GetTypeAtIndex(size_t idx) { 460 lldb::TypeImplSP type_sp; 461 if (idx < GetSize()) 462 type_sp = m_content[idx]; 463 return type_sp; 464 } 465 466 size_t GetSize() { return m_content.size(); } 467 468private: 469 std::vector<lldb::TypeImplSP> m_content; 470}; 471 472class TypeMemberImpl { 473public: 474 TypeMemberImpl() 475 : m_type_impl_sp(), m_bit_offset(0), m_name(), m_bitfield_bit_size(0), 476 m_is_bitfield(false) 477 478 {} 479 480 TypeMemberImpl(const lldb::TypeImplSP &type_impl_sp, uint64_t bit_offset, 481 const ConstString &name, uint32_t bitfield_bit_size = 0, 482 bool is_bitfield = false) 483 : m_type_impl_sp(type_impl_sp), m_bit_offset(bit_offset), m_name(name), 484 m_bitfield_bit_size(bitfield_bit_size), m_is_bitfield(is_bitfield) {} 485 486 TypeMemberImpl(const lldb::TypeImplSP &type_impl_sp, uint64_t bit_offset) 487 : m_type_impl_sp(type_impl_sp), m_bit_offset(bit_offset), m_name(), 488 m_bitfield_bit_size(0), m_is_bitfield(false) { 489 if (m_type_impl_sp) 490 m_name = m_type_impl_sp->GetName(); 491 } 492 493 const lldb::TypeImplSP &GetTypeImpl() { return m_type_impl_sp; } 494 495 const ConstString &GetName() const { return m_name; } 496 497 uint64_t GetBitOffset() const { return m_bit_offset; } 498 499 uint32_t GetBitfieldBitSize() const { return m_bitfield_bit_size; } 500 501 void SetBitfieldBitSize(uint32_t bitfield_bit_size) { 502 m_bitfield_bit_size = bitfield_bit_size; 503 } 504 505 bool GetIsBitfield() const { return m_is_bitfield; } 506 507 void SetIsBitfield(bool is_bitfield) { m_is_bitfield = is_bitfield; } 508 509protected: 510 lldb::TypeImplSP m_type_impl_sp; 511 uint64_t m_bit_offset; 512 ConstString m_name; 513 uint32_t m_bitfield_bit_size; // Bit size for bitfield members only 514 bool m_is_bitfield; 515}; 516 517/// 518/// Sometimes you can find the name of the type corresponding to an object, but 519/// we don't have debug 520/// information for it. If that is the case, you can return one of these 521/// objects, and then if it 522/// has a full type, you can use that, but if not at least you can print the 523/// name for informational 524/// purposes. 525/// 526 527class TypeAndOrName { 528public: 529 TypeAndOrName(); 530 TypeAndOrName(lldb::TypeSP &type_sp); 531 TypeAndOrName(const CompilerType &compiler_type); 532 TypeAndOrName(const char *type_str); 533 TypeAndOrName(const TypeAndOrName &rhs); 534 TypeAndOrName(ConstString &type_const_string); 535 536 TypeAndOrName &operator=(const TypeAndOrName &rhs); 537 538 bool operator==(const TypeAndOrName &other) const; 539 540 bool operator!=(const TypeAndOrName &other) const; 541 542 ConstString GetName() const; 543 544 lldb::TypeSP GetTypeSP() const { return m_type_pair.GetTypeSP(); } 545 546 CompilerType GetCompilerType() const { return m_type_pair.GetCompilerType(); } 547 548 void SetName(const ConstString &type_name); 549 550 void SetName(const char *type_name_cstr); 551 552 void SetTypeSP(lldb::TypeSP type_sp); 553 554 void SetCompilerType(CompilerType compiler_type); 555 556 bool IsEmpty() const; 557 558 bool HasName() const; 559 560 bool HasTypeSP() const; 561 562 bool HasCompilerType() const; 563 564 bool HasType() const { return HasTypeSP() || HasCompilerType(); } 565 566 void Clear(); 567 568 explicit operator bool() { return !IsEmpty(); } 569 570private: 571 TypePair m_type_pair; 572 ConstString m_type_name; 573}; 574 575class TypeMemberFunctionImpl { 576public: 577 TypeMemberFunctionImpl() 578 : m_type(), m_decl(), m_name(), m_kind(lldb::eMemberFunctionKindUnknown) { 579 } 580 581 TypeMemberFunctionImpl(const CompilerType &type, const CompilerDecl &decl, 582 const std::string &name, 583 const lldb::MemberFunctionKind &kind) 584 : m_type(type), m_decl(decl), m_name(name), m_kind(kind) {} 585 586 bool IsValid(); 587 588 ConstString GetName() const; 589 590 ConstString GetMangledName() const; 591 592 CompilerType GetType() const; 593 594 CompilerType GetReturnType() const; 595 596 size_t GetNumArguments() const; 597 598 CompilerType GetArgumentAtIndex(size_t idx) const; 599 600 lldb::MemberFunctionKind GetKind() const; 601 602 bool GetDescription(Stream &stream); 603 604protected: 605 std::string GetPrintableTypeName(); 606 607private: 608 CompilerType m_type; 609 CompilerDecl m_decl; 610 ConstString m_name; 611 lldb::MemberFunctionKind m_kind; 612}; 613 614class TypeEnumMemberImpl { 615public: 616 TypeEnumMemberImpl() 617 : m_integer_type_sp(), m_name("<invalid>"), m_value(), m_valid(false) {} 618 619 TypeEnumMemberImpl(const lldb::TypeImplSP &integer_type_sp, 620 const ConstString &name, const llvm::APSInt &value); 621 622 TypeEnumMemberImpl(const TypeEnumMemberImpl &rhs) 623 : m_integer_type_sp(rhs.m_integer_type_sp), m_name(rhs.m_name), 624 m_value(rhs.m_value), m_valid(rhs.m_valid) {} 625 626 TypeEnumMemberImpl &operator=(const TypeEnumMemberImpl &rhs); 627 628 bool IsValid() { return m_valid; } 629 630 const ConstString &GetName() const { return m_name; } 631 632 const lldb::TypeImplSP &GetIntegerType() const { return m_integer_type_sp; } 633 634 uint64_t GetValueAsUnsigned() const { return m_value.getZExtValue(); } 635 636 int64_t GetValueAsSigned() const { return m_value.getSExtValue(); } 637 638protected: 639 lldb::TypeImplSP m_integer_type_sp; 640 ConstString m_name; 641 llvm::APSInt m_value; 642 bool m_valid; 643}; 644 645class TypeEnumMemberListImpl { 646public: 647 TypeEnumMemberListImpl() : m_content() {} 648 649 void Append(const lldb::TypeEnumMemberImplSP &type) { 650 m_content.push_back(type); 651 } 652 653 void Append(const lldb_private::TypeEnumMemberListImpl &type_list); 654 655 lldb::TypeEnumMemberImplSP GetTypeEnumMemberAtIndex(size_t idx) { 656 lldb::TypeEnumMemberImplSP enum_member; 657 if (idx < GetSize()) 658 enum_member = m_content[idx]; 659 return enum_member; 660 } 661 662 size_t GetSize() { return m_content.size(); } 663 664private: 665 std::vector<lldb::TypeEnumMemberImplSP> m_content; 666}; 667 668} // namespace lldb_private 669 670#endif // liblldb_Type_h_ 671