TypeSystem.h revision 314564
1292932Sdim//===-- TypeSystem.h ------------------------------------------*- C++ -*-===// 2292932Sdim// 3292932Sdim// The LLVM Compiler Infrastructure 4292932Sdim// 5292932Sdim// This file is distributed under the University of Illinois Open Source 6292932Sdim// License. See LICENSE.TXT for details. 7292932Sdim// 8292932Sdim//===----------------------------------------------------------------------===// 9292932Sdim 10292932Sdim#ifndef liblldb_TypeSystem_h_ 11292932Sdim#define liblldb_TypeSystem_h_ 12292932Sdim 13292932Sdim// C Includes 14292932Sdim// C++ Includes 15292932Sdim#include <functional> 16292932Sdim#include <map> 17309124Sdim#include <mutex> 18292932Sdim#include <string> 19292932Sdim 20292932Sdim// Other libraries and framework includes 21292932Sdim#include "llvm/ADT/APSInt.h" 22292932Sdim#include "llvm/Support/Casting.h" 23292932Sdim 24292932Sdim// Project includes 25292932Sdim#include "lldb/Core/PluginInterface.h" 26292932Sdim#include "lldb/Expression/Expression.h" 27292932Sdim#include "lldb/Symbol/CompilerDecl.h" 28292932Sdim#include "lldb/Symbol/CompilerDeclContext.h" 29314564Sdim#include "lldb/lldb-private.h" 30292932Sdim 31292932Sdimclass DWARFDIE; 32292932Sdimclass DWARFASTParser; 33292932Sdim 34292932Sdimnamespace lldb_private { 35314564Sdim 36292932Sdim//---------------------------------------------------------------------- 37292932Sdim// Interface for representing the Type Systems in different languages. 38292932Sdim//---------------------------------------------------------------------- 39314564Sdimclass TypeSystem : public PluginInterface { 40292932Sdimpublic: 41314564Sdim //---------------------------------------------------------------------- 42314564Sdim // Intrusive type system that allows us to use llvm casting. 43314564Sdim // 44314564Sdim // To add a new type system: 45314564Sdim // 46314564Sdim // 1 - Add a new enumeration for llvm casting below for your TypeSystem 47314564Sdim // subclass, here we will use eKindFoo 48314564Sdim // 49314564Sdim // 2 - Your TypeSystem subclass will inherit from TypeSystem and needs 50314564Sdim // to implement a static classof() function that returns your 51314564Sdim // enumeration: 52314564Sdim // 53314564Sdim // class Foo : public lldb_private::TypeSystem 54314564Sdim // { 55314564Sdim // static bool classof(const TypeSystem *ts) 56314564Sdim // { 57314564Sdim // return ts->getKind() == TypeSystem::eKindFoo; 58314564Sdim // } 59314564Sdim // }; 60314564Sdim // 61314564Sdim // 3 - Contruct your TypeSystem subclass with the enumeration from below 62314564Sdim // 63314564Sdim // Foo() : 64314564Sdim // TypeSystem(TypeSystem::eKindFoo), 65314564Sdim // ... 66314564Sdim // { 67314564Sdim // } 68314564Sdim // 69314564Sdim // Then you can use the llvm casting on any "TypeSystem *" to get an 70314564Sdim // instance of your subclass. 71314564Sdim //---------------------------------------------------------------------- 72314564Sdim enum LLVMCastKind { 73314564Sdim eKindClang, 74314564Sdim eKindSwift, 75314564Sdim eKindGo, 76314564Sdim eKindJava, 77314564Sdim eKindOCaml, 78314564Sdim kNumKinds 79314564Sdim }; 80292932Sdim 81314564Sdim //---------------------------------------------------------------------- 82314564Sdim // Constructors and Destructors 83314564Sdim //---------------------------------------------------------------------- 84314564Sdim TypeSystem(LLVMCastKind kind); 85292932Sdim 86314564Sdim ~TypeSystem() override; 87292932Sdim 88314564Sdim LLVMCastKind getKind() const { return m_kind; } 89292932Sdim 90314564Sdim static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language, 91314564Sdim Module *module); 92292932Sdim 93314564Sdim static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language, 94314564Sdim Target *target); 95309124Sdim 96314564Sdim // Free up any resources associated with this TypeSystem. Done before 97314564Sdim // removing 98314564Sdim // all the TypeSystems from the TypeSystemMap. 99314564Sdim virtual void Finalize() {} 100292932Sdim 101314564Sdim virtual DWARFASTParser *GetDWARFParser() { return nullptr; } 102292932Sdim 103314564Sdim virtual SymbolFile *GetSymbolFile() const { return m_sym_file; } 104292932Sdim 105314564Sdim // Returns true if the symbol file changed during the set accessor. 106314564Sdim virtual void SetSymbolFile(SymbolFile *sym_file) { m_sym_file = sym_file; } 107292932Sdim 108314564Sdim //---------------------------------------------------------------------- 109314564Sdim // CompilerDecl functions 110314564Sdim //---------------------------------------------------------------------- 111314564Sdim virtual ConstString DeclGetName(void *opaque_decl) = 0; 112292932Sdim 113314564Sdim virtual ConstString DeclGetMangledName(void *opaque_decl); 114292932Sdim 115314564Sdim virtual CompilerDeclContext DeclGetDeclContext(void *opaque_decl); 116292932Sdim 117314564Sdim virtual CompilerType DeclGetFunctionReturnType(void *opaque_decl); 118292932Sdim 119314564Sdim virtual size_t DeclGetFunctionNumArguments(void *opaque_decl); 120292932Sdim 121314564Sdim virtual CompilerType DeclGetFunctionArgumentType(void *opaque_decl, 122314564Sdim size_t arg_idx); 123292932Sdim 124314564Sdim //---------------------------------------------------------------------- 125314564Sdim // CompilerDeclContext functions 126314564Sdim //---------------------------------------------------------------------- 127292932Sdim 128314564Sdim virtual std::vector<CompilerDecl> 129314564Sdim DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name, 130314564Sdim const bool ignore_imported_decls); 131292932Sdim 132314564Sdim virtual bool DeclContextIsStructUnionOrClass(void *opaque_decl_ctx) = 0; 133294024Sdim 134314564Sdim virtual ConstString DeclContextGetName(void *opaque_decl_ctx) = 0; 135292932Sdim 136314564Sdim virtual ConstString 137314564Sdim DeclContextGetScopeQualifiedName(void *opaque_decl_ctx) = 0; 138292932Sdim 139314564Sdim virtual bool DeclContextIsClassMethod( 140314564Sdim void *opaque_decl_ctx, lldb::LanguageType *language_ptr, 141314564Sdim bool *is_instance_method_ptr, ConstString *language_object_name_ptr) = 0; 142292932Sdim 143314564Sdim //---------------------------------------------------------------------- 144314564Sdim // Tests 145314564Sdim //---------------------------------------------------------------------- 146309124Sdim 147314564Sdim virtual bool IsArrayType(lldb::opaque_compiler_type_t type, 148314564Sdim CompilerType *element_type, uint64_t *size, 149314564Sdim bool *is_incomplete) = 0; 150309124Sdim 151314564Sdim virtual bool IsAggregateType(lldb::opaque_compiler_type_t type) = 0; 152292932Sdim 153314564Sdim virtual bool IsAnonymousType(lldb::opaque_compiler_type_t type); 154292932Sdim 155314564Sdim virtual bool IsCharType(lldb::opaque_compiler_type_t type) = 0; 156292932Sdim 157314564Sdim virtual bool IsCompleteType(lldb::opaque_compiler_type_t type) = 0; 158292932Sdim 159314564Sdim virtual bool IsDefined(lldb::opaque_compiler_type_t type) = 0; 160292932Sdim 161314564Sdim virtual bool IsFloatingPointType(lldb::opaque_compiler_type_t type, 162314564Sdim uint32_t &count, bool &is_complex) = 0; 163292932Sdim 164314564Sdim virtual bool IsFunctionType(lldb::opaque_compiler_type_t type, 165314564Sdim bool *is_variadic_ptr) = 0; 166292932Sdim 167314564Sdim virtual size_t 168314564Sdim GetNumberOfFunctionArguments(lldb::opaque_compiler_type_t type) = 0; 169292932Sdim 170314564Sdim virtual CompilerType 171314564Sdim GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type, 172314564Sdim const size_t index) = 0; 173292932Sdim 174314564Sdim virtual bool IsFunctionPointerType(lldb::opaque_compiler_type_t type) = 0; 175292932Sdim 176314564Sdim virtual bool IsBlockPointerType(lldb::opaque_compiler_type_t type, 177314564Sdim CompilerType *function_pointer_type_ptr) = 0; 178292932Sdim 179314564Sdim virtual bool IsIntegerType(lldb::opaque_compiler_type_t type, 180314564Sdim bool &is_signed) = 0; 181292932Sdim 182314564Sdim virtual bool IsEnumerationType(lldb::opaque_compiler_type_t type, 183314564Sdim bool &is_signed) { 184314564Sdim is_signed = false; 185314564Sdim return false; 186314564Sdim } 187292932Sdim 188314564Sdim virtual bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type, 189314564Sdim CompilerType *target_type, // Can pass NULL 190314564Sdim bool check_cplusplus, bool check_objc) = 0; 191292932Sdim 192314564Sdim virtual bool IsPointerType(lldb::opaque_compiler_type_t type, 193314564Sdim CompilerType *pointee_type) = 0; 194292932Sdim 195314564Sdim virtual bool IsScalarType(lldb::opaque_compiler_type_t type) = 0; 196292932Sdim 197314564Sdim virtual bool IsVoidType(lldb::opaque_compiler_type_t type) = 0; 198292932Sdim 199314564Sdim // TypeSystems can support more than one language 200314564Sdim virtual bool SupportsLanguage(lldb::LanguageType language) = 0; 201292932Sdim 202314564Sdim //---------------------------------------------------------------------- 203314564Sdim // Type Completion 204314564Sdim //---------------------------------------------------------------------- 205292932Sdim 206314564Sdim virtual bool GetCompleteType(lldb::opaque_compiler_type_t type) = 0; 207292932Sdim 208314564Sdim //---------------------------------------------------------------------- 209314564Sdim // AST related queries 210314564Sdim //---------------------------------------------------------------------- 211292932Sdim 212314564Sdim virtual uint32_t GetPointerByteSize() = 0; 213292932Sdim 214314564Sdim //---------------------------------------------------------------------- 215314564Sdim // Accessors 216314564Sdim //---------------------------------------------------------------------- 217292932Sdim 218314564Sdim virtual ConstString GetTypeName(lldb::opaque_compiler_type_t type) = 0; 219292932Sdim 220314564Sdim virtual uint32_t 221314564Sdim GetTypeInfo(lldb::opaque_compiler_type_t type, 222314564Sdim CompilerType *pointee_or_element_compiler_type) = 0; 223292932Sdim 224314564Sdim virtual lldb::LanguageType 225314564Sdim GetMinimumLanguage(lldb::opaque_compiler_type_t type) = 0; 226314564Sdim 227314564Sdim virtual lldb::TypeClass GetTypeClass(lldb::opaque_compiler_type_t type) = 0; 228314564Sdim 229314564Sdim //---------------------------------------------------------------------- 230314564Sdim // Creating related types 231314564Sdim //---------------------------------------------------------------------- 232314564Sdim 233314564Sdim virtual CompilerType GetArrayElementType(lldb::opaque_compiler_type_t type, 234314564Sdim uint64_t *stride) = 0; 235314564Sdim 236314564Sdim virtual CompilerType GetArrayType(lldb::opaque_compiler_type_t type, 237314564Sdim uint64_t size); 238314564Sdim 239314564Sdim virtual CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) = 0; 240314564Sdim 241314564Sdim // Returns -1 if this isn't a function of if the function doesn't have a 242314564Sdim // prototype 243314564Sdim // Returns a value >= 0 if there is a prototype. 244314564Sdim virtual int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) = 0; 245314564Sdim 246314564Sdim virtual CompilerType 247314564Sdim GetFunctionArgumentTypeAtIndex(lldb::opaque_compiler_type_t type, 248314564Sdim size_t idx) = 0; 249314564Sdim 250314564Sdim virtual CompilerType 251314564Sdim GetFunctionReturnType(lldb::opaque_compiler_type_t type) = 0; 252314564Sdim 253314564Sdim virtual size_t GetNumMemberFunctions(lldb::opaque_compiler_type_t type) = 0; 254314564Sdim 255314564Sdim virtual TypeMemberFunctionImpl 256314564Sdim GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type, size_t idx) = 0; 257314564Sdim 258314564Sdim virtual CompilerType GetPointeeType(lldb::opaque_compiler_type_t type) = 0; 259314564Sdim 260314564Sdim virtual CompilerType GetPointerType(lldb::opaque_compiler_type_t type) = 0; 261314564Sdim 262314564Sdim virtual CompilerType 263314564Sdim GetLValueReferenceType(lldb::opaque_compiler_type_t type); 264314564Sdim 265314564Sdim virtual CompilerType 266314564Sdim GetRValueReferenceType(lldb::opaque_compiler_type_t type); 267314564Sdim 268314564Sdim virtual CompilerType AddConstModifier(lldb::opaque_compiler_type_t type); 269314564Sdim 270314564Sdim virtual CompilerType AddVolatileModifier(lldb::opaque_compiler_type_t type); 271314564Sdim 272314564Sdim virtual CompilerType AddRestrictModifier(lldb::opaque_compiler_type_t type); 273314564Sdim 274314564Sdim virtual CompilerType CreateTypedef(lldb::opaque_compiler_type_t type, 275314564Sdim const char *name, 276314564Sdim const CompilerDeclContext &decl_ctx); 277314564Sdim 278314564Sdim //---------------------------------------------------------------------- 279314564Sdim // Exploring the type 280314564Sdim //---------------------------------------------------------------------- 281314564Sdim 282314564Sdim virtual uint64_t GetBitSize(lldb::opaque_compiler_type_t type, 283314564Sdim ExecutionContextScope *exe_scope) = 0; 284314564Sdim 285314564Sdim virtual lldb::Encoding GetEncoding(lldb::opaque_compiler_type_t type, 286314564Sdim uint64_t &count) = 0; 287314564Sdim 288314564Sdim virtual lldb::Format GetFormat(lldb::opaque_compiler_type_t type) = 0; 289314564Sdim 290314564Sdim virtual uint32_t GetNumChildren(lldb::opaque_compiler_type_t type, 291314564Sdim bool omit_empty_base_classes) = 0; 292314564Sdim 293314564Sdim virtual CompilerType GetBuiltinTypeByName(const ConstString &name); 294314564Sdim 295314564Sdim virtual lldb::BasicType 296314564Sdim GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) = 0; 297314564Sdim 298314564Sdim virtual void ForEachEnumerator( 299314564Sdim lldb::opaque_compiler_type_t type, 300314564Sdim std::function<bool(const CompilerType &integer_type, 301314564Sdim const ConstString &name, 302314564Sdim const llvm::APSInt &value)> const &callback) {} 303314564Sdim 304314564Sdim virtual uint32_t GetNumFields(lldb::opaque_compiler_type_t type) = 0; 305314564Sdim 306314564Sdim virtual CompilerType GetFieldAtIndex(lldb::opaque_compiler_type_t type, 307314564Sdim size_t idx, std::string &name, 308314564Sdim uint64_t *bit_offset_ptr, 309314564Sdim uint32_t *bitfield_bit_size_ptr, 310314564Sdim bool *is_bitfield_ptr) = 0; 311314564Sdim 312314564Sdim virtual uint32_t 313314564Sdim GetNumDirectBaseClasses(lldb::opaque_compiler_type_t type) = 0; 314314564Sdim 315314564Sdim virtual uint32_t 316314564Sdim GetNumVirtualBaseClasses(lldb::opaque_compiler_type_t type) = 0; 317314564Sdim 318314564Sdim virtual CompilerType 319314564Sdim GetDirectBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx, 320314564Sdim uint32_t *bit_offset_ptr) = 0; 321314564Sdim 322314564Sdim virtual CompilerType 323314564Sdim GetVirtualBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx, 324314564Sdim uint32_t *bit_offset_ptr) = 0; 325314564Sdim 326314564Sdim virtual CompilerType GetChildCompilerTypeAtIndex( 327314564Sdim lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx, 328314564Sdim bool transparent_pointers, bool omit_empty_base_classes, 329314564Sdim bool ignore_array_bounds, std::string &child_name, 330314564Sdim uint32_t &child_byte_size, int32_t &child_byte_offset, 331314564Sdim uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset, 332314564Sdim bool &child_is_base_class, bool &child_is_deref_of_parent, 333314564Sdim ValueObject *valobj, uint64_t &language_flags) = 0; 334314564Sdim 335314564Sdim // Lookup a child given a name. This function will match base class names 336314564Sdim // and member member names in "clang_type" only, not descendants. 337314564Sdim virtual uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type, 338314564Sdim const char *name, 339314564Sdim bool omit_empty_base_classes) = 0; 340314564Sdim 341314564Sdim // Lookup a child member given a name. This function will match member names 342314564Sdim // only and will descend into "clang_type" children in search for the first 343314564Sdim // member in this class, or any base class that matches "name". 344314564Sdim // TODO: Return all matches for a given name by returning a 345314564Sdim // vector<vector<uint32_t>> 346314564Sdim // so we catch all names that match a given child name, not just the first. 347314564Sdim virtual size_t 348314564Sdim GetIndexOfChildMemberWithName(lldb::opaque_compiler_type_t type, 349314564Sdim const char *name, bool omit_empty_base_classes, 350314564Sdim std::vector<uint32_t> &child_indexes) = 0; 351314564Sdim 352314564Sdim virtual size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type) = 0; 353314564Sdim 354314564Sdim virtual CompilerType 355314564Sdim GetTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx, 356314564Sdim lldb::TemplateArgumentKind &kind) = 0; 357314564Sdim 358314564Sdim //---------------------------------------------------------------------- 359314564Sdim // Dumping types 360314564Sdim //---------------------------------------------------------------------- 361314564Sdim 362314564Sdim virtual void DumpValue(lldb::opaque_compiler_type_t type, 363314564Sdim ExecutionContext *exe_ctx, Stream *s, 364314564Sdim lldb::Format format, const DataExtractor &data, 365314564Sdim lldb::offset_t data_offset, size_t data_byte_size, 366314564Sdim uint32_t bitfield_bit_size, 367314564Sdim uint32_t bitfield_bit_offset, bool show_types, 368314564Sdim bool show_summary, bool verbose, uint32_t depth) = 0; 369314564Sdim 370314564Sdim virtual bool DumpTypeValue(lldb::opaque_compiler_type_t type, Stream *s, 371314564Sdim lldb::Format format, const DataExtractor &data, 372314564Sdim lldb::offset_t data_offset, size_t data_byte_size, 373314564Sdim uint32_t bitfield_bit_size, 374314564Sdim uint32_t bitfield_bit_offset, 375314564Sdim ExecutionContextScope *exe_scope) = 0; 376314564Sdim 377314564Sdim virtual void 378314564Sdim DumpTypeDescription(lldb::opaque_compiler_type_t type) = 0; // Dump to stdout 379314564Sdim 380314564Sdim virtual void DumpTypeDescription(lldb::opaque_compiler_type_t type, 381314564Sdim Stream *s) = 0; 382314564Sdim 383314564Sdim //---------------------------------------------------------------------- 384314564Sdim // TODO: These methods appear unused. Should they be removed? 385314564Sdim //---------------------------------------------------------------------- 386314564Sdim 387314564Sdim virtual bool IsRuntimeGeneratedType(lldb::opaque_compiler_type_t type) = 0; 388314564Sdim 389314564Sdim virtual void DumpSummary(lldb::opaque_compiler_type_t type, 390314564Sdim ExecutionContext *exe_ctx, Stream *s, 391314564Sdim const DataExtractor &data, 392314564Sdim lldb::offset_t data_offset, 393314564Sdim size_t data_byte_size) = 0; 394314564Sdim 395314564Sdim // Converts "s" to a floating point value and place resulting floating 396314564Sdim // point bytes in the "dst" buffer. 397314564Sdim virtual size_t ConvertStringToFloatValue(lldb::opaque_compiler_type_t type, 398314564Sdim const char *s, uint8_t *dst, 399314564Sdim size_t dst_size) = 0; 400314564Sdim 401314564Sdim //---------------------------------------------------------------------- 402314564Sdim // TODO: Determine if these methods should move to ClangASTContext. 403314564Sdim //---------------------------------------------------------------------- 404314564Sdim 405314564Sdim virtual bool IsPointerOrReferenceType(lldb::opaque_compiler_type_t type, 406314564Sdim CompilerType *pointee_type) = 0; 407314564Sdim 408314564Sdim virtual unsigned GetTypeQualifiers(lldb::opaque_compiler_type_t type) = 0; 409314564Sdim 410314564Sdim virtual bool IsCStringType(lldb::opaque_compiler_type_t type, 411314564Sdim uint32_t &length) = 0; 412314564Sdim 413314564Sdim virtual size_t GetTypeBitAlign(lldb::opaque_compiler_type_t type) = 0; 414314564Sdim 415314564Sdim virtual CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) = 0; 416314564Sdim 417314564Sdim virtual CompilerType 418314564Sdim GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, 419314564Sdim size_t bit_size) = 0; 420314564Sdim 421314564Sdim virtual bool IsBeingDefined(lldb::opaque_compiler_type_t type) = 0; 422314564Sdim 423314564Sdim virtual bool IsConst(lldb::opaque_compiler_type_t type) = 0; 424314564Sdim 425314564Sdim virtual uint32_t IsHomogeneousAggregate(lldb::opaque_compiler_type_t type, 426314564Sdim CompilerType *base_type_ptr) = 0; 427314564Sdim 428314564Sdim virtual bool IsPolymorphicClass(lldb::opaque_compiler_type_t type) = 0; 429314564Sdim 430314564Sdim virtual bool IsTypedefType(lldb::opaque_compiler_type_t type) = 0; 431314564Sdim 432314564Sdim // If the current object represents a typedef type, get the underlying type 433314564Sdim virtual CompilerType GetTypedefedType(lldb::opaque_compiler_type_t type) = 0; 434314564Sdim 435314564Sdim virtual bool IsVectorType(lldb::opaque_compiler_type_t type, 436314564Sdim CompilerType *element_type, uint64_t *size) = 0; 437314564Sdim 438314564Sdim virtual CompilerType 439314564Sdim GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) = 0; 440314564Sdim 441314564Sdim virtual CompilerType 442314564Sdim GetNonReferenceType(lldb::opaque_compiler_type_t type) = 0; 443314564Sdim 444314564Sdim virtual bool IsReferenceType(lldb::opaque_compiler_type_t type, 445314564Sdim CompilerType *pointee_type, bool *is_rvalue) = 0; 446314564Sdim 447314564Sdim virtual bool 448314564Sdim ShouldTreatScalarValueAsAddress(lldb::opaque_compiler_type_t type) { 449314564Sdim return IsPointerOrReferenceType(type, nullptr); 450314564Sdim } 451314564Sdim 452314564Sdim virtual UserExpression * 453314564Sdim GetUserExpression(llvm::StringRef expr, llvm::StringRef prefix, 454314564Sdim lldb::LanguageType language, 455314564Sdim Expression::ResultType desired_type, 456314564Sdim const EvaluateExpressionOptions &options) { 457314564Sdim return nullptr; 458314564Sdim } 459314564Sdim 460314564Sdim virtual FunctionCaller *GetFunctionCaller(const CompilerType &return_type, 461314564Sdim const Address &function_address, 462314564Sdim const ValueList &arg_value_list, 463314564Sdim const char *name) { 464314564Sdim return nullptr; 465314564Sdim } 466314564Sdim 467314564Sdim virtual UtilityFunction *GetUtilityFunction(const char *text, 468314564Sdim const char *name) { 469314564Sdim return nullptr; 470314564Sdim } 471314564Sdim 472314564Sdim virtual PersistentExpressionState *GetPersistentExpressionState() { 473314564Sdim return nullptr; 474314564Sdim } 475314564Sdim 476314564Sdim virtual CompilerType GetTypeForFormatters(void *type); 477314564Sdim 478314564Sdim virtual LazyBool ShouldPrintAsOneLiner(void *type, ValueObject *valobj); 479314564Sdim 480314564Sdim // Type systems can have types that are placeholder types, which are meant to 481314564Sdim // indicate 482314564Sdim // the presence of a type, but offer no actual information about said types, 483314564Sdim // and leave 484314564Sdim // the burden of actually figuring type information out to dynamic type 485314564Sdim // resolution. For instance 486314564Sdim // a language with a generics system, can use placeholder types to indicate 487314564Sdim // "type argument goes here", 488314564Sdim // without promising uniqueness of the placeholder, nor attaching any actually 489314564Sdim // idenfiable information 490314564Sdim // to said placeholder. This API allows type systems to tell LLDB when such a 491314564Sdim // type has been encountered 492314564Sdim // In response, the debugger can react by not using this type as a cache entry 493314564Sdim // in any type-specific way 494314564Sdim // For instance, LLDB will currently not cache any formatters that are 495314564Sdim // discovered on such a type as 496314564Sdim // attributable to the meaningless type itself, instead preferring to use the 497314564Sdim // dynamic type 498314564Sdim virtual bool IsMeaninglessWithoutDynamicResolution(void *type); 499314564Sdim 500292932Sdimprotected: 501314564Sdim const LLVMCastKind m_kind; // Support for llvm casting 502314564Sdim SymbolFile *m_sym_file; 503292932Sdim}; 504292932Sdim 505314564Sdimclass TypeSystemMap { 506314564Sdimpublic: 507314564Sdim TypeSystemMap(); 508314564Sdim ~TypeSystemMap(); 509292932Sdim 510314564Sdim // Clear calls Finalize on all the TypeSystems managed by this map, and then 511314564Sdim // empties the map. 512314564Sdim void Clear(); 513292932Sdim 514314564Sdim // Iterate through all of the type systems that are created. Return true 515314564Sdim // from callback to keep iterating, false to stop iterating. 516314564Sdim void ForEach(std::function<bool(TypeSystem *)> const &callback); 517292932Sdim 518314564Sdim TypeSystem *GetTypeSystemForLanguage(lldb::LanguageType language, 519314564Sdim Module *module, bool can_create); 520292932Sdim 521314564Sdim TypeSystem *GetTypeSystemForLanguage(lldb::LanguageType language, 522314564Sdim Target *target, bool can_create); 523292932Sdim 524314564Sdimprotected: 525314564Sdim // This function does not take the map mutex, and should only be called from 526314564Sdim // functions that do take the mutex. 527314564Sdim void AddToMap(lldb::LanguageType language, 528314564Sdim lldb::TypeSystemSP const &type_system_sp); 529309124Sdim 530314564Sdim typedef std::map<lldb::LanguageType, lldb::TypeSystemSP> collection; 531314564Sdim mutable std::mutex m_mutex; ///< A mutex to keep this object happy in 532314564Sdim ///multi-threaded environments. 533314564Sdim collection m_map; 534314564Sdim bool m_clear_in_progress; 535314564Sdim}; 536292932Sdim 537292932Sdim} // namespace lldb_private 538292932Sdim 539292932Sdim#endif // liblldb_TypeSystem_h_ 540