Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:53

0001 //===-- TypeSystem.h ------------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_SYMBOL_TYPESYSTEM_H
0010 #define LLDB_SYMBOL_TYPESYSTEM_H
0011 
0012 #include <functional>
0013 #include <mutex>
0014 #include <optional>
0015 #include <string>
0016 
0017 #include "llvm/ADT/APFloat.h"
0018 #include "llvm/ADT/APSInt.h"
0019 #include "llvm/ADT/DenseMap.h"
0020 #include "llvm/ADT/SmallBitVector.h"
0021 #include "llvm/Support/Casting.h"
0022 #include "llvm/Support/Error.h"
0023 #include "llvm/Support/JSON.h"
0024 
0025 #include "lldb/Core/PluginInterface.h"
0026 #include "lldb/Expression/Expression.h"
0027 #include "lldb/Symbol/CompilerDecl.h"
0028 #include "lldb/Symbol/CompilerDeclContext.h"
0029 #include "lldb/Symbol/Type.h"
0030 #include "lldb/Utility/Scalar.h"
0031 #include "lldb/lldb-forward.h"
0032 #include "lldb/lldb-private.h"
0033 #include "lldb/lldb-types.h"
0034 
0035 class PDBASTParser;
0036 
0037 namespace lldb_private {
0038 
0039 namespace plugin {
0040 namespace dwarf {
0041 class DWARFDIE;
0042 class DWARFASTParser;
0043 } // namespace dwarf
0044 } // namespace plugin
0045 
0046 namespace npdb {
0047   class PdbAstBuilder;
0048 } // namespace npdb
0049 
0050 /// Interface for representing a type system.
0051 ///
0052 /// Implemented by language plugins to define the type system for a given
0053 /// language.
0054 ///
0055 /// This interface extensively used opaque pointers to prevent that generic
0056 /// LLDB code has dependencies on language plugins. The type and semantics of
0057 /// these opaque pointers are defined by the TypeSystem implementation inside
0058 /// the respective language plugin. Opaque pointers from one TypeSystem
0059 /// instance should never be passed to a different TypeSystem instance (even
0060 /// when the language plugin for both TypeSystem instances is the same).
0061 ///
0062 /// Most of the functions in this class should not be called directly but only
0063 /// called by their respective counterparts in CompilerType, CompilerDecl and
0064 /// CompilerDeclContext.
0065 ///
0066 /// \see lldb_private::CompilerType
0067 /// \see lldb_private::CompilerDecl
0068 /// \see lldb_private::CompilerDeclContext
0069 class TypeSystem : public PluginInterface,
0070                    public std::enable_shared_from_this<TypeSystem> {
0071 public:
0072   // Constructors and Destructors
0073   TypeSystem();
0074   ~TypeSystem() override;
0075 
0076   // LLVM RTTI support
0077   virtual bool isA(const void *ClassID) const = 0;
0078 
0079   static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language,
0080                                            Module *module);
0081 
0082   static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language,
0083                                            Target *target);
0084 
0085   /// Free up any resources associated with this TypeSystem.  Done before
0086   /// removing all the TypeSystems from the TypeSystemMap.
0087   virtual void Finalize() {}
0088 
0089   virtual plugin::dwarf::DWARFASTParser *GetDWARFParser() { return nullptr; }
0090 
0091   virtual PDBASTParser *GetPDBParser() { return nullptr; }
0092   virtual npdb::PdbAstBuilder *GetNativePDBParser() { return nullptr; }
0093 
0094   virtual SymbolFile *GetSymbolFile() const { return m_sym_file; }
0095 
0096   virtual void SetSymbolFile(SymbolFile *sym_file) { m_sym_file = sym_file; }
0097 
0098   // CompilerDecl functions
0099   virtual ConstString DeclGetName(void *opaque_decl) = 0;
0100 
0101   virtual ConstString DeclGetMangledName(void *opaque_decl);
0102 
0103   virtual CompilerDeclContext DeclGetDeclContext(void *opaque_decl);
0104 
0105   virtual CompilerType DeclGetFunctionReturnType(void *opaque_decl);
0106 
0107   virtual size_t DeclGetFunctionNumArguments(void *opaque_decl);
0108 
0109   virtual CompilerType DeclGetFunctionArgumentType(void *opaque_decl,
0110                                                    size_t arg_idx);
0111 
0112   virtual std::vector<lldb_private::CompilerContext>
0113   DeclGetCompilerContext(void *opaque_decl);
0114 
0115   virtual Scalar DeclGetConstantValue(void *opaque_decl) { return Scalar(); }
0116 
0117   virtual CompilerType GetTypeForDecl(void *opaque_decl) = 0;
0118 
0119   // CompilerDeclContext functions
0120 
0121   virtual std::vector<CompilerDecl>
0122   DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name,
0123                             const bool ignore_imported_decls);
0124 
0125   virtual ConstString DeclContextGetName(void *opaque_decl_ctx) = 0;
0126 
0127   virtual ConstString
0128   DeclContextGetScopeQualifiedName(void *opaque_decl_ctx) = 0;
0129 
0130   virtual bool DeclContextIsClassMethod(void *opaque_decl_ctx) = 0;
0131 
0132   virtual bool DeclContextIsContainedInLookup(void *opaque_decl_ctx,
0133                                               void *other_opaque_decl_ctx) = 0;
0134 
0135   virtual lldb::LanguageType DeclContextGetLanguage(void *opaque_decl_ctx) = 0;
0136 
0137   /// Returns the direct parent context of specified type
0138   virtual CompilerDeclContext
0139   GetCompilerDeclContextForType(const CompilerType &type);
0140 
0141   virtual std::vector<lldb_private::CompilerContext>
0142   DeclContextGetCompilerContext(void *opaque_decl_ctx);
0143 
0144   // Tests
0145 #ifndef NDEBUG
0146   /// Verify the integrity of the type to catch CompilerTypes that mix
0147   /// and match invalid TypeSystem/Opaque type pairs.
0148   virtual bool Verify(lldb::opaque_compiler_type_t type) = 0;
0149 #endif
0150 
0151   virtual bool IsArrayType(lldb::opaque_compiler_type_t type,
0152                            CompilerType *element_type, uint64_t *size,
0153                            bool *is_incomplete) = 0;
0154 
0155   virtual bool IsAggregateType(lldb::opaque_compiler_type_t type) = 0;
0156 
0157   virtual bool IsAnonymousType(lldb::opaque_compiler_type_t type);
0158 
0159   virtual bool IsCharType(lldb::opaque_compiler_type_t type) = 0;
0160 
0161   virtual bool IsCompleteType(lldb::opaque_compiler_type_t type) = 0;
0162 
0163   virtual bool IsDefined(lldb::opaque_compiler_type_t type) = 0;
0164 
0165   virtual bool IsFloatingPointType(lldb::opaque_compiler_type_t type,
0166                                    uint32_t &count, bool &is_complex) = 0;
0167 
0168   virtual bool IsFunctionType(lldb::opaque_compiler_type_t type) = 0;
0169 
0170   virtual size_t
0171   GetNumberOfFunctionArguments(lldb::opaque_compiler_type_t type) = 0;
0172 
0173   virtual CompilerType
0174   GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type,
0175                              const size_t index) = 0;
0176 
0177   virtual bool IsFunctionPointerType(lldb::opaque_compiler_type_t type) = 0;
0178 
0179   virtual bool
0180   IsMemberFunctionPointerType(lldb::opaque_compiler_type_t type) = 0;
0181 
0182   virtual bool IsBlockPointerType(lldb::opaque_compiler_type_t type,
0183                                   CompilerType *function_pointer_type_ptr) = 0;
0184 
0185   virtual bool IsIntegerType(lldb::opaque_compiler_type_t type,
0186                              bool &is_signed) = 0;
0187 
0188   virtual bool IsEnumerationType(lldb::opaque_compiler_type_t type,
0189                                  bool &is_signed) {
0190     is_signed = false;
0191     return false;
0192   }
0193 
0194   virtual bool IsScopedEnumerationType(lldb::opaque_compiler_type_t type) = 0;
0195 
0196   virtual bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
0197                                      CompilerType *target_type, // Can pass NULL
0198                                      bool check_cplusplus, bool check_objc) = 0;
0199 
0200   virtual bool IsPointerType(lldb::opaque_compiler_type_t type,
0201                              CompilerType *pointee_type) = 0;
0202 
0203   virtual bool IsScalarType(lldb::opaque_compiler_type_t type) = 0;
0204 
0205   virtual bool IsVoidType(lldb::opaque_compiler_type_t type) = 0;
0206 
0207   virtual bool CanPassInRegisters(const CompilerType &type) = 0;
0208 
0209   // TypeSystems can support more than one language
0210   virtual bool SupportsLanguage(lldb::LanguageType language) = 0;
0211 
0212   static bool SupportsLanguageStatic(lldb::LanguageType language);
0213   // Type Completion
0214 
0215   virtual bool GetCompleteType(lldb::opaque_compiler_type_t type) = 0;
0216 
0217   virtual bool IsForcefullyCompleted(lldb::opaque_compiler_type_t type) {
0218     return false;
0219   }
0220 
0221   // AST related queries
0222 
0223   virtual uint32_t GetPointerByteSize() = 0;
0224 
0225   virtual unsigned GetPtrAuthKey(lldb::opaque_compiler_type_t type) = 0;
0226 
0227   virtual unsigned
0228   GetPtrAuthDiscriminator(lldb::opaque_compiler_type_t type) = 0;
0229 
0230   virtual bool
0231   GetPtrAuthAddressDiversity(lldb::opaque_compiler_type_t type) = 0;
0232 
0233   // Accessors
0234 
0235   virtual ConstString GetTypeName(lldb::opaque_compiler_type_t type,
0236                                   bool BaseOnly) = 0;
0237 
0238   virtual ConstString GetDisplayTypeName(lldb::opaque_compiler_type_t type) = 0;
0239 
0240   /// Defaults to GetTypeName(type).  Override if your language desires
0241   /// specialized behavior.
0242   virtual ConstString GetMangledTypeName(lldb::opaque_compiler_type_t type);
0243 
0244   virtual uint32_t
0245   GetTypeInfo(lldb::opaque_compiler_type_t type,
0246               CompilerType *pointee_or_element_compiler_type) = 0;
0247 
0248   virtual lldb::LanguageType
0249   GetMinimumLanguage(lldb::opaque_compiler_type_t type) = 0;
0250 
0251   virtual lldb::TypeClass GetTypeClass(lldb::opaque_compiler_type_t type) = 0;
0252 
0253   // Creating related types
0254 
0255   virtual CompilerType
0256   GetArrayElementType(lldb::opaque_compiler_type_t type,
0257                       ExecutionContextScope *exe_scope) = 0;
0258 
0259   virtual CompilerType GetArrayType(lldb::opaque_compiler_type_t type,
0260                                     uint64_t size);
0261 
0262   virtual CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) = 0;
0263 
0264   virtual CompilerType
0265   GetEnumerationIntegerType(lldb::opaque_compiler_type_t type) = 0;
0266 
0267   // Returns -1 if this isn't a function of if the function doesn't have a
0268   // prototype Returns a value >= 0 if there is a prototype.
0269   virtual int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) = 0;
0270 
0271   virtual CompilerType
0272   GetFunctionArgumentTypeAtIndex(lldb::opaque_compiler_type_t type,
0273                                  size_t idx) = 0;
0274 
0275   virtual CompilerType
0276   GetFunctionReturnType(lldb::opaque_compiler_type_t type) = 0;
0277 
0278   virtual size_t GetNumMemberFunctions(lldb::opaque_compiler_type_t type) = 0;
0279 
0280   virtual TypeMemberFunctionImpl
0281   GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type, size_t idx) = 0;
0282 
0283   virtual CompilerType GetPointeeType(lldb::opaque_compiler_type_t type) = 0;
0284 
0285   virtual CompilerType GetPointerType(lldb::opaque_compiler_type_t type) = 0;
0286 
0287   virtual CompilerType
0288   GetLValueReferenceType(lldb::opaque_compiler_type_t type);
0289 
0290   virtual CompilerType
0291   GetRValueReferenceType(lldb::opaque_compiler_type_t type);
0292 
0293   virtual CompilerType GetAtomicType(lldb::opaque_compiler_type_t type);
0294 
0295   virtual CompilerType AddConstModifier(lldb::opaque_compiler_type_t type);
0296 
0297   virtual CompilerType AddVolatileModifier(lldb::opaque_compiler_type_t type);
0298 
0299   virtual CompilerType AddRestrictModifier(lldb::opaque_compiler_type_t type);
0300 
0301   virtual CompilerType AddPtrAuthModifier(lldb::opaque_compiler_type_t type,
0302                                           uint32_t payload);
0303 
0304   /// \param opaque_payload      The m_payload field of Type, which may
0305   /// carry TypeSystem-specific extra information.
0306   virtual CompilerType CreateTypedef(lldb::opaque_compiler_type_t type,
0307                                      const char *name,
0308                                      const CompilerDeclContext &decl_ctx,
0309                                      uint32_t opaque_payload);
0310 
0311   // Exploring the type
0312 
0313   virtual const llvm::fltSemantics &GetFloatTypeSemantics(size_t byte_size) = 0;
0314 
0315   virtual std::optional<uint64_t>
0316   GetBitSize(lldb::opaque_compiler_type_t type,
0317              ExecutionContextScope *exe_scope) = 0;
0318 
0319   virtual lldb::Encoding GetEncoding(lldb::opaque_compiler_type_t type,
0320                                      uint64_t &count) = 0;
0321 
0322   virtual lldb::Format GetFormat(lldb::opaque_compiler_type_t type) = 0;
0323 
0324   virtual llvm::Expected<uint32_t>
0325   GetNumChildren(lldb::opaque_compiler_type_t type,
0326                  bool omit_empty_base_classes,
0327                  const ExecutionContext *exe_ctx) = 0;
0328 
0329   virtual CompilerType GetBuiltinTypeByName(ConstString name);
0330 
0331   virtual lldb::BasicType
0332   GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) = 0;
0333 
0334   virtual void ForEachEnumerator(
0335       lldb::opaque_compiler_type_t type,
0336       std::function<bool(const CompilerType &integer_type,
0337                          ConstString name,
0338                          const llvm::APSInt &value)> const &callback) {}
0339 
0340   virtual uint32_t GetNumFields(lldb::opaque_compiler_type_t type) = 0;
0341 
0342   virtual CompilerType GetFieldAtIndex(lldb::opaque_compiler_type_t type,
0343                                        size_t idx, std::string &name,
0344                                        uint64_t *bit_offset_ptr,
0345                                        uint32_t *bitfield_bit_size_ptr,
0346                                        bool *is_bitfield_ptr) = 0;
0347 
0348   virtual uint32_t
0349   GetNumDirectBaseClasses(lldb::opaque_compiler_type_t type) = 0;
0350 
0351   virtual uint32_t
0352   GetNumVirtualBaseClasses(lldb::opaque_compiler_type_t type) = 0;
0353 
0354   virtual CompilerType
0355   GetDirectBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx,
0356                             uint32_t *bit_offset_ptr) = 0;
0357 
0358   virtual CompilerType
0359   GetVirtualBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx,
0360                              uint32_t *bit_offset_ptr) = 0;
0361 
0362   virtual CompilerDecl GetStaticFieldWithName(lldb::opaque_compiler_type_t type,
0363                                               llvm::StringRef name) {
0364     return CompilerDecl();
0365   }
0366 
0367   virtual llvm::Expected<CompilerType> GetChildCompilerTypeAtIndex(
0368       lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx,
0369       bool transparent_pointers, bool omit_empty_base_classes,
0370       bool ignore_array_bounds, std::string &child_name,
0371       uint32_t &child_byte_size, int32_t &child_byte_offset,
0372       uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
0373       bool &child_is_base_class, bool &child_is_deref_of_parent,
0374       ValueObject *valobj, uint64_t &language_flags) = 0;
0375 
0376   // Lookup a child given a name. This function will match base class names and
0377   // member member names in "clang_type" only, not descendants.
0378   virtual uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
0379                                            llvm::StringRef name,
0380                                            bool omit_empty_base_classes) = 0;
0381 
0382   // Lookup a child member given a name. This function will match member names
0383   // only and will descend into "clang_type" children in search for the first
0384   // member in this class, or any base class that matches "name".
0385   // TODO: Return all matches for a given name by returning a
0386   // vector<vector<uint32_t>>
0387   // so we catch all names that match a given child name, not just the first.
0388   virtual size_t GetIndexOfChildMemberWithName(
0389       lldb::opaque_compiler_type_t type, llvm::StringRef name,
0390       bool omit_empty_base_classes, std::vector<uint32_t> &child_indexes) = 0;
0391 
0392   virtual CompilerType
0393   GetDirectNestedTypeWithName(lldb::opaque_compiler_type_t type,
0394                               llvm::StringRef name) {
0395     return CompilerType();
0396   }
0397 
0398   virtual bool IsTemplateType(lldb::opaque_compiler_type_t type);
0399 
0400   virtual size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type,
0401                                          bool expand_pack);
0402 
0403   virtual lldb::TemplateArgumentKind
0404   GetTemplateArgumentKind(lldb::opaque_compiler_type_t type, size_t idx,
0405                           bool expand_pack);
0406   virtual CompilerType
0407   GetTypeTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx,
0408                           bool expand_pack);
0409   virtual std::optional<CompilerType::IntegralTemplateArgument>
0410   GetIntegralTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx,
0411                               bool expand_pack);
0412 
0413   // Dumping types
0414 
0415 #ifndef NDEBUG
0416   /// Convenience LLVM-style dump method for use in the debugger only.
0417   LLVM_DUMP_METHOD virtual void
0418   dump(lldb::opaque_compiler_type_t type) const = 0;
0419 #endif
0420 
0421   virtual bool DumpTypeValue(lldb::opaque_compiler_type_t type, Stream &s,
0422                              lldb::Format format, const DataExtractor &data,
0423                              lldb::offset_t data_offset, size_t data_byte_size,
0424                              uint32_t bitfield_bit_size,
0425                              uint32_t bitfield_bit_offset,
0426                              ExecutionContextScope *exe_scope) = 0;
0427 
0428   /// Dump the type to stdout.
0429   virtual void DumpTypeDescription(
0430       lldb::opaque_compiler_type_t type,
0431       lldb::DescriptionLevel level = lldb::eDescriptionLevelFull) = 0;
0432 
0433   /// Print a description of the type to a stream. The exact implementation
0434   /// varies, but the expectation is that eDescriptionLevelFull returns a
0435   /// source-like representation of the type, whereas eDescriptionLevelVerbose
0436   /// does a dump of the underlying AST if applicable.
0437   virtual void DumpTypeDescription(
0438       lldb::opaque_compiler_type_t type, Stream &s,
0439       lldb::DescriptionLevel level = lldb::eDescriptionLevelFull) = 0;
0440 
0441   /// Dump a textual representation of the internal TypeSystem state to the
0442   /// given stream.
0443   ///
0444   /// This should not modify the state of the TypeSystem if possible.
0445   virtual void Dump(llvm::raw_ostream &output) = 0;
0446 
0447   /// This is used by swift.
0448   virtual bool IsRuntimeGeneratedType(lldb::opaque_compiler_type_t type) = 0;
0449 
0450   // TODO: Determine if these methods should move to TypeSystemClang.
0451 
0452   virtual bool IsPointerOrReferenceType(lldb::opaque_compiler_type_t type,
0453                                         CompilerType *pointee_type) = 0;
0454 
0455   virtual unsigned GetTypeQualifiers(lldb::opaque_compiler_type_t type) = 0;
0456 
0457   virtual std::optional<size_t>
0458   GetTypeBitAlign(lldb::opaque_compiler_type_t type,
0459                   ExecutionContextScope *exe_scope) = 0;
0460 
0461   virtual CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) = 0;
0462 
0463   virtual CompilerType CreateGenericFunctionPrototype() {
0464     return CompilerType();
0465   }
0466 
0467   virtual CompilerType
0468   GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding,
0469                                       size_t bit_size) = 0;
0470 
0471   virtual bool IsBeingDefined(lldb::opaque_compiler_type_t type) = 0;
0472 
0473   virtual bool IsConst(lldb::opaque_compiler_type_t type) = 0;
0474 
0475   virtual uint32_t IsHomogeneousAggregate(lldb::opaque_compiler_type_t type,
0476                                           CompilerType *base_type_ptr) = 0;
0477 
0478   virtual bool IsPolymorphicClass(lldb::opaque_compiler_type_t type) = 0;
0479 
0480   virtual bool IsTypedefType(lldb::opaque_compiler_type_t type) = 0;
0481 
0482   // If the current object represents a typedef type, get the underlying type
0483   virtual CompilerType GetTypedefedType(lldb::opaque_compiler_type_t type) = 0;
0484 
0485   virtual bool IsVectorType(lldb::opaque_compiler_type_t type,
0486                             CompilerType *element_type, uint64_t *size) = 0;
0487 
0488   virtual CompilerType
0489   GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) = 0;
0490 
0491   virtual CompilerType
0492   GetNonReferenceType(lldb::opaque_compiler_type_t type) = 0;
0493 
0494   virtual bool IsReferenceType(lldb::opaque_compiler_type_t type,
0495                                CompilerType *pointee_type, bool *is_rvalue) = 0;
0496 
0497   virtual bool
0498   ShouldTreatScalarValueAsAddress(lldb::opaque_compiler_type_t type) {
0499     return IsPointerOrReferenceType(type, nullptr);
0500   }
0501 
0502   virtual UserExpression *GetUserExpression(
0503       llvm::StringRef expr, llvm::StringRef prefix, SourceLanguage language,
0504       Expression::ResultType desired_type,
0505       const EvaluateExpressionOptions &options, ValueObject *ctx_obj) {
0506     return nullptr;
0507   }
0508 
0509   virtual FunctionCaller *GetFunctionCaller(const CompilerType &return_type,
0510                                             const Address &function_address,
0511                                             const ValueList &arg_value_list,
0512                                             const char *name) {
0513     return nullptr;
0514   }
0515 
0516   virtual std::unique_ptr<UtilityFunction>
0517   CreateUtilityFunction(std::string text, std::string name);
0518 
0519   virtual PersistentExpressionState *GetPersistentExpressionState() {
0520     return nullptr;
0521   }
0522 
0523   virtual CompilerType GetTypeForFormatters(void *type);
0524 
0525   virtual LazyBool ShouldPrintAsOneLiner(void *type, ValueObject *valobj);
0526 
0527   // Type systems can have types that are placeholder types, which are meant to
0528   // indicate the presence of a type, but offer no actual information about
0529   // said types, and leave the burden of actually figuring type information out
0530   // to dynamic type resolution. For instance a language with a generics
0531   // system, can use placeholder types to indicate "type argument goes here",
0532   // without promising uniqueness of the placeholder, nor attaching any
0533   // actually idenfiable information to said placeholder. This API allows type
0534   // systems to tell LLDB when such a type has been encountered In response,
0535   // the debugger can react by not using this type as a cache entry in any
0536   // type-specific way For instance, LLDB will currently not cache any
0537   // formatters that are discovered on such a type as attributable to the
0538   // meaningless type itself, instead preferring to use the dynamic type
0539   virtual bool IsMeaninglessWithoutDynamicResolution(void *type);
0540 
0541   virtual std::optional<llvm::json::Value> ReportStatistics();
0542 
0543   bool GetHasForcefullyCompletedTypes() const {
0544     return m_has_forcefully_completed_types;
0545   }
0546 protected:
0547   SymbolFile *m_sym_file = nullptr;
0548   /// Used for reporting statistics.
0549   bool m_has_forcefully_completed_types = false;
0550 };
0551 
0552 class TypeSystemMap {
0553 public:
0554   TypeSystemMap();
0555   ~TypeSystemMap();
0556 
0557   // Clear calls Finalize on all the TypeSystems managed by this map, and then
0558   // empties the map.
0559   void Clear();
0560 
0561   // Iterate through all of the type systems that are created. Return true from
0562   // callback to keep iterating, false to stop iterating.
0563   void ForEach(std::function<bool(lldb::TypeSystemSP)> const &callback);
0564 
0565   llvm::Expected<lldb::TypeSystemSP>
0566   GetTypeSystemForLanguage(lldb::LanguageType language, Module *module,
0567                            bool can_create);
0568 
0569   llvm::Expected<lldb::TypeSystemSP>
0570   GetTypeSystemForLanguage(lldb::LanguageType language, Target *target,
0571                            bool can_create);
0572 
0573   /// Check all type systems in the map to see if any have forcefully completed
0574   /// types;
0575   bool GetHasForcefullyCompletedTypes() const;
0576 protected:
0577   typedef llvm::DenseMap<uint16_t, lldb::TypeSystemSP> collection;
0578   mutable std::mutex m_mutex; ///< A mutex to keep this object happy in
0579                               /// multi-threaded environments.
0580   collection m_map;
0581   bool m_clear_in_progress = false;
0582 
0583 private:
0584   typedef llvm::function_ref<lldb::TypeSystemSP()> CreateCallback;
0585   /// Finds the type system for the given language. If no type system could be
0586   /// found for a language and a CreateCallback was provided, the value
0587   /// returned by the callback will be treated as the TypeSystem for the
0588   /// language.
0589   ///
0590   /// \param language The language for which the type system should be found.
0591   /// \param create_callback A callback that will be called if no previously
0592   ///                        created TypeSystem that fits the given language
0593   ///                        could found. Can be omitted if a non-existent
0594   ///                        type system should be treated as an error
0595   ///                        instead.
0596   /// \return The found type system or an error.
0597   llvm::Expected<lldb::TypeSystemSP> GetTypeSystemForLanguage(
0598       lldb::LanguageType language,
0599       std::optional<CreateCallback> create_callback = std::nullopt);
0600   };
0601 
0602   } // namespace lldb_private
0603 
0604 #endif // LLDB_SYMBOL_TYPESYSTEM_H