15#include "llvm/ADT/DenseSet.h"
25 "Languages bit vector is no longer small on 64 bit systems");
45 if (
auto type_system_sp = create_callback(language, module, target))
46 return type_system_sp;
110 uint32_t opaque_payload) {
147 size_t idx,
bool expand_pack) {
151std::optional<CompilerType::IntegralTemplateArgument>
188std::vector<lldb_private::CompilerContext>
193std::vector<lldb_private::CompilerContext>
198std::vector<CompilerDecl>
200 bool ignore_imported_decls) {
201 return std::vector<CompilerDecl>();
204std::unique_ptr<UtilityFunction>
218#pragma mark TypeSystemMap
227 std::lock_guard<std::mutex> guard(
m_mutex);
231 llvm::DenseSet<TypeSystem *> visited;
232 for (
auto &pair : map) {
233 if (visited.count(pair.second.get()))
235 visited.insert(pair.second.get());
237 type_system->Finalize();
241 std::lock_guard<std::mutex> guard(
m_mutex);
256 std::lock_guard<std::mutex> guard(
m_mutex);
257 map_snapshot =
m_map;
262 llvm::DenseSet<TypeSystem *> visited;
263 for (
auto &pair : map_snapshot) {
265 if (!type_system || visited.count(type_system))
267 visited.insert(type_system);
269 if (!callback(pair.second))
276 std::optional<CreateCallback> create_callback) {
277 std::lock_guard<std::mutex> guard(
m_mutex);
279 return llvm::createStringError(
280 "Unable to get TypeSystem because TypeSystemMap is being cleared");
282 collection::iterator pos =
m_map.find(language);
283 if (pos !=
m_map.end()) {
285 assert(!pos->second->weak_from_this().expired());
288 return llvm::createStringError(
289 "TypeSystem for language " +
294 for (
const auto &pair :
m_map) {
295 if (pair.second && pair.second->SupportsLanguage(language)) {
298 m_map[language] = pair.second;
301 return llvm::createStringError(
302 "TypeSystem for language " +
308 if (!create_callback)
309 return llvm::createStringError(
310 "Unable to find type system for language " +
315 m_map[language] = type_system_sp;
317 return type_system_sp;
318 return llvm::createStringError(
319 "TypeSystem for language " +
324llvm::Expected<lldb::TypeSystemSP>
326 Module *module,
bool can_create) {
329 language, std::optional<CreateCallback>([language, module]() {
336llvm::Expected<lldb::TypeSystemSP>
338 Target *target,
bool can_create) {
341 language, std::optional<CreateCallback>([language, target]() {
354 if (languages.
Empty())
356 return languages[language];
static const size_t g_num_small_bitvector_bits
A 64-bit SmallBitVector is only small up to 64-7 bits, and the setBitsInMask interface wants to write...
static TypeSystemSP CreateInstanceHelper(lldb::LanguageType language, Module *module, Target *target)
Represents a generic declaration context in a program.
Generic representation of a type in a programming language.
A uniqued constant string class.
static const char * GetNameForLanguageType(lldb::LanguageType language)
Returns the internal LLDB name for the specified language.
A class that describes an executable image and its associated object and symbol files.
static llvm::SmallVector< TypeSystemCreateInstance > GetTypeSystemCreateCallbacks()
static LanguageSet GetAllTypeSystemSupportedLanguagesForTypes()
llvm::DenseMap< uint16_t, lldb::TypeSystemSP > collection
std::mutex m_mutex
A mutex to keep this object happy in multi-threaded environments.
llvm::Expected< lldb::TypeSystemSP > GetTypeSystemForLanguage(lldb::LanguageType language, Module *module, bool can_create)
void ForEach(std::function< bool(lldb::TypeSystemSP)> const &callback)
Interface for representing a type system.
virtual std::unique_ptr< UtilityFunction > CreateUtilityFunction(std::string text, std::string name)
virtual bool IsMeaninglessWithoutDynamicResolution(void *type)
virtual size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type, bool expand_pack)
virtual CompilerType GetBuiltinTypeByName(ConstString name)
virtual CompilerType GetTypeTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx, bool expand_pack)
virtual CompilerType GetTypeForFormatters(void *type)
virtual CompilerType AddRestrictModifier(lldb::opaque_compiler_type_t type)
virtual CompilerType GetAtomicType(lldb::opaque_compiler_type_t type)
virtual ConstString GetMangledTypeName(lldb::opaque_compiler_type_t type)
Defaults to GetTypeName(type).
virtual CompilerType GetLValueReferenceType(lldb::opaque_compiler_type_t type)
virtual std::vector< CompilerDecl > DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name, const bool ignore_imported_decls)
virtual ConstString GetTypeName(lldb::opaque_compiler_type_t type, bool BaseOnly)=0
virtual bool IsPromotableIntegerType(lldb::opaque_compiler_type_t type)
virtual std::optional< llvm::json::Value > ReportStatistics()
virtual CompilerType CreateTypedef(lldb::opaque_compiler_type_t type, const char *name, const CompilerDeclContext &decl_ctx, uint32_t opaque_payload)
virtual LazyBool ShouldPrintAsOneLiner(void *type, ValueObject *valobj)
virtual CompilerType AddConstModifier(lldb::opaque_compiler_type_t type)
virtual CompilerType AddPtrAuthModifier(lldb::opaque_compiler_type_t type, uint32_t payload)
virtual CompilerType DeclGetFunctionReturnType(void *opaque_decl)
virtual CompilerType DeclGetFunctionArgumentType(void *opaque_decl, size_t arg_idx)
virtual CompilerType GetRValueReferenceType(lldb::opaque_compiler_type_t type)
virtual std::vector< lldb_private::CompilerContext > DeclGetCompilerContext(void *opaque_decl)
virtual std::vector< lldb_private::CompilerContext > DeclContextGetCompilerContext(void *opaque_decl_ctx)
virtual bool IsAnonymousType(lldb::opaque_compiler_type_t type)
virtual ConstString DeclGetMangledName(void *opaque_decl)
virtual CompilerType GetArrayType(lldb::opaque_compiler_type_t type, uint64_t size)
static bool SupportsLanguageStatic(lldb::LanguageType language)
virtual CompilerDeclContext GetCompilerDeclContextForType(const CompilerType &type)
Returns the direct parent context of specified type.
virtual CompilerType GetPromotedIntegerType(lldb::opaque_compiler_type_t type)
virtual std::optional< CompilerType::IntegralTemplateArgument > GetIntegralTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx, bool expand_pack)
virtual bool Verify(lldb::opaque_compiler_type_t type)=0
Verify the integrity of the type to catch CompilerTypes that mix and match invalid TypeSystem/Opaque ...
virtual lldb::TemplateArgumentKind GetTemplateArgumentKind(lldb::opaque_compiler_type_t type, size_t idx, bool expand_pack)
static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language, Module *module)
virtual bool IsTemplateType(lldb::opaque_compiler_type_t type)
virtual size_t DeclGetFunctionNumArguments(void *opaque_decl)
virtual CompilerDeclContext DeclGetDeclContext(void *opaque_decl)
virtual CompilerType AddVolatileModifier(lldb::opaque_compiler_type_t type)
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::TypeSystem > TypeSystemSP
void * opaque_compiler_type_t
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
@ eTemplateArgumentKindNull
A SmallBitVector that represents a set of source languages (lldb::LanguageType).
llvm::SmallBitVector bitvector
std::optional< lldb::LanguageType > GetSingularLanguage()
If the set contains a single language only, return it.
bool operator[](unsigned i) const
void Insert(lldb::LanguageType language)