1292932Sdim//===-- TypeSystem.h ------------------------------------------*- C++ -*-===//
2292932Sdim//
3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4353358Sdim// See https://llvm.org/LICENSE.txt for license information.
5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6292932Sdim//
7292932Sdim//===----------------------------------------------------------------------===//
8292932Sdim
9292932Sdim#ifndef liblldb_TypeSystem_h_
10292932Sdim#define liblldb_TypeSystem_h_
11292932Sdim
12292932Sdim#include <functional>
13292932Sdim#include <map>
14309124Sdim#include <mutex>
15292932Sdim#include <string>
16292932Sdim
17360784Sdim#include "llvm/ADT/APFloat.h"
18292932Sdim#include "llvm/ADT/APSInt.h"
19360784Sdim#include "llvm/ADT/SmallBitVector.h"
20292932Sdim#include "llvm/Support/Casting.h"
21360784Sdim#include "llvm/Support/Error.h"
22292932Sdim
23292932Sdim#include "lldb/Core/PluginInterface.h"
24292932Sdim#include "lldb/Expression/Expression.h"
25292932Sdim#include "lldb/Symbol/CompilerDecl.h"
26292932Sdim#include "lldb/Symbol/CompilerDeclContext.h"
27314564Sdim#include "lldb/lldb-private.h"
28292932Sdim
29292932Sdimclass DWARFDIE;
30292932Sdimclass DWARFASTParser;
31353358Sdimclass PDBASTParser;
32292932Sdim
33292932Sdimnamespace lldb_private {
34314564Sdim
35360784Sdim/// A SmallBitVector that represents a set of source languages (\p
36360784Sdim/// lldb::LanguageType).  Each lldb::LanguageType is represented by
37360784Sdim/// the bit with the position of its enumerator. The largest
38360784Sdim/// LanguageType is < 64, so this is space-efficient and on 64-bit
39360784Sdim/// architectures a LanguageSet can be completely stack-allocated.
40360784Sdimstruct LanguageSet {
41360784Sdim  llvm::SmallBitVector bitvector;
42360784Sdim  LanguageSet();
43360784Sdim
44360784Sdim  /// If the set contains a single language only, return it.
45360784Sdim  llvm::Optional<lldb::LanguageType> GetSingularLanguage();
46360784Sdim  void Insert(lldb::LanguageType language);
47360784Sdim  bool Empty() const;
48360784Sdim  size_t Size() const;
49360784Sdim  bool operator[](unsigned i) const;
50360784Sdim};
51360784Sdim
52360784Sdim/// Interface for representing a type system.
53360784Sdim///
54360784Sdim/// Implemented by language plugins to define the type system for a given
55360784Sdim/// language.
56360784Sdim///
57360784Sdim/// This interface extensively used opaque pointers to prevent that generic
58360784Sdim/// LLDB code has dependencies on language plugins. The type and semantics of
59360784Sdim/// these opaque pointers are defined by the TypeSystem implementation inside
60360784Sdim/// the respective language plugin. Opaque pointers from one TypeSystem
61360784Sdim/// instance should never be passed to a different TypeSystem instance (even
62360784Sdim/// when the language plugin for both TypeSystem instances is the same).
63360784Sdim///
64360784Sdim/// Most of the functions in this class should not be called directly but only
65360784Sdim/// called by their respective counterparts in CompilerType, CompilerDecl and
66360784Sdim/// CompilerDeclContext.
67360784Sdim///
68360784Sdim/// \see lldb_private::CompilerType
69360784Sdim/// \see lldb_private::CompilerDecl
70360784Sdim/// \see lldb_private::CompilerDeclContext
71314564Sdimclass TypeSystem : public PluginInterface {
72292932Sdimpublic:
73314564Sdim  // Constructors and Destructors
74314564Sdim  ~TypeSystem() override;
75292932Sdim
76360784Sdim  // LLVM RTTI support
77360784Sdim  virtual bool isA(const void *ClassID) const = 0;
78292932Sdim
79314564Sdim  static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language,
80314564Sdim                                           Module *module);
81292932Sdim
82314564Sdim  static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language,
83314564Sdim                                           Target *target);
84309124Sdim
85314564Sdim  // Free up any resources associated with this TypeSystem.  Done before
86341825Sdim  // removing all the TypeSystems from the TypeSystemMap.
87314564Sdim  virtual void Finalize() {}
88292932Sdim
89314564Sdim  virtual DWARFASTParser *GetDWARFParser() { return nullptr; }
90353358Sdim  virtual PDBASTParser *GetPDBParser() { return nullptr; }
91292932Sdim
92314564Sdim  virtual SymbolFile *GetSymbolFile() const { return m_sym_file; }
93292932Sdim
94314564Sdim  // Returns true if the symbol file changed during the set accessor.
95314564Sdim  virtual void SetSymbolFile(SymbolFile *sym_file) { m_sym_file = sym_file; }
96292932Sdim
97314564Sdim  // CompilerDecl functions
98314564Sdim  virtual ConstString DeclGetName(void *opaque_decl) = 0;
99292932Sdim
100314564Sdim  virtual ConstString DeclGetMangledName(void *opaque_decl);
101292932Sdim
102314564Sdim  virtual CompilerDeclContext DeclGetDeclContext(void *opaque_decl);
103292932Sdim
104314564Sdim  virtual CompilerType DeclGetFunctionReturnType(void *opaque_decl);
105292932Sdim
106314564Sdim  virtual size_t DeclGetFunctionNumArguments(void *opaque_decl);
107292932Sdim
108314564Sdim  virtual CompilerType DeclGetFunctionArgumentType(void *opaque_decl,
109314564Sdim                                                   size_t arg_idx);
110292932Sdim
111360784Sdim  virtual CompilerType GetTypeForDecl(void *opaque_decl) = 0;
112360784Sdim
113314564Sdim  // CompilerDeclContext functions
114292932Sdim
115314564Sdim  virtual std::vector<CompilerDecl>
116314564Sdim  DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name,
117314564Sdim                            const bool ignore_imported_decls);
118292932Sdim
119314564Sdim  virtual ConstString DeclContextGetName(void *opaque_decl_ctx) = 0;
120292932Sdim
121314564Sdim  virtual ConstString
122314564Sdim  DeclContextGetScopeQualifiedName(void *opaque_decl_ctx) = 0;
123292932Sdim
124314564Sdim  virtual bool DeclContextIsClassMethod(
125314564Sdim      void *opaque_decl_ctx, lldb::LanguageType *language_ptr,
126314564Sdim      bool *is_instance_method_ptr, ConstString *language_object_name_ptr) = 0;
127292932Sdim
128353358Sdim  virtual bool DeclContextIsContainedInLookup(void *opaque_decl_ctx,
129353358Sdim                                              void *other_opaque_decl_ctx) = 0;
130353358Sdim
131314564Sdim  // Tests
132309124Sdim
133314564Sdim  virtual bool IsArrayType(lldb::opaque_compiler_type_t type,
134314564Sdim                           CompilerType *element_type, uint64_t *size,
135314564Sdim                           bool *is_incomplete) = 0;
136309124Sdim
137314564Sdim  virtual bool IsAggregateType(lldb::opaque_compiler_type_t type) = 0;
138292932Sdim
139314564Sdim  virtual bool IsAnonymousType(lldb::opaque_compiler_type_t type);
140292932Sdim
141314564Sdim  virtual bool IsCharType(lldb::opaque_compiler_type_t type) = 0;
142292932Sdim
143314564Sdim  virtual bool IsCompleteType(lldb::opaque_compiler_type_t type) = 0;
144292932Sdim
145314564Sdim  virtual bool IsDefined(lldb::opaque_compiler_type_t type) = 0;
146292932Sdim
147314564Sdim  virtual bool IsFloatingPointType(lldb::opaque_compiler_type_t type,
148314564Sdim                                   uint32_t &count, bool &is_complex) = 0;
149292932Sdim
150314564Sdim  virtual bool IsFunctionType(lldb::opaque_compiler_type_t type,
151314564Sdim                              bool *is_variadic_ptr) = 0;
152292932Sdim
153314564Sdim  virtual size_t
154314564Sdim  GetNumberOfFunctionArguments(lldb::opaque_compiler_type_t type) = 0;
155292932Sdim
156314564Sdim  virtual CompilerType
157314564Sdim  GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type,
158314564Sdim                             const size_t index) = 0;
159292932Sdim
160314564Sdim  virtual bool IsFunctionPointerType(lldb::opaque_compiler_type_t type) = 0;
161292932Sdim
162314564Sdim  virtual bool IsBlockPointerType(lldb::opaque_compiler_type_t type,
163314564Sdim                                  CompilerType *function_pointer_type_ptr) = 0;
164292932Sdim
165314564Sdim  virtual bool IsIntegerType(lldb::opaque_compiler_type_t type,
166314564Sdim                             bool &is_signed) = 0;
167292932Sdim
168314564Sdim  virtual bool IsEnumerationType(lldb::opaque_compiler_type_t type,
169314564Sdim                                 bool &is_signed) {
170314564Sdim    is_signed = false;
171314564Sdim    return false;
172314564Sdim  }
173292932Sdim
174314564Sdim  virtual bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
175314564Sdim                                     CompilerType *target_type, // Can pass NULL
176314564Sdim                                     bool check_cplusplus, bool check_objc) = 0;
177292932Sdim
178314564Sdim  virtual bool IsPointerType(lldb::opaque_compiler_type_t type,
179314564Sdim                             CompilerType *pointee_type) = 0;
180292932Sdim
181314564Sdim  virtual bool IsScalarType(lldb::opaque_compiler_type_t type) = 0;
182292932Sdim
183314564Sdim  virtual bool IsVoidType(lldb::opaque_compiler_type_t type) = 0;
184292932Sdim
185353358Sdim  virtual bool CanPassInRegisters(const CompilerType &type) = 0;
186353358Sdim
187314564Sdim  // TypeSystems can support more than one language
188314564Sdim  virtual bool SupportsLanguage(lldb::LanguageType language) = 0;
189292932Sdim
190314564Sdim  // Type Completion
191292932Sdim
192314564Sdim  virtual bool GetCompleteType(lldb::opaque_compiler_type_t type) = 0;
193292932Sdim
194314564Sdim  // AST related queries
195292932Sdim
196314564Sdim  virtual uint32_t GetPointerByteSize() = 0;
197292932Sdim
198314564Sdim  // Accessors
199292932Sdim
200314564Sdim  virtual ConstString GetTypeName(lldb::opaque_compiler_type_t type) = 0;
201292932Sdim
202314564Sdim  virtual uint32_t
203314564Sdim  GetTypeInfo(lldb::opaque_compiler_type_t type,
204314564Sdim              CompilerType *pointee_or_element_compiler_type) = 0;
205292932Sdim
206314564Sdim  virtual lldb::LanguageType
207314564Sdim  GetMinimumLanguage(lldb::opaque_compiler_type_t type) = 0;
208314564Sdim
209314564Sdim  virtual lldb::TypeClass GetTypeClass(lldb::opaque_compiler_type_t type) = 0;
210314564Sdim
211314564Sdim  // Creating related types
212314564Sdim
213314564Sdim  virtual CompilerType GetArrayElementType(lldb::opaque_compiler_type_t type,
214314564Sdim                                           uint64_t *stride) = 0;
215314564Sdim
216314564Sdim  virtual CompilerType GetArrayType(lldb::opaque_compiler_type_t type,
217314564Sdim                                    uint64_t size);
218314564Sdim
219314564Sdim  virtual CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) = 0;
220314564Sdim
221314564Sdim  // Returns -1 if this isn't a function of if the function doesn't have a
222341825Sdim  // prototype Returns a value >= 0 if there is a prototype.
223314564Sdim  virtual int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) = 0;
224314564Sdim
225314564Sdim  virtual CompilerType
226314564Sdim  GetFunctionArgumentTypeAtIndex(lldb::opaque_compiler_type_t type,
227314564Sdim                                 size_t idx) = 0;
228314564Sdim
229314564Sdim  virtual CompilerType
230314564Sdim  GetFunctionReturnType(lldb::opaque_compiler_type_t type) = 0;
231314564Sdim
232314564Sdim  virtual size_t GetNumMemberFunctions(lldb::opaque_compiler_type_t type) = 0;
233314564Sdim
234314564Sdim  virtual TypeMemberFunctionImpl
235314564Sdim  GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type, size_t idx) = 0;
236314564Sdim
237314564Sdim  virtual CompilerType GetPointeeType(lldb::opaque_compiler_type_t type) = 0;
238314564Sdim
239314564Sdim  virtual CompilerType GetPointerType(lldb::opaque_compiler_type_t type) = 0;
240314564Sdim
241314564Sdim  virtual CompilerType
242314564Sdim  GetLValueReferenceType(lldb::opaque_compiler_type_t type);
243314564Sdim
244314564Sdim  virtual CompilerType
245314564Sdim  GetRValueReferenceType(lldb::opaque_compiler_type_t type);
246314564Sdim
247360784Sdim  virtual CompilerType GetAtomicType(lldb::opaque_compiler_type_t type);
248360784Sdim
249314564Sdim  virtual CompilerType AddConstModifier(lldb::opaque_compiler_type_t type);
250314564Sdim
251314564Sdim  virtual CompilerType AddVolatileModifier(lldb::opaque_compiler_type_t type);
252314564Sdim
253314564Sdim  virtual CompilerType AddRestrictModifier(lldb::opaque_compiler_type_t type);
254314564Sdim
255314564Sdim  virtual CompilerType CreateTypedef(lldb::opaque_compiler_type_t type,
256314564Sdim                                     const char *name,
257314564Sdim                                     const CompilerDeclContext &decl_ctx);
258314564Sdim
259314564Sdim  // Exploring the type
260314564Sdim
261360784Sdim  virtual const llvm::fltSemantics &GetFloatTypeSemantics(size_t byte_size) = 0;
262360784Sdim
263353358Sdim  virtual llvm::Optional<uint64_t>
264353358Sdim  GetBitSize(lldb::opaque_compiler_type_t type,
265353358Sdim             ExecutionContextScope *exe_scope) = 0;
266314564Sdim
267314564Sdim  virtual lldb::Encoding GetEncoding(lldb::opaque_compiler_type_t type,
268314564Sdim                                     uint64_t &count) = 0;
269314564Sdim
270314564Sdim  virtual lldb::Format GetFormat(lldb::opaque_compiler_type_t type) = 0;
271314564Sdim
272314564Sdim  virtual uint32_t GetNumChildren(lldb::opaque_compiler_type_t type,
273344779Sdim                                  bool omit_empty_base_classes,
274344779Sdim                                  const ExecutionContext *exe_ctx) = 0;
275314564Sdim
276353358Sdim  virtual CompilerType GetBuiltinTypeByName(ConstString name);
277314564Sdim
278314564Sdim  virtual lldb::BasicType
279314564Sdim  GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) = 0;
280314564Sdim
281314564Sdim  virtual void ForEachEnumerator(
282314564Sdim      lldb::opaque_compiler_type_t type,
283314564Sdim      std::function<bool(const CompilerType &integer_type,
284353358Sdim                         ConstString name,
285314564Sdim                         const llvm::APSInt &value)> const &callback) {}
286314564Sdim
287314564Sdim  virtual uint32_t GetNumFields(lldb::opaque_compiler_type_t type) = 0;
288314564Sdim
289314564Sdim  virtual CompilerType GetFieldAtIndex(lldb::opaque_compiler_type_t type,
290314564Sdim                                       size_t idx, std::string &name,
291314564Sdim                                       uint64_t *bit_offset_ptr,
292314564Sdim                                       uint32_t *bitfield_bit_size_ptr,
293314564Sdim                                       bool *is_bitfield_ptr) = 0;
294314564Sdim
295314564Sdim  virtual uint32_t
296314564Sdim  GetNumDirectBaseClasses(lldb::opaque_compiler_type_t type) = 0;
297314564Sdim
298314564Sdim  virtual uint32_t
299314564Sdim  GetNumVirtualBaseClasses(lldb::opaque_compiler_type_t type) = 0;
300314564Sdim
301314564Sdim  virtual CompilerType
302314564Sdim  GetDirectBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx,
303314564Sdim                            uint32_t *bit_offset_ptr) = 0;
304314564Sdim
305314564Sdim  virtual CompilerType
306314564Sdim  GetVirtualBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx,
307314564Sdim                             uint32_t *bit_offset_ptr) = 0;
308314564Sdim
309314564Sdim  virtual CompilerType GetChildCompilerTypeAtIndex(
310314564Sdim      lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx,
311314564Sdim      bool transparent_pointers, bool omit_empty_base_classes,
312314564Sdim      bool ignore_array_bounds, std::string &child_name,
313314564Sdim      uint32_t &child_byte_size, int32_t &child_byte_offset,
314314564Sdim      uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
315314564Sdim      bool &child_is_base_class, bool &child_is_deref_of_parent,
316314564Sdim      ValueObject *valobj, uint64_t &language_flags) = 0;
317314564Sdim
318341825Sdim  // Lookup a child given a name. This function will match base class names and
319341825Sdim  // member member names in "clang_type" only, not descendants.
320314564Sdim  virtual uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
321314564Sdim                                           const char *name,
322314564Sdim                                           bool omit_empty_base_classes) = 0;
323314564Sdim
324314564Sdim  // Lookup a child member given a name. This function will match member names
325314564Sdim  // only and will descend into "clang_type" children in search for the first
326314564Sdim  // member in this class, or any base class that matches "name".
327314564Sdim  // TODO: Return all matches for a given name by returning a
328314564Sdim  // vector<vector<uint32_t>>
329314564Sdim  // so we catch all names that match a given child name, not just the first.
330314564Sdim  virtual size_t
331314564Sdim  GetIndexOfChildMemberWithName(lldb::opaque_compiler_type_t type,
332314564Sdim                                const char *name, bool omit_empty_base_classes,
333314564Sdim                                std::vector<uint32_t> &child_indexes) = 0;
334314564Sdim
335344779Sdim  virtual size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type);
336314564Sdim
337327952Sdim  virtual lldb::TemplateArgumentKind
338327952Sdim  GetTemplateArgumentKind(lldb::opaque_compiler_type_t type, size_t idx);
339327952Sdim  virtual CompilerType GetTypeTemplateArgument(lldb::opaque_compiler_type_t type,
340327952Sdim                                           size_t idx);
341327952Sdim  virtual llvm::Optional<CompilerType::IntegralTemplateArgument>
342327952Sdim  GetIntegralTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx);
343314564Sdim
344314564Sdim  // Dumping types
345314564Sdim
346353358Sdim#ifndef NDEBUG
347353358Sdim  /// Convenience LLVM-style dump method for use in the debugger only.
348353358Sdim  LLVM_DUMP_METHOD virtual void
349353358Sdim  dump(lldb::opaque_compiler_type_t type) const = 0;
350353358Sdim#endif
351353358Sdim
352314564Sdim  virtual void DumpValue(lldb::opaque_compiler_type_t type,
353314564Sdim                         ExecutionContext *exe_ctx, Stream *s,
354314564Sdim                         lldb::Format format, const DataExtractor &data,
355314564Sdim                         lldb::offset_t data_offset, size_t data_byte_size,
356314564Sdim                         uint32_t bitfield_bit_size,
357314564Sdim                         uint32_t bitfield_bit_offset, bool show_types,
358314564Sdim                         bool show_summary, bool verbose, uint32_t depth) = 0;
359314564Sdim
360314564Sdim  virtual bool DumpTypeValue(lldb::opaque_compiler_type_t type, Stream *s,
361314564Sdim                             lldb::Format format, const DataExtractor &data,
362314564Sdim                             lldb::offset_t data_offset, size_t data_byte_size,
363314564Sdim                             uint32_t bitfield_bit_size,
364314564Sdim                             uint32_t bitfield_bit_offset,
365314564Sdim                             ExecutionContextScope *exe_scope) = 0;
366314564Sdim
367314564Sdim  virtual void
368314564Sdim  DumpTypeDescription(lldb::opaque_compiler_type_t type) = 0; // Dump to stdout
369314564Sdim
370314564Sdim  virtual void DumpTypeDescription(lldb::opaque_compiler_type_t type,
371314564Sdim                                   Stream *s) = 0;
372314564Sdim
373314564Sdim  // TODO: These methods appear unused. Should they be removed?
374314564Sdim
375314564Sdim  virtual bool IsRuntimeGeneratedType(lldb::opaque_compiler_type_t type) = 0;
376314564Sdim
377314564Sdim  virtual void DumpSummary(lldb::opaque_compiler_type_t type,
378314564Sdim                           ExecutionContext *exe_ctx, Stream *s,
379314564Sdim                           const DataExtractor &data,
380314564Sdim                           lldb::offset_t data_offset,
381314564Sdim                           size_t data_byte_size) = 0;
382314564Sdim
383314564Sdim  // TODO: Determine if these methods should move to ClangASTContext.
384314564Sdim
385314564Sdim  virtual bool IsPointerOrReferenceType(lldb::opaque_compiler_type_t type,
386314564Sdim                                        CompilerType *pointee_type) = 0;
387314564Sdim
388314564Sdim  virtual unsigned GetTypeQualifiers(lldb::opaque_compiler_type_t type) = 0;
389314564Sdim
390314564Sdim  virtual bool IsCStringType(lldb::opaque_compiler_type_t type,
391314564Sdim                             uint32_t &length) = 0;
392314564Sdim
393360784Sdim  virtual llvm::Optional<size_t>
394360784Sdim  GetTypeBitAlign(lldb::opaque_compiler_type_t type,
395360784Sdim                  ExecutionContextScope *exe_scope) = 0;
396314564Sdim
397314564Sdim  virtual CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) = 0;
398314564Sdim
399314564Sdim  virtual CompilerType
400314564Sdim  GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding,
401314564Sdim                                      size_t bit_size) = 0;
402314564Sdim
403314564Sdim  virtual bool IsBeingDefined(lldb::opaque_compiler_type_t type) = 0;
404314564Sdim
405314564Sdim  virtual bool IsConst(lldb::opaque_compiler_type_t type) = 0;
406314564Sdim
407314564Sdim  virtual uint32_t IsHomogeneousAggregate(lldb::opaque_compiler_type_t type,
408314564Sdim                                          CompilerType *base_type_ptr) = 0;
409314564Sdim
410314564Sdim  virtual bool IsPolymorphicClass(lldb::opaque_compiler_type_t type) = 0;
411314564Sdim
412314564Sdim  virtual bool IsTypedefType(lldb::opaque_compiler_type_t type) = 0;
413314564Sdim
414314564Sdim  // If the current object represents a typedef type, get the underlying type
415314564Sdim  virtual CompilerType GetTypedefedType(lldb::opaque_compiler_type_t type) = 0;
416314564Sdim
417314564Sdim  virtual bool IsVectorType(lldb::opaque_compiler_type_t type,
418314564Sdim                            CompilerType *element_type, uint64_t *size) = 0;
419314564Sdim
420314564Sdim  virtual CompilerType
421314564Sdim  GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) = 0;
422314564Sdim
423314564Sdim  virtual CompilerType
424314564Sdim  GetNonReferenceType(lldb::opaque_compiler_type_t type) = 0;
425314564Sdim
426314564Sdim  virtual bool IsReferenceType(lldb::opaque_compiler_type_t type,
427314564Sdim                               CompilerType *pointee_type, bool *is_rvalue) = 0;
428314564Sdim
429314564Sdim  virtual bool
430314564Sdim  ShouldTreatScalarValueAsAddress(lldb::opaque_compiler_type_t type) {
431314564Sdim    return IsPointerOrReferenceType(type, nullptr);
432314564Sdim  }
433314564Sdim
434314564Sdim  virtual UserExpression *
435314564Sdim  GetUserExpression(llvm::StringRef expr, llvm::StringRef prefix,
436314564Sdim                    lldb::LanguageType language,
437314564Sdim                    Expression::ResultType desired_type,
438353358Sdim                    const EvaluateExpressionOptions &options,
439353358Sdim                    ValueObject *ctx_obj) {
440314564Sdim    return nullptr;
441314564Sdim  }
442314564Sdim
443314564Sdim  virtual FunctionCaller *GetFunctionCaller(const CompilerType &return_type,
444314564Sdim                                            const Address &function_address,
445314564Sdim                                            const ValueList &arg_value_list,
446314564Sdim                                            const char *name) {
447314564Sdim    return nullptr;
448314564Sdim  }
449314564Sdim
450314564Sdim  virtual UtilityFunction *GetUtilityFunction(const char *text,
451314564Sdim                                              const char *name) {
452314564Sdim    return nullptr;
453314564Sdim  }
454314564Sdim
455314564Sdim  virtual PersistentExpressionState *GetPersistentExpressionState() {
456314564Sdim    return nullptr;
457314564Sdim  }
458314564Sdim
459314564Sdim  virtual CompilerType GetTypeForFormatters(void *type);
460314564Sdim
461314564Sdim  virtual LazyBool ShouldPrintAsOneLiner(void *type, ValueObject *valobj);
462314564Sdim
463314564Sdim  // Type systems can have types that are placeholder types, which are meant to
464341825Sdim  // indicate the presence of a type, but offer no actual information about
465341825Sdim  // said types, and leave the burden of actually figuring type information out
466341825Sdim  // to dynamic type resolution. For instance a language with a generics
467341825Sdim  // system, can use placeholder types to indicate "type argument goes here",
468341825Sdim  // without promising uniqueness of the placeholder, nor attaching any
469341825Sdim  // actually idenfiable information to said placeholder. This API allows type
470341825Sdim  // systems to tell LLDB when such a type has been encountered In response,
471341825Sdim  // the debugger can react by not using this type as a cache entry in any
472341825Sdim  // type-specific way For instance, LLDB will currently not cache any
473341825Sdim  // formatters that are discovered on such a type as attributable to the
474341825Sdim  // meaningless type itself, instead preferring to use the dynamic type
475314564Sdim  virtual bool IsMeaninglessWithoutDynamicResolution(void *type);
476314564Sdim
477292932Sdimprotected:
478360784Sdim  SymbolFile *m_sym_file = nullptr;
479292932Sdim};
480292932Sdim
481314564Sdimclass TypeSystemMap {
482314564Sdimpublic:
483314564Sdim  TypeSystemMap();
484314564Sdim  ~TypeSystemMap();
485292932Sdim
486314564Sdim  // Clear calls Finalize on all the TypeSystems managed by this map, and then
487314564Sdim  // empties the map.
488314564Sdim  void Clear();
489292932Sdim
490341825Sdim  // Iterate through all of the type systems that are created. Return true from
491341825Sdim  // callback to keep iterating, false to stop iterating.
492314564Sdim  void ForEach(std::function<bool(TypeSystem *)> const &callback);
493292932Sdim
494360784Sdim  llvm::Expected<TypeSystem &>
495360784Sdim  GetTypeSystemForLanguage(lldb::LanguageType language, Module *module,
496360784Sdim                           bool can_create);
497292932Sdim
498360784Sdim  llvm::Expected<TypeSystem &>
499360784Sdim  GetTypeSystemForLanguage(lldb::LanguageType language, Target *target,
500360784Sdim                           bool can_create);
501292932Sdim
502314564Sdimprotected:
503314564Sdim  typedef std::map<lldb::LanguageType, lldb::TypeSystemSP> collection;
504314564Sdim  mutable std::mutex m_mutex; ///< A mutex to keep this object happy in
505314564Sdim                              ///multi-threaded environments.
506314564Sdim  collection m_map;
507314564Sdim  bool m_clear_in_progress;
508314564Sdim};
509292932Sdim
510292932Sdim} // namespace lldb_private
511292932Sdim
512292932Sdim#endif // liblldb_TypeSystem_h_
513