TypeSystem.h revision 360660
1163953Srrs//===-- TypeSystem.h ------------------------------------------*- C++ -*-===//
2169382Srrs//
3163953Srrs// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4163953Srrs// See https://llvm.org/LICENSE.txt for license information.
5163953Srrs// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6163953Srrs//
7163953Srrs//===----------------------------------------------------------------------===//
8163953Srrs
9163953Srrs#ifndef liblldb_TypeSystem_h_
10163953Srrs#define liblldb_TypeSystem_h_
11163953Srrs
12163953Srrs#include <functional>
13163953Srrs#include <map>
14163953Srrs#include <mutex>
15163953Srrs#include <string>
16163953Srrs
17163953Srrs#include "llvm/ADT/APSInt.h"
18163953Srrs#include "llvm/Support/Casting.h"
19163953Srrs
20163953Srrs#include "lldb/Core/PluginInterface.h"
21163953Srrs#include "lldb/Expression/Expression.h"
22163953Srrs#include "lldb/Symbol/CompilerDecl.h"
23163953Srrs#include "lldb/Symbol/CompilerDeclContext.h"
24163953Srrs#include "lldb/lldb-private.h"
25163953Srrs
26163953Srrsclass DWARFDIE;
27163953Srrsclass DWARFASTParser;
28163953Srrsclass PDBASTParser;
29163953Srrs
30163953Srrsnamespace lldb_private {
31163953Srrs
32163953Srrs// Interface for representing the Type Systems in different languages.
33163953Srrsclass TypeSystem : public PluginInterface {
34163953Srrspublic:
35163953Srrs  // Intrusive type system that allows us to use llvm casting.
36163953Srrs  //
37163953Srrs  // To add a new type system:
38167598Srrs  //
39163953Srrs  // 1 - Add a new enumeration for llvm casting below for your TypeSystem
40163953Srrs  //     subclass, here we will use eKindFoo
41163953Srrs  //
42163953Srrs  // 2 - Your TypeSystem subclass will inherit from TypeSystem and needs
43163953Srrs  //     to implement a static classof() function that returns your
44163953Srrs  //     enumeration:
45163953Srrs  //
46163953Srrs  //    class Foo : public lldb_private::TypeSystem
47170091Srrs  //    {
48172091Srrs  //        static bool classof(const TypeSystem *ts)
49163953Srrs  //        {
50163953Srrs  //            return ts->getKind() == TypeSystem::eKindFoo;
51163953Srrs  //        }
52163953Srrs  //    };
53163953Srrs  //
54163953Srrs  // 3 - Contruct your TypeSystem subclass with the enumeration from below
55163953Srrs  //
56163953Srrs  //    Foo() :
57165220Srrs  //        TypeSystem(TypeSystem::eKindFoo),
58165220Srrs  //        ...
59165220Srrs  //    {
60165220Srrs  //    }
61165220Srrs  //
62163953Srrs  // Then you can use the llvm casting on any "TypeSystem *" to get an instance
63163953Srrs  // of your subclass.
64165220Srrs  enum LLVMCastKind {
65163953Srrs    eKindClang,
66163953Srrs    eKindSwift,
67163953Srrs    eKindOCaml,
68165220Srrs    kNumKinds
69165220Srrs  };
70165220Srrs
71165220Srrs  // Constructors and Destructors
72165220Srrs  TypeSystem(LLVMCastKind kind);
73165220Srrs
74163953Srrs  ~TypeSystem() override;
75163953Srrs
76163953Srrs  LLVMCastKind getKind() const { return m_kind; }
77163953Srrs
78163953Srrs  static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language,
79163953Srrs                                           Module *module);
80163953Srrs
81163953Srrs  static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language,
82170181Srrs                                           Target *target);
83163953Srrs
84163953Srrs  // Free up any resources associated with this TypeSystem.  Done before
85163953Srrs  // removing all the TypeSystems from the TypeSystemMap.
86163953Srrs  virtual void Finalize() {}
87163953Srrs
88169420Srrs  virtual DWARFASTParser *GetDWARFParser() { return nullptr; }
89169420Srrs  virtual PDBASTParser *GetPDBParser() { return nullptr; }
90163953Srrs
91163953Srrs  virtual SymbolFile *GetSymbolFile() const { return m_sym_file; }
92163953Srrs
93163953Srrs  // Returns true if the symbol file changed during the set accessor.
94169420Srrs  virtual void SetSymbolFile(SymbolFile *sym_file) { m_sym_file = sym_file; }
95169420Srrs
96169420Srrs  // CompilerDecl functions
97163953Srrs  virtual ConstString DeclGetName(void *opaque_decl) = 0;
98163953Srrs
99163953Srrs  virtual ConstString DeclGetMangledName(void *opaque_decl);
100163953Srrs
101169352Srrs  virtual CompilerDeclContext DeclGetDeclContext(void *opaque_decl);
102170181Srrs
103168299Srrs  virtual CompilerType DeclGetFunctionReturnType(void *opaque_decl);
104168299Srrs
105163953Srrs  virtual size_t DeclGetFunctionNumArguments(void *opaque_decl);
106163953Srrs
107163953Srrs  virtual CompilerType DeclGetFunctionArgumentType(void *opaque_decl,
108163953Srrs                                                   size_t arg_idx);
109163953Srrs
110169352Srrs  // CompilerDeclContext functions
111170181Srrs
112168299Srrs  virtual std::vector<CompilerDecl>
113168299Srrs  DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name,
114163953Srrs                            const bool ignore_imported_decls);
115163953Srrs
116163953Srrs  virtual bool DeclContextIsStructUnionOrClass(void *opaque_decl_ctx) = 0;
117163953Srrs
118163953Srrs  virtual ConstString DeclContextGetName(void *opaque_decl_ctx) = 0;
119163953Srrs
120169352Srrs  virtual ConstString
121170181Srrs  DeclContextGetScopeQualifiedName(void *opaque_decl_ctx) = 0;
122168299Srrs
123168299Srrs  virtual bool DeclContextIsClassMethod(
124163953Srrs      void *opaque_decl_ctx, lldb::LanguageType *language_ptr,
125163953Srrs      bool *is_instance_method_ptr, ConstString *language_object_name_ptr) = 0;
126163953Srrs
127163953Srrs  virtual bool DeclContextIsContainedInLookup(void *opaque_decl_ctx,
128163953Srrs                                              void *other_opaque_decl_ctx) = 0;
129169352Srrs
130170181Srrs  // Tests
131171440Srrs
132171440Srrs  virtual bool IsArrayType(lldb::opaque_compiler_type_t type,
133163953Srrs                           CompilerType *element_type, uint64_t *size,
134163953Srrs                           bool *is_incomplete) = 0;
135163953Srrs
136163953Srrs  virtual bool IsAggregateType(lldb::opaque_compiler_type_t type) = 0;
137163953Srrs
138169352Srrs  virtual bool IsAnonymousType(lldb::opaque_compiler_type_t type);
139170181Srrs
140168299Srrs  virtual bool IsCharType(lldb::opaque_compiler_type_t type) = 0;
141168299Srrs
142163953Srrs  virtual bool IsCompleteType(lldb::opaque_compiler_type_t type) = 0;
143163953Srrs
144163953Srrs  virtual bool IsDefined(lldb::opaque_compiler_type_t type) = 0;
145163953Srrs
146163953Srrs  virtual bool IsFloatingPointType(lldb::opaque_compiler_type_t type,
147169352Srrs                                   uint32_t &count, bool &is_complex) = 0;
148170181Srrs
149168299Srrs  virtual bool IsFunctionType(lldb::opaque_compiler_type_t type,
150168299Srrs                              bool *is_variadic_ptr) = 0;
151163953Srrs
152163953Srrs  virtual size_t
153163953Srrs  GetNumberOfFunctionArguments(lldb::opaque_compiler_type_t type) = 0;
154163953Srrs
155163953Srrs  virtual CompilerType
156163953Srrs  GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type,
157170181Srrs                             const size_t index) = 0;
158168299Srrs
159168299Srrs  virtual bool IsFunctionPointerType(lldb::opaque_compiler_type_t type) = 0;
160163953Srrs
161163953Srrs  virtual bool IsBlockPointerType(lldb::opaque_compiler_type_t type,
162163953Srrs                                  CompilerType *function_pointer_type_ptr) = 0;
163169420Srrs
164170181Srrs  virtual bool IsIntegerType(lldb::opaque_compiler_type_t type,
165163953Srrs                             bool &is_signed) = 0;
166163953Srrs
167163953Srrs  virtual bool IsEnumerationType(lldb::opaque_compiler_type_t type,
168163953Srrs                                 bool &is_signed) {
169163953Srrs    is_signed = false;
170171158Srrs    return false;
171171158Srrs  }
172171158Srrs
173171158Srrs  virtual bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
174171158Srrs                                     CompilerType *target_type, // Can pass NULL
175171158Srrs                                     bool check_cplusplus, bool check_objc) = 0;
176171158Srrs
177171158Srrs  virtual bool IsPointerType(lldb::opaque_compiler_type_t type,
178171158Srrs                             CompilerType *pointee_type) = 0;
179171158Srrs
180171158Srrs  virtual bool IsScalarType(lldb::opaque_compiler_type_t type) = 0;
181171158Srrs
182171158Srrs  virtual bool IsVoidType(lldb::opaque_compiler_type_t type) = 0;
183171158Srrs
184171158Srrs  virtual bool CanPassInRegisters(const CompilerType &type) = 0;
185171158Srrs
186171158Srrs  // TypeSystems can support more than one language
187171158Srrs  virtual bool SupportsLanguage(lldb::LanguageType language) = 0;
188171158Srrs
189171158Srrs  // Type Completion
190171531Srrs
191171158Srrs  virtual bool GetCompleteType(lldb::opaque_compiler_type_t type) = 0;
192171158Srrs
193171158Srrs  // AST related queries
194171158Srrs
195171158Srrs  virtual uint32_t GetPointerByteSize() = 0;
196171158Srrs
197171158Srrs  // Accessors
198171158Srrs
199171158Srrs  virtual ConstString GetTypeName(lldb::opaque_compiler_type_t type) = 0;
200171158Srrs
201171158Srrs  virtual uint32_t
202171158Srrs  GetTypeInfo(lldb::opaque_compiler_type_t type,
203171158Srrs              CompilerType *pointee_or_element_compiler_type) = 0;
204171158Srrs
205171158Srrs  virtual lldb::LanguageType
206171158Srrs  GetMinimumLanguage(lldb::opaque_compiler_type_t type) = 0;
207171158Srrs
208171158Srrs  virtual lldb::TypeClass GetTypeClass(lldb::opaque_compiler_type_t type) = 0;
209171158Srrs
210171158Srrs  // Creating related types
211171158Srrs
212171158Srrs  virtual CompilerType GetArrayElementType(lldb::opaque_compiler_type_t type,
213171158Srrs                                           uint64_t *stride) = 0;
214171158Srrs
215171158Srrs  virtual CompilerType GetArrayType(lldb::opaque_compiler_type_t type,
216171158Srrs                                    uint64_t size);
217171158Srrs
218171158Srrs  virtual CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) = 0;
219171158Srrs
220171158Srrs  // Returns -1 if this isn't a function of if the function doesn't have a
221171158Srrs  // prototype Returns a value >= 0 if there is a prototype.
222171158Srrs  virtual int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) = 0;
223171158Srrs
224171158Srrs  virtual CompilerType
225171158Srrs  GetFunctionArgumentTypeAtIndex(lldb::opaque_compiler_type_t type,
226171158Srrs                                 size_t idx) = 0;
227171158Srrs
228171158Srrs  virtual CompilerType
229171158Srrs  GetFunctionReturnType(lldb::opaque_compiler_type_t type) = 0;
230171158Srrs
231163953Srrs  virtual size_t GetNumMemberFunctions(lldb::opaque_compiler_type_t type) = 0;
232163953Srrs
233163953Srrs  virtual TypeMemberFunctionImpl
234163953Srrs  GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type, size_t idx) = 0;
235163953Srrs
236163953Srrs  virtual CompilerType GetPointeeType(lldb::opaque_compiler_type_t type) = 0;
237163953Srrs
238163953Srrs  virtual CompilerType GetPointerType(lldb::opaque_compiler_type_t type) = 0;
239163953Srrs
240163953Srrs  virtual CompilerType
241163953Srrs  GetLValueReferenceType(lldb::opaque_compiler_type_t type);
242163953Srrs
243163953Srrs  virtual CompilerType
244163953Srrs  GetRValueReferenceType(lldb::opaque_compiler_type_t type);
245163953Srrs
246163953Srrs  virtual CompilerType AddConstModifier(lldb::opaque_compiler_type_t type);
247163953Srrs
248163953Srrs  virtual CompilerType AddVolatileModifier(lldb::opaque_compiler_type_t type);
249163953Srrs
250170744Srrs  virtual CompilerType AddRestrictModifier(lldb::opaque_compiler_type_t type);
251170744Srrs
252170744Srrs  virtual CompilerType CreateTypedef(lldb::opaque_compiler_type_t type,
253163953Srrs                                     const char *name,
254163953Srrs                                     const CompilerDeclContext &decl_ctx);
255164181Srrs
256163953Srrs  // Exploring the type
257163953Srrs
258163953Srrs  virtual llvm::Optional<uint64_t>
259163953Srrs  GetBitSize(lldb::opaque_compiler_type_t type,
260163953Srrs             ExecutionContextScope *exe_scope) = 0;
261163953Srrs
262163953Srrs  virtual lldb::Encoding GetEncoding(lldb::opaque_compiler_type_t type,
263163953Srrs                                     uint64_t &count) = 0;
264163953Srrs
265163953Srrs  virtual lldb::Format GetFormat(lldb::opaque_compiler_type_t type) = 0;
266163953Srrs
267163953Srrs  virtual uint32_t GetNumChildren(lldb::opaque_compiler_type_t type,
268163953Srrs                                  bool omit_empty_base_classes,
269163953Srrs                                  const ExecutionContext *exe_ctx) = 0;
270163953Srrs
271163953Srrs  virtual CompilerType GetBuiltinTypeByName(ConstString name);
272163953Srrs
273163953Srrs  virtual lldb::BasicType
274163953Srrs  GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) = 0;
275172090Srrs
276163953Srrs  virtual void ForEachEnumerator(
277163953Srrs      lldb::opaque_compiler_type_t type,
278163953Srrs      std::function<bool(const CompilerType &integer_type,
279163953Srrs                         ConstString name,
280163953Srrs                         const llvm::APSInt &value)> const &callback) {}
281163953Srrs
282163953Srrs  virtual uint32_t GetNumFields(lldb::opaque_compiler_type_t type) = 0;
283169420Srrs
284163979Sru  virtual CompilerType GetFieldAtIndex(lldb::opaque_compiler_type_t type,
285163953Srrs                                       size_t idx, std::string &name,
286163953Srrs                                       uint64_t *bit_offset_ptr,
287169655Srrs                                       uint32_t *bitfield_bit_size_ptr,
288163953Srrs                                       bool *is_bitfield_ptr) = 0;
289163953Srrs
290163953Srrs  virtual uint32_t
291163953Srrs  GetNumDirectBaseClasses(lldb::opaque_compiler_type_t type) = 0;
292163953Srrs
293163953Srrs  virtual uint32_t
294163953Srrs  GetNumVirtualBaseClasses(lldb::opaque_compiler_type_t type) = 0;
295164181Srrs
296163953Srrs  virtual CompilerType
297163953Srrs  GetDirectBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx,
298163953Srrs                            uint32_t *bit_offset_ptr) = 0;
299170744Srrs
300170744Srrs  virtual CompilerType
301170744Srrs  GetVirtualBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx,
302163953Srrs                             uint32_t *bit_offset_ptr) = 0;
303163953Srrs
304163953Srrs  virtual CompilerType GetChildCompilerTypeAtIndex(
305163953Srrs      lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx,
306163953Srrs      bool transparent_pointers, bool omit_empty_base_classes,
307163953Srrs      bool ignore_array_bounds, std::string &child_name,
308163953Srrs      uint32_t &child_byte_size, int32_t &child_byte_offset,
309163953Srrs      uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
310170091Srrs      bool &child_is_base_class, bool &child_is_deref_of_parent,
311163953Srrs      ValueObject *valobj, uint64_t &language_flags) = 0;
312163953Srrs
313164181Srrs  // Lookup a child given a name. This function will match base class names and
314164181Srrs  // member member names in "clang_type" only, not descendants.
315164181Srrs  virtual uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
316164181Srrs                                           const char *name,
317164181Srrs                                           bool omit_empty_base_classes) = 0;
318164181Srrs
319164181Srrs  // Lookup a child member given a name. This function will match member names
320171158Srrs  // only and will descend into "clang_type" children in search for the first
321164181Srrs  // member in this class, or any base class that matches "name".
322164181Srrs  // TODO: Return all matches for a given name by returning a
323164181Srrs  // vector<vector<uint32_t>>
324164181Srrs  // so we catch all names that match a given child name, not just the first.
325164181Srrs  virtual size_t
326164181Srrs  GetIndexOfChildMemberWithName(lldb::opaque_compiler_type_t type,
327170091Srrs                                const char *name, bool omit_empty_base_classes,
328163953Srrs                                std::vector<uint32_t> &child_indexes) = 0;
329164181Srrs
330164181Srrs  virtual size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type);
331164181Srrs
332164181Srrs  virtual lldb::TemplateArgumentKind
333163953Srrs  GetTemplateArgumentKind(lldb::opaque_compiler_type_t type, size_t idx);
334170091Srrs  virtual CompilerType GetTypeTemplateArgument(lldb::opaque_compiler_type_t type,
335163953Srrs                                           size_t idx);
336163953Srrs  virtual llvm::Optional<CompilerType::IntegralTemplateArgument>
337169420Srrs  GetIntegralTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx);
338163953Srrs
339163953Srrs  // Dumping types
340163953Srrs
341163953Srrs#ifndef NDEBUG
342163953Srrs  /// Convenience LLVM-style dump method for use in the debugger only.
343163953Srrs  LLVM_DUMP_METHOD virtual void
344163953Srrs  dump(lldb::opaque_compiler_type_t type) const = 0;
345163953Srrs#endif
346163953Srrs
347163953Srrs  virtual void DumpValue(lldb::opaque_compiler_type_t type,
348163953Srrs                         ExecutionContext *exe_ctx, Stream *s,
349168943Srrs                         lldb::Format format, const DataExtractor &data,
350163953Srrs                         lldb::offset_t data_offset, size_t data_byte_size,
351163953Srrs                         uint32_t bitfield_bit_size,
352163953Srrs                         uint32_t bitfield_bit_offset, bool show_types,
353163953Srrs                         bool show_summary, bool verbose, uint32_t depth) = 0;
354163953Srrs
355163953Srrs  virtual bool DumpTypeValue(lldb::opaque_compiler_type_t type, Stream *s,
356163953Srrs                             lldb::Format format, const DataExtractor &data,
357163953Srrs                             lldb::offset_t data_offset, size_t data_byte_size,
358163953Srrs                             uint32_t bitfield_bit_size,
359163953Srrs                             uint32_t bitfield_bit_offset,
360169655Srrs                             ExecutionContextScope *exe_scope) = 0;
361163953Srrs
362163953Srrs  virtual void
363163953Srrs  DumpTypeDescription(lldb::opaque_compiler_type_t type) = 0; // Dump to stdout
364163953Srrs
365163953Srrs  virtual void DumpTypeDescription(lldb::opaque_compiler_type_t type,
366163953Srrs                                   Stream *s) = 0;
367163953Srrs
368163953Srrs  // TODO: These methods appear unused. Should they be removed?
369163953Srrs
370170181Srrs  virtual bool IsRuntimeGeneratedType(lldb::opaque_compiler_type_t type) = 0;
371163953Srrs
372163953Srrs  virtual void DumpSummary(lldb::opaque_compiler_type_t type,
373163953Srrs                           ExecutionContext *exe_ctx, Stream *s,
374163953Srrs                           const DataExtractor &data,
375163953Srrs                           lldb::offset_t data_offset,
376163953Srrs                           size_t data_byte_size) = 0;
377163953Srrs
378163953Srrs  // Converts "s" to a floating point value and place resulting floating point
379163953Srrs  // bytes in the "dst" buffer.
380163953Srrs  virtual size_t ConvertStringToFloatValue(lldb::opaque_compiler_type_t type,
381163953Srrs                                           const char *s, uint8_t *dst,
382163953Srrs                                           size_t dst_size) = 0;
383163953Srrs
384163953Srrs  // TODO: Determine if these methods should move to ClangASTContext.
385163953Srrs
386172090Srrs  virtual bool IsPointerOrReferenceType(lldb::opaque_compiler_type_t type,
387170056Srrs                                        CompilerType *pointee_type) = 0;
388163953Srrs
389163953Srrs  virtual unsigned GetTypeQualifiers(lldb::opaque_compiler_type_t type) = 0;
390163953Srrs
391163953Srrs  virtual bool IsCStringType(lldb::opaque_compiler_type_t type,
392163953Srrs                             uint32_t &length) = 0;
393163953Srrs
394163953Srrs  virtual size_t GetTypeBitAlign(lldb::opaque_compiler_type_t type) = 0;
395163953Srrs
396163953Srrs  virtual CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) = 0;
397163953Srrs
398163953Srrs  virtual CompilerType
399163953Srrs  GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding,
400163953Srrs                                      size_t bit_size) = 0;
401163953Srrs
402169420Srrs  virtual bool IsBeingDefined(lldb::opaque_compiler_type_t type) = 0;
403169420Srrs
404169420Srrs  virtual bool IsConst(lldb::opaque_compiler_type_t type) = 0;
405163953Srrs
406170181Srrs  virtual uint32_t IsHomogeneousAggregate(lldb::opaque_compiler_type_t type,
407168299Srrs                                          CompilerType *base_type_ptr) = 0;
408163953Srrs
409163953Srrs  virtual bool IsPolymorphicClass(lldb::opaque_compiler_type_t type) = 0;
410171477Srrs
411171477Srrs  virtual bool IsTypedefType(lldb::opaque_compiler_type_t type) = 0;
412171477Srrs
413171477Srrs  // If the current object represents a typedef type, get the underlying type
414171477Srrs  virtual CompilerType GetTypedefedType(lldb::opaque_compiler_type_t type) = 0;
415171477Srrs
416171477Srrs  virtual bool IsVectorType(lldb::opaque_compiler_type_t type,
417171477Srrs                            CompilerType *element_type, uint64_t *size) = 0;
418171477Srrs
419171477Srrs  virtual CompilerType
420171477Srrs  GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) = 0;
421163953Srrs
422163953Srrs  virtual CompilerType
423163953Srrs  GetNonReferenceType(lldb::opaque_compiler_type_t type) = 0;
424163953Srrs
425163953Srrs  virtual bool IsReferenceType(lldb::opaque_compiler_type_t type,
426163953Srrs                               CompilerType *pointee_type, bool *is_rvalue) = 0;
427163953Srrs
428163953Srrs  virtual bool
429171943Srrs  ShouldTreatScalarValueAsAddress(lldb::opaque_compiler_type_t type) {
430171943Srrs    return IsPointerOrReferenceType(type, nullptr);
431171943Srrs  }
432171943Srrs
433171943Srrs  virtual UserExpression *
434171943Srrs  GetUserExpression(llvm::StringRef expr, llvm::StringRef prefix,
435171943Srrs                    lldb::LanguageType language,
436163953Srrs                    Expression::ResultType desired_type,
437163953Srrs                    const EvaluateExpressionOptions &options,
438163953Srrs                    ValueObject *ctx_obj) {
439163953Srrs    return nullptr;
440163953Srrs  }
441163953Srrs
442163953Srrs  virtual FunctionCaller *GetFunctionCaller(const CompilerType &return_type,
443163953Srrs                                            const Address &function_address,
444163953Srrs                                            const ValueList &arg_value_list,
445163953Srrs                                            const char *name) {
446165220Srrs    return nullptr;
447163953Srrs  }
448165220Srrs
449171477Srrs  virtual UtilityFunction *GetUtilityFunction(const char *text,
450165220Srrs                                              const char *name) {
451163953Srrs    return nullptr;
452163953Srrs  }
453163953Srrs
454163953Srrs  virtual PersistentExpressionState *GetPersistentExpressionState() {
455163953Srrs    return nullptr;
456163953Srrs  }
457163953Srrs
458163953Srrs  virtual CompilerType GetTypeForFormatters(void *type);
459163953Srrs
460163953Srrs  virtual LazyBool ShouldPrintAsOneLiner(void *type, ValueObject *valobj);
461163953Srrs
462163953Srrs  // Type systems can have types that are placeholder types, which are meant to
463163953Srrs  // indicate the presence of a type, but offer no actual information about
464163953Srrs  // said types, and leave the burden of actually figuring type information out
465163953Srrs  // to dynamic type resolution. For instance a language with a generics
466163953Srrs  // system, can use placeholder types to indicate "type argument goes here",
467163953Srrs  // without promising uniqueness of the placeholder, nor attaching any
468163953Srrs  // actually idenfiable information to said placeholder. This API allows type
469165647Srrs  // systems to tell LLDB when such a type has been encountered In response,
470163953Srrs  // the debugger can react by not using this type as a cache entry in any
471163953Srrs  // type-specific way For instance, LLDB will currently not cache any
472163953Srrs  // formatters that are discovered on such a type as attributable to the
473163953Srrs  // meaningless type itself, instead preferring to use the dynamic type
474163953Srrs  virtual bool IsMeaninglessWithoutDynamicResolution(void *type);
475163953Srrs
476163953Srrsprotected:
477163953Srrs  const LLVMCastKind m_kind; // Support for llvm casting
478163953Srrs  SymbolFile *m_sym_file;
479163953Srrs};
480163953Srrs
481170181Srrsclass TypeSystemMap {
482168299Srrspublic:
483163953Srrs  TypeSystemMap();
484163953Srrs  ~TypeSystemMap();
485163953Srrs
486163953Srrs  // Clear calls Finalize on all the TypeSystems managed by this map, and then
487163953Srrs  // empties the map.
488163953Srrs  void Clear();
489163953Srrs
490163953Srrs  // Iterate through all of the type systems that are created. Return true from
491163953Srrs  // callback to keep iterating, false to stop iterating.
492163953Srrs  void ForEach(std::function<bool(TypeSystem *)> const &callback);
493163953Srrs
494163953Srrs  TypeSystem *GetTypeSystemForLanguage(lldb::LanguageType language,
495163953Srrs                                       Module *module, bool can_create);
496163953Srrs
497163953Srrs  TypeSystem *GetTypeSystemForLanguage(lldb::LanguageType language,
498163953Srrs                                       Target *target, bool can_create);
499163953Srrs
500163953Srrsprotected:
501163953Srrs  // This function does not take the map mutex, and should only be called from
502163953Srrs  // functions that do take the mutex.
503163953Srrs  void AddToMap(lldb::LanguageType language,
504163953Srrs                lldb::TypeSystemSP const &type_system_sp);
505163953Srrs
506163953Srrs  typedef std::map<lldb::LanguageType, lldb::TypeSystemSP> collection;
507163953Srrs  mutable std::mutex m_mutex; ///< A mutex to keep this object happy in
508163953Srrs                              ///multi-threaded environments.
509163953Srrs  collection m_map;
510163953Srrs  bool m_clear_in_progress;
511163953Srrs};
512163953Srrs
513163953Srrs} // namespace lldb_private
514163953Srrs
515163953Srrs#endif // liblldb_TypeSystem_h_
516163953Srrs