15#include "llvm/ADT/DenseSet.h"
25 "Languages bit vector is no longer small on 64 bit systems");
48 if (
auto type_system_sp = create_callback(language, module, target))
49 return type_system_sp;
137 size_t idx,
bool expand_pack) {
141std::optional<CompilerType::IntegralTemplateArgument>
174std::vector<CompilerDecl>
176 bool ignore_imported_decls) {
177 return std::vector<CompilerDecl>();
180std::unique_ptr<UtilityFunction>
189#pragma mark TypeSystemMap
198 std::lock_guard<std::mutex> guard(
m_mutex);
202 llvm::DenseSet<TypeSystem *> visited;
203 for (
auto &pair : map) {
204 if (visited.count(pair.second.get()))
206 visited.insert(pair.second.get());
207 if (lldb::TypeSystemSP type_system = pair.second)
208 type_system->Finalize();
212 std::lock_guard<std::mutex> guard(
m_mutex);
219 std::function<
bool(lldb::TypeSystemSP)>
const &callback) {
220 std::lock_guard<std::mutex> guard(
m_mutex);
223 llvm::DenseSet<TypeSystem *> visited;
224 for (
auto &pair :
m_map) {
226 if (!type_system || visited.count(type_system))
228 visited.insert(type_system);
230 if (!callback(pair.second))
237 std::optional<CreateCallback> create_callback) {
238 std::lock_guard<std::mutex> guard(
m_mutex);
240 return llvm::make_error<llvm::StringError>(
241 "Unable to get TypeSystem because TypeSystemMap is being cleared",
242 llvm::inconvertibleErrorCode());
244 collection::iterator pos =
m_map.find(language);
245 if (pos !=
m_map.end()) {
247 assert(!pos->second->weak_from_this().expired());
250 return llvm::make_error<llvm::StringError>(
251 "TypeSystem for language " +
254 llvm::inconvertibleErrorCode());
257 for (
const auto &pair :
m_map) {
258 if (pair.second && pair.second->SupportsLanguage(language)) {
261 m_map[language] = pair.second;
264 return llvm::make_error<llvm::StringError>(
265 "TypeSystem for language " +
268 llvm::inconvertibleErrorCode());
272 if (!create_callback)
273 return llvm::make_error<llvm::StringError>(
274 "Unable to find type system for language " +
276 llvm::inconvertibleErrorCode());
280 TypeSystemSP type_system_sp = (*create_callback)();
281 m_map[language] = type_system_sp;
283 return type_system_sp;
284 return llvm::make_error<llvm::StringError>(
285 "TypeSystem for language " +
288 llvm::inconvertibleErrorCode());
291llvm::Expected<lldb::TypeSystemSP>
293 Module *module,
bool can_create) {
296 language, std::optional<CreateCallback>([language, module]() {
303llvm::Expected<lldb::TypeSystemSP>
305 Target *target,
bool can_create) {
308 language, std::optional<CreateCallback>([language, target]() {
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)
A class that describes an executable image and its associated object and symbol files.
static TypeSystemCreateInstance GetTypeSystemCreateCallbackAtIndex(uint32_t idx)
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 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 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 DeclGetFunctionReturnType(void *opaque_decl)
virtual CompilerType DeclGetFunctionArgumentType(void *opaque_decl, size_t arg_idx)
virtual CompilerType GetRValueReferenceType(lldb::opaque_compiler_type_t type)
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)
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.
void * opaque_compiler_type_t
LanguageType
Programming language type.
@ eTemplateArgumentKindNull
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)