class TypeSummaryImpl;
class TypeSummaryOptions;
class TypeSystem;
+class TypeSystemClang;
class UUID;
class UnixSignals;
class Unwind;
typedef std::shared_ptr<lldb_private::TypeEnumMemberImpl> TypeEnumMemberImplSP;
typedef std::shared_ptr<lldb_private::TypeFilterImpl> TypeFilterImplSP;
typedef std::shared_ptr<lldb_private::TypeSystem> TypeSystemSP;
+typedef std::shared_ptr<lldb_private::TypeSystemClang> TypeSystemClangSP;
typedef std::weak_ptr<lldb_private::TypeSystem> TypeSystemWP;
typedef std::shared_ptr<lldb_private::TypeFormatImpl> TypeFormatImplSP;
typedef std::shared_ptr<lldb_private::TypeNameSpecifierImpl>
}
StackFrameSP frame_sp = thread_sp->GetStackFrameAtIndex(0);
if (frame_sp) {
- TypeSystemClang *clang_ast_context =
+ TypeSystemClangSP scratch_ts_sp =
ScratchTypeSystemClang::GetForTarget(target);
- if (!clang_ast_context)
+ if (!scratch_ts_sp)
return LLDB_INVALID_ADDRESS;
CompilerType clang_void_ptr_type =
- clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();
+ scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
Address pthread_getspecific_addr = GetPthreadSetSpecificAddress();
if (pthread_getspecific_addr.IsValid()) {
EvaluateExpressionOptions options;
// Build up the value array to store the three arguments given above, then
// get the values from the ABI:
- TypeSystemClang *clang_ast_context =
+ TypeSystemClangSP scratch_ts_sp =
ScratchTypeSystemClang::GetForTarget(process->GetTarget());
- if (!clang_ast_context)
+ if (!scratch_ts_sp)
return false;
ValueList argument_values;
Value headers_value; // uint64_t machHeaders[] (aka void*)
CompilerType clang_void_ptr_type =
- clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();
+ scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
CompilerType clang_uint32_type =
- clang_ast_context->GetBuiltinTypeForEncodingAndBitSize(
- lldb::eEncodingUint, 32);
+ scratch_ts_sp->GetBuiltinTypeForEncodingAndBitSize(lldb::eEncodingUint,
+ 32);
CompilerType clang_uint64_type =
- clang_ast_context->GetBuiltinTypeForEncodingAndBitSize(
- lldb::eEncodingUint, 32);
+ scratch_ts_sp->GetBuiltinTypeForEncodingAndBitSize(lldb::eEncodingUint,
+ 32);
mode_value.SetValueType(Value::ValueType::Scalar);
mode_value.SetCompilerType(clang_uint32_type);
// Build up the value array to store the three arguments given above, then
// get the values from the ABI:
- TypeSystemClang *clang_ast_context =
+ TypeSystemClangSP scratch_ts_sp =
ScratchTypeSystemClang::GetForTarget(process->GetTarget());
- if (!clang_ast_context)
+ if (!scratch_ts_sp)
return false;
ValueList argument_values;
Value input_value;
CompilerType clang_void_ptr_type =
- clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();
+ scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
CompilerType clang_uint32_type =
- clang_ast_context->GetBuiltinTypeForEncodingAndBitSize(
- lldb::eEncodingUint, 32);
+ scratch_ts_sp->GetBuiltinTypeForEncodingAndBitSize(lldb::eEncodingUint,
+ 32);
input_value.SetValueType(Value::ValueType::Scalar);
input_value.SetCompilerType(clang_uint32_type);
// input_value.SetContext (Value::eContextTypeClangType,
auto *persistent_vars = llvm::cast<ClangPersistentVariables>(state);
- TypeSystemClang *scratch_ctx = ScratchTypeSystemClang::GetForTarget(
+ lldb::TypeSystemClangSP scratch_ts_sp = ScratchTypeSystemClang::GetForTarget(
m_target, m_ast_context->getLangOpts());
for (clang::NamedDecl *decl : m_decls) {
ConstString name_cs(name.str().c_str());
Decl *D_scratch = persistent_vars->GetClangASTImporter()->DeportDecl(
- &scratch_ctx->getASTContext(), decl);
+ &scratch_ts_sp->getASTContext(), decl);
if (!D_scratch) {
Log *log = GetLog(LLDBLog::Expressions);
if (NamedDecl *NamedDecl_scratch = dyn_cast<NamedDecl>(D_scratch))
persistent_vars->RegisterPersistentDecl(name_cs, NamedDecl_scratch,
- scratch_ctx);
+ scratch_ts_sp);
}
}
// query the deleted ASTContext for additional type information.
// We unregister from *all* scratch ASTContexts in case a type got exported
// to a scratch AST that isn't the best fitting scratch ASTContext.
- TypeSystemClang *scratch_ast = ScratchTypeSystemClang::GetForTarget(
+ lldb::TypeSystemClangSP scratch_ts_sp = ScratchTypeSystemClang::GetForTarget(
*m_target, ScratchTypeSystemClang::DefaultAST, false);
- if (!scratch_ast)
+ if (!scratch_ts_sp)
return;
ScratchTypeSystemClang *default_scratch_ast =
- llvm::cast<ScratchTypeSystemClang>(scratch_ast);
+ llvm::cast<ScratchTypeSystemClang>(scratch_ts_sp.get());
// Unregister from the default scratch AST (and all sub-ASTs).
default_scratch_ast->ForgetSource(m_ast_context, *m_ast_importer_sp);
}
TypeFromUser ClangExpressionDeclMap::DeportType(TypeSystemClang &target,
TypeSystemClang &source,
TypeFromParser parser_type) {
- assert(&target == GetScratchContext(*m_target));
+ assert(&target == GetScratchContext(*m_target).get());
assert((TypeSystem *)&source ==
parser_type.GetTypeSystem().GetSharedPointer().get());
assert(&source.getASTContext() == m_ast_context);
if (target == nullptr)
return false;
- auto *clang_ast_context = GetScratchContext(*target);
+ auto clang_ast_context = GetScratchContext(*target);
if (!clang_ast_context)
return false;
if (target == nullptr)
return false;
- TypeSystemClang *context = GetScratchContext(*target);
+ auto context = GetScratchContext(*target);
if (!context)
return false;
if (target == nullptr)
return;
- TypeSystemClang *scratch_ast_context = GetScratchContext(*target);
+ auto scratch_ast_context = GetScratchContext(*target);
if (!scratch_ast_context)
return;
#include <csignal>
#include <cstdint>
+#include <memory>
#include <vector>
#include "ClangASTSource.h"
/// Deallocate struct variables
void DisableStructVars() { m_struct_vars.reset(); }
- TypeSystemClang *GetScratchContext(Target &target) {
+ lldb::TypeSystemClangSP GetScratchContext(Target &target) {
return ScratchTypeSystemClang::GetForTarget(target,
m_ast_context->getLangOpts());
}
#include "llvm/ADT/StringMap.h"
#include <optional>
+#include <memory>
using namespace lldb;
using namespace lldb_private;
return std::nullopt;
}
-void ClangPersistentVariables::RegisterPersistentDecl(ConstString name,
- clang::NamedDecl *decl,
- TypeSystemClang *ctx) {
- PersistentDecl p = {decl, ctx->weak_from_this()};
+void ClangPersistentVariables::RegisterPersistentDecl(
+ ConstString name, clang::NamedDecl *decl,
+ std::shared_ptr<TypeSystemClang> ctx) {
+ PersistentDecl p = {decl, ctx};
m_persistent_decls.insert(std::make_pair(name.GetCString(), p));
if (clang::EnumDecl *enum_decl = llvm::dyn_cast<clang::EnumDecl>(decl)) {
for (clang::EnumConstantDecl *enumerator_decl : enum_decl->enumerators()) {
- p = {enumerator_decl, ctx->weak_from_this()};
+ p = {enumerator_decl, ctx};
m_persistent_decls.insert(std::make_pair(
ConstString(enumerator_decl->getNameAsString()).GetCString(), p));
}
GetCompilerTypeFromPersistentDecl(ConstString type_name) override;
void RegisterPersistentDecl(ConstString name, clang::NamedDecl *decl,
- TypeSystemClang *ctx);
+ std::shared_ptr<TypeSystemClang> ctx);
clang::NamedDecl *GetPersistentDecl(ConstString name);
return false;
// std::wstring::size() is measured in 'characters', not bytes
- TypeSystemClang *ast_context =
+ TypeSystemClangSP scratch_ts_sp =
ScratchTypeSystemClang::GetForTarget(*valobj.GetTargetSP());
- if (!ast_context)
+ if (!scratch_ts_sp)
return false;
auto wchar_t_size =
- ast_context->GetBasicType(lldb::eBasicTypeWChar).GetByteSize(nullptr);
+ scratch_ts_sp->GetBasicType(lldb::eBasicTypeWChar).GetByteSize(nullptr);
if (!wchar_t_size)
return false;
NSArrayMSyntheticFrontEndBase(lldb::ValueObjectSP valobj_sp)
: SyntheticChildrenFrontEnd(*valobj_sp), m_exe_ctx_ref(), m_id_type() {
if (valobj_sp) {
- auto *clang_ast_context = ScratchTypeSystemClang::GetForTarget(
+ TypeSystemClangSP scratch_ts_sp = ScratchTypeSystemClang::GetForTarget(
*valobj_sp->GetExecutionContextRef().GetTargetSP());
- if (clang_ast_context)
+ if (scratch_ts_sp)
m_id_type = CompilerType(
- clang_ast_context->weak_from_this(),
- clang_ast_context->getASTContext().ObjCBuiltinIdTy.getAsOpaquePtr());
+ scratch_ts_sp->weak_from_this(),
+ scratch_ts_sp->getASTContext().ObjCBuiltinIdTy.getAsOpaquePtr());
if (valobj_sp->GetProcessSP())
m_ptr_size = valobj_sp->GetProcessSP()->GetAddressByteSize();
}
if (valobj_sp) {
CompilerType type = valobj_sp->GetCompilerType();
if (type) {
- auto *clang_ast_context = ScratchTypeSystemClang::GetForTarget(
+ TypeSystemClangSP scratch_ts_sp = ScratchTypeSystemClang::GetForTarget(
*valobj_sp->GetExecutionContextRef().GetTargetSP());
- if (clang_ast_context)
- m_id_type = clang_ast_context->GetType(
- clang_ast_context->getASTContext().ObjCBuiltinIdTy);
+ if (scratch_ts_sp)
+ m_id_type = scratch_ts_sp->GetType(
+ scratch_ts_sp->getASTContext().ObjCBuiltinIdTy);
}
}
}
static const ConstString g_zero("[0]");
if (idx == 0) {
- auto *clang_ast_context =
+ TypeSystemClangSP scratch_ts_sp =
ScratchTypeSystemClang::GetForTarget(*m_backend.GetTargetSP());
- if (clang_ast_context) {
- CompilerType id_type(
- clang_ast_context->GetBasicType(lldb::eBasicTypeObjCID));
+ if (scratch_ts_sp) {
+ CompilerType id_type(scratch_ts_sp->GetBasicType(lldb::eBasicTypeObjCID));
return m_backend.GetSyntheticChildAtOffset(
m_backend.GetProcessSP()->GetAddressByteSize(), id_type, true,
g_zero);
static CompilerType GetLLDBNSPairType(TargetSP target_sp) {
CompilerType compiler_type;
- TypeSystemClang *target_ast_context =
+ TypeSystemClangSP scratch_ts_sp =
ScratchTypeSystemClang::GetForTarget(*target_sp);
- if (target_ast_context) {
+ if (scratch_ts_sp) {
ConstString g_lldb_autogen_nspair("__lldb_autogen_nspair");
- compiler_type =
- target_ast_context->GetTypeForIdentifier<clang::CXXRecordDecl>(
- g_lldb_autogen_nspair);
+ compiler_type = scratch_ts_sp->GetTypeForIdentifier<clang::CXXRecordDecl>(
+ g_lldb_autogen_nspair);
if (!compiler_type) {
- compiler_type = target_ast_context->CreateRecordType(
+ compiler_type = scratch_ts_sp->CreateRecordType(
nullptr, OptionalClangModuleID(), lldb::eAccessPublic,
g_lldb_autogen_nspair.GetCString(), clang::TTK_Struct,
lldb::eLanguageTypeC);
if (compiler_type) {
TypeSystemClang::StartTagDeclarationDefinition(compiler_type);
CompilerType id_compiler_type =
- target_ast_context->GetBasicType(eBasicTypeObjCID);
+ scratch_ts_sp->GetBasicType(eBasicTypeObjCID);
TypeSystemClang::AddFieldToRecordType(
compiler_type, "key", id_compiler_type, lldb::eAccessPublic, 0);
TypeSystemClang::AddFieldToRecordType(
}
InferiorSizedWord isw(domain_str_value, *process_sp);
+ TypeSystemClangSP scratch_ts_sp =
+ ScratchTypeSystemClang::GetForTarget(process_sp->GetTarget());
+ if (!scratch_ts_sp)
+ return false;
ValueObjectSP domain_str_sp = ValueObject::CreateValueObjectFromData(
"domain_str", isw.GetAsData(process_sp->GetByteOrder()),
valobj.GetExecutionContextRef(),
- ScratchTypeSystemClang::GetForTarget(process_sp->GetTarget())
- ->GetBasicType(lldb::eBasicTypeVoid)
- .GetPointerType());
+ scratch_ts_sp->GetBasicType(lldb::eBasicTypeVoid).GetPointerType());
if (!domain_str_sp)
return false;
if (userinfo == LLDB_INVALID_ADDRESS || error.Fail())
return false;
InferiorSizedWord isw(userinfo, *process_sp);
+ TypeSystemClangSP scratch_ts_sp =
+ ScratchTypeSystemClang::GetForTarget(process_sp->GetTarget());
+ if (!scratch_ts_sp)
+ return false;
m_child_sp = CreateValueObjectFromData(
"_userInfo", isw.GetAsData(process_sp->GetByteOrder()),
m_backend.GetExecutionContextRef(),
- ScratchTypeSystemClang::GetForTarget(process_sp->GetTarget())
- ->GetBasicType(lldb::eBasicTypeObjCID));
+ scratch_ts_sp->GetBasicType(lldb::eBasicTypeObjCID));
return false;
}
InferiorSizedWord userinfo_isw(userinfo, *process_sp);
InferiorSizedWord reserved_isw(reserved, *process_sp);
- auto *clang_ast_context =
+ TypeSystemClangSP scratch_ts_sp =
ScratchTypeSystemClang::GetForTarget(process_sp->GetTarget());
- if (!clang_ast_context)
+ if (!scratch_ts_sp)
return false;
CompilerType voidstar =
- clang_ast_context->GetBasicType(lldb::eBasicTypeVoid).GetPointerType();
+ scratch_ts_sp->GetBasicType(lldb::eBasicTypeVoid).GetPointerType();
if (name_sp)
*name_sp = ValueObject::CreateValueObjectFromData(
if (!type_system)
return false;
- TypeSystemClang *ast = ScratchTypeSystemClang::GetForTarget(
+ auto ast = ScratchTypeSystemClang::GetForTarget(
*m_backend.GetExecutionContextRef().GetTargetSP());
if (!ast)
return false;
if (!thread_sp->SafeToCallFunctions())
return {};
- TypeSystemClang *clang_ast_context =
+ TypeSystemClangSP scratch_ts_sp =
ScratchTypeSystemClang::GetForTarget(m_process->GetTarget());
- if (!clang_ast_context)
+ if (!scratch_ts_sp)
return {};
CompilerType voidstar =
- clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();
+ scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
DiagnosticManager diagnostics;
ExecutionContext exe_ctx;
}
} else {
// If it is not a pointer, see if we can make it into a pointer.
- TypeSystemClang *ast_context =
+ TypeSystemClangSP scratch_ts_sp =
ScratchTypeSystemClang::GetForTarget(*target);
- if (!ast_context)
+ if (!scratch_ts_sp)
return false;
- CompilerType opaque_type = ast_context->GetBasicType(eBasicTypeObjCID);
+ CompilerType opaque_type = scratch_ts_sp->GetBasicType(eBasicTypeObjCID);
if (!opaque_type)
- opaque_type = ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();
+ opaque_type = scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
// value.SetContext(Value::eContextTypeClangType, opaque_type_ptr);
value.SetCompilerType(opaque_type);
}
arg_value_list.PushValue(value);
// This is the return value:
- TypeSystemClang *ast_context = ScratchTypeSystemClang::GetForTarget(*target);
- if (!ast_context)
+ TypeSystemClangSP scratch_ts_sp =
+ ScratchTypeSystemClang::GetForTarget(*target);
+ if (!scratch_ts_sp)
return false;
- CompilerType return_compiler_type = ast_context->GetCStringType(true);
+ CompilerType return_compiler_type = scratch_ts_sp->GetCStringType(true);
Value ret;
// ret.SetContext(Value::eContextTypeClangType, return_compiler_type);
ret.SetCompilerType(return_compiler_type);
if (!reserved_dict)
return FailExceptionParsing("Failed to get synthetic value.");
- TypeSystemClang *clang_ast_context =
+ TypeSystemClangSP scratch_ts_sp =
ScratchTypeSystemClang::GetForTarget(*exception_sp->GetTargetSP());
- if (!clang_ast_context)
+ if (!scratch_ts_sp)
return FailExceptionParsing("Failed to get scratch AST.");
- CompilerType objc_id =
- clang_ast_context->GetBasicType(lldb::eBasicTypeObjCID);
+ CompilerType objc_id = scratch_ts_sp->GetBasicType(lldb::eBasicTypeObjCID);
ValueObjectSP return_addresses;
auto objc_object_from_address = [&exception_sp, &objc_id](uint64_t addr,
LLDB_LOG(log, "Creating utility function {0}", name);
- TypeSystemClang *ast =
+ TypeSystemClangSP scratch_ts_sp =
ScratchTypeSystemClang::GetForTarget(exe_ctx.GetTargetRef());
- if (!ast)
+ if (!scratch_ts_sp)
return {};
auto utility_fn_or_error = exe_ctx.GetTargetRef().CreateUtilityFunction(
// Make some types for our arguments.
CompilerType clang_uint32_t_type =
- ast->GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, 32);
+ scratch_ts_sp->GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, 32);
CompilerType clang_void_pointer_type =
- ast->GetBasicType(eBasicTypeVoid).GetPointerType();
+ scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
// Make the runner function for our implementation utility function.
ValueList arguments;
LLDB_LOG(log, "Creating utility function {0}",
g_get_shared_cache_class_info_name);
- TypeSystemClang *ast =
+ TypeSystemClangSP scratch_ts_sp =
ScratchTypeSystemClang::GetForTarget(exe_ctx.GetTargetRef());
- if (!ast)
+ if (!scratch_ts_sp)
return {};
// If the inferior objc.dylib has the class_getNameRaw function, use that in
// Make some types for our arguments.
CompilerType clang_uint32_t_type =
- ast->GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, 32);
+ scratch_ts_sp->GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, 32);
CompilerType clang_void_pointer_type =
- ast->GetBasicType(eBasicTypeVoid).GetPointerType();
+ scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
CompilerType clang_uint64_t_pointer_type =
- ast->GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, 64)
+ scratch_ts_sp->GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, 64)
.GetPointerType();
// Next make the function caller for our implementation utility function.
return DescriptorMapUpdateResult::Retry();
thread_sp->CalculateExecutionContext(exe_ctx);
- TypeSystemClang *ast =
+ TypeSystemClangSP scratch_ts_sp =
ScratchTypeSystemClang::GetForTarget(process->GetTarget());
- if (!ast)
+ if (!scratch_ts_sp)
return DescriptorMapUpdateResult::Fail();
Address function_address;
options.SetIsForUtilityExpr(true);
CompilerType clang_uint32_t_type =
- ast->GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, 32);
+ scratch_ts_sp->GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, 32);
Value return_value;
return_value.SetValueType(Value::ValueType::Scalar);
return DescriptorMapUpdateResult::Retry();
thread_sp->CalculateExecutionContext(exe_ctx);
- TypeSystemClang *ast =
+ TypeSystemClangSP scratch_ts_sp =
ScratchTypeSystemClang::GetForTarget(process->GetTarget());
- if (!ast)
+ if (!scratch_ts_sp)
return DescriptorMapUpdateResult::Fail();
Address function_address;
options.SetIsForUtilityExpr(true);
CompilerType clang_uint32_t_type =
- ast->GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, 32);
+ scratch_ts_sp->GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, 32);
Value return_value;
return_value.SetValueType(Value::ValueType::Scalar);
if (!abi)
return;
- TypeSystemClang *clang_ast_context =
+ TypeSystemClangSP scratch_ts_sp =
ScratchTypeSystemClang::GetForTarget(process_sp->GetTarget());
- if (!clang_ast_context)
+ if (!scratch_ts_sp)
return;
CompilerType voidstar =
- clang_ast_context->GetBasicType(lldb::eBasicTypeVoid).GetPointerType();
+ scratch_ts_sp->GetBasicType(lldb::eBasicTypeVoid).GetPointerType();
ValueList args;
Value input_value;
Process *process = exe_ctx.GetProcessPtr();
const ABI *abi = process->GetABI().get();
- TypeSystemClang *clang_ast_context =
+ TypeSystemClangSP scratch_ts_sp =
ScratchTypeSystemClang::GetForTarget(process->GetTarget());
- if (!clang_ast_context)
+ if (!scratch_ts_sp)
return false;
ValueList argument_values;
Value input_value;
CompilerType clang_void_ptr_type =
- clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();
+ scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
input_value.SetValueType(Value::ValueType::Scalar);
// input_value.SetContext (Value::eContextTypeClangType,
}
// Next make the runner function for our implementation utility function.
- TypeSystemClang *clang_ast_context = ScratchTypeSystemClang::GetForTarget(
+ TypeSystemClangSP scratch_ts_sp = ScratchTypeSystemClang::GetForTarget(
thread.GetProcess()->GetTarget());
- if (!clang_ast_context)
+ if (!scratch_ts_sp)
return LLDB_INVALID_ADDRESS;
CompilerType clang_void_ptr_type =
- clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();
+ scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
Status error;
impl_function_caller = m_impl_code->MakeFunctionCaller(
TargetSP target_sp(thread.CalculateTarget());
- TypeSystemClang *clang_ast_context =
+ TypeSystemClangSP scratch_ts_sp =
ScratchTypeSystemClang::GetForTarget(*target_sp);
- if (!clang_ast_context)
+ if (!scratch_ts_sp)
return ret_plan_sp;
ValueList argument_values;
Value void_ptr_value;
CompilerType clang_void_ptr_type =
- clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();
+ scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
void_ptr_value.SetValueType(Value::ValueType::Scalar);
// void_ptr_value.SetContext (Value::eContextTypeClangType,
// clang_void_ptr_type);
Value flag_value;
CompilerType clang_int_type =
- clang_ast_context->GetBuiltinTypeForEncodingAndBitSize(
+ scratch_ts_sp->GetBuiltinTypeForEncodingAndBitSize(
lldb::eEncodingSint, 32);
flag_value.SetValueType(Value::ValueType::Scalar);
// flag_value.SetContext (Value::eContextTypeClangType, clang_int_type);
FunctionCaller *do_dlopen_function = nullptr;
// Fetch the clang types we will need:
- TypeSystemClang *ast =
+ TypeSystemClangSP scratch_ts_sp =
ScratchTypeSystemClang::GetForTarget(process->GetTarget());
- if (!ast)
+ if (!scratch_ts_sp)
return nullptr;
- CompilerType clang_void_pointer_type
- = ast->GetBasicType(eBasicTypeVoid).GetPointerType();
- CompilerType clang_char_pointer_type
- = ast->GetBasicType(eBasicTypeChar).GetPointerType();
+ CompilerType clang_void_pointer_type =
+ scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
+ CompilerType clang_char_pointer_type =
+ scratch_ts_sp->GetBasicType(eBasicTypeChar).GetPointerType();
// We are passing four arguments, the basename, the list of places to look,
// a buffer big enough for all the path + name combos, and
Value return_value;
// Fetch the clang types we will need:
- TypeSystemClang *ast =
+ TypeSystemClangSP scratch_ts_sp =
ScratchTypeSystemClang::GetForTarget(process->GetTarget());
- if (!ast) {
+ if (!scratch_ts_sp) {
error.SetErrorString("dlopen error: Unable to get TypeSystemClang");
return LLDB_INVALID_IMAGE_TOKEN;
}
- CompilerType clang_void_pointer_type
- = ast->GetBasicType(eBasicTypeVoid).GetPointerType();
+ CompilerType clang_void_pointer_type =
+ scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
return_value.SetCompilerType(clang_void_pointer_type);
return LLDB_INVALID_IMAGE_TOKEN;
}
- auto parameter_cleanup = llvm::make_scope_exit([invocation, &context, injected_parameters]() {
- invocation->DeallocateFunctionResults(context, injected_parameters);
- });
+ auto parameter_cleanup =
+ llvm::make_scope_exit([invocation, &context, injected_parameters]() {
+ invocation->DeallocateFunctionResults(context, injected_parameters);
+ });
- TypeSystemClang *ast =
+ TypeSystemClangSP scratch_ts_sp =
ScratchTypeSystemClang::GetForTarget(process->GetTarget());
- if (!ast) {
+ if (!scratch_ts_sp) {
error.SetErrorString("LoadLibrary error: unable to get (clang) type system");
return LLDB_INVALID_IMAGE_TOKEN;
}
/* Setup Return Type */
- CompilerType VoidPtrTy = ast->GetBasicType(eBasicTypeVoid).GetPointerType();
+ CompilerType VoidPtrTy =
+ scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
Value value;
value.SetCompilerType(VoidPtrTy);
return nullptr;
}
- TypeSystemClang *ast = ScratchTypeSystemClang::GetForTarget(target);
- if (!ast)
+ TypeSystemClangSP scratch_ts_sp =
+ ScratchTypeSystemClang::GetForTarget(target);
+ if (!scratch_ts_sp)
return nullptr;
- CompilerType VoidPtrTy = ast->GetBasicType(eBasicTypeVoid).GetPointerType();
- CompilerType WCharPtrTy = ast->GetBasicType(eBasicTypeWChar).GetPointerType();
+ CompilerType VoidPtrTy =
+ scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
+ CompilerType WCharPtrTy =
+ scratch_ts_sp->GetBasicType(eBasicTypeWChar).GetPointerType();
ValueList parameters;
lldb::StackFrameSP thread_cur_frame = thread.GetStackFrameAtIndex(0);
ProcessSP process_sp(thread.CalculateProcess());
TargetSP target_sp(thread.CalculateTarget());
- TypeSystemClang *clang_ast_context =
+ TypeSystemClangSP scratch_ts_sp =
ScratchTypeSystemClang::GetForTarget(*target_sp);
Log *log = GetLog(LLDBLog::SystemRuntime);
// already allocated by lldb in the inferior process.
CompilerType clang_void_ptr_type =
- clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();
+ scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
Value return_buffer_ptr_value;
return_buffer_ptr_value.SetValueType(Value::ValueType::Scalar);
return_buffer_ptr_value.SetCompilerType(clang_void_ptr_type);
- CompilerType clang_int_type = clang_ast_context->GetBasicType(eBasicTypeInt);
+ CompilerType clang_int_type = scratch_ts_sp->GetBasicType(eBasicTypeInt);
Value debug_value;
debug_value.SetValueType(Value::ValueType::Scalar);
debug_value.SetCompilerType(clang_int_type);
CompilerType clang_uint64_type =
- clang_ast_context->GetBasicType(eBasicTypeUnsignedLongLong);
+ scratch_ts_sp->GetBasicType(eBasicTypeUnsignedLongLong);
Value item_value;
item_value.SetValueType(Value::ValueType::Scalar);
item_value.SetCompilerType(clang_uint64_type);
// Next make the runner function for our implementation utility function.
Status error;
- TypeSystemClang *clang_ast_context = ScratchTypeSystemClang::GetForTarget(
+ TypeSystemClangSP scratch_ts_sp = ScratchTypeSystemClang::GetForTarget(
thread.GetProcess()->GetTarget());
CompilerType get_pending_items_return_type =
- clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();
+ scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
get_pending_items_caller =
m_get_pending_items_impl_code->MakeFunctionCaller(
get_pending_items_return_type, get_pending_items_arglist,
lldb::StackFrameSP thread_cur_frame = thread.GetStackFrameAtIndex(0);
ProcessSP process_sp(thread.CalculateProcess());
TargetSP target_sp(thread.CalculateTarget());
- TypeSystemClang *clang_ast_context =
+ TypeSystemClangSP scratch_ts_sp =
ScratchTypeSystemClang::GetForTarget(*target_sp);
Log *log = GetLog(LLDBLog::SystemRuntime);
// already allocated by lldb in the inferior process.
CompilerType clang_void_ptr_type =
- clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();
+ scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
Value return_buffer_ptr_value;
return_buffer_ptr_value.SetValueType(Value::ValueType::Scalar);
return_buffer_ptr_value.SetCompilerType(clang_void_ptr_type);
- CompilerType clang_int_type = clang_ast_context->GetBasicType(eBasicTypeInt);
+ CompilerType clang_int_type = scratch_ts_sp->GetBasicType(eBasicTypeInt);
Value debug_value;
debug_value.SetValueType(Value::ValueType::Scalar);
debug_value.SetCompilerType(clang_int_type);
CompilerType clang_uint64_type =
- clang_ast_context->GetBasicType(eBasicTypeUnsignedLongLong);
+ scratch_ts_sp->GetBasicType(eBasicTypeUnsignedLongLong);
Value queue_value;
queue_value.SetValueType(Value::ValueType::Scalar);
queue_value.SetCompilerType(clang_uint64_type);
}
// Next make the runner function for our implementation utility function.
- TypeSystemClang *clang_ast_context =
+ TypeSystemClangSP scratch_ts_sp =
ScratchTypeSystemClang::GetForTarget(thread.GetProcess()->GetTarget());
CompilerType get_queues_return_type =
- clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();
+ scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
Status error;
get_queues_caller = m_get_queues_impl_code_up->MakeFunctionCaller(
get_queues_return_type, get_queues_arglist, thread_sp, error);
lldb::StackFrameSP thread_cur_frame = thread.GetStackFrameAtIndex(0);
ProcessSP process_sp(thread.CalculateProcess());
TargetSP target_sp(thread.CalculateTarget());
- TypeSystemClang *clang_ast_context =
+ TypeSystemClangSP scratch_ts_sp =
ScratchTypeSystemClang::GetForTarget(*target_sp);
Log *log = GetLog(LLDBLog::SystemRuntime);
// already allocated by lldb in the inferior process.
CompilerType clang_void_ptr_type =
- clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();
+ scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
Value return_buffer_ptr_value;
return_buffer_ptr_value.SetValueType(Value::ValueType::Scalar);
return_buffer_ptr_value.SetCompilerType(clang_void_ptr_type);
- CompilerType clang_int_type = clang_ast_context->GetBasicType(eBasicTypeInt);
+ CompilerType clang_int_type = scratch_ts_sp->GetBasicType(eBasicTypeInt);
Value debug_value;
debug_value.SetValueType(Value::ValueType::Scalar);
debug_value.SetCompilerType(clang_int_type);
page_to_free_value.SetCompilerType(clang_void_ptr_type);
CompilerType clang_uint64_type =
- clang_ast_context->GetBasicType(eBasicTypeUnsignedLongLong);
+ scratch_ts_sp->GetBasicType(eBasicTypeUnsignedLongLong);
Value page_to_free_size_value;
page_to_free_size_value.SetValueType(Value::ValueType::Scalar);
page_to_free_size_value.SetCompilerType(clang_uint64_type);
// Also make the FunctionCaller for this UtilityFunction:
- TypeSystemClang *clang_ast_context = ScratchTypeSystemClang::GetForTarget(
+ TypeSystemClangSP scratch_ts_sp = ScratchTypeSystemClang::GetForTarget(
thread.GetProcess()->GetTarget());
CompilerType get_thread_item_info_return_type =
- clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();
+ scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
get_thread_item_info_caller =
m_get_thread_item_info_impl_code->MakeFunctionCaller(
lldb::StackFrameSP thread_cur_frame = thread.GetStackFrameAtIndex(0);
ProcessSP process_sp(thread.CalculateProcess());
TargetSP target_sp(thread.CalculateTarget());
- TypeSystemClang *clang_ast_context =
+ TypeSystemClangSP scratch_ts_sp =
ScratchTypeSystemClang::GetForTarget(*target_sp);
Log *log = GetLog(LLDBLog::SystemRuntime);
// already allocated by lldb in the inferior process.
CompilerType clang_void_ptr_type =
- clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();
+ scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
Value return_buffer_ptr_value;
return_buffer_ptr_value.SetValueType(Value::ValueType::Scalar);
return_buffer_ptr_value.SetCompilerType(clang_void_ptr_type);
- CompilerType clang_int_type = clang_ast_context->GetBasicType(eBasicTypeInt);
+ CompilerType clang_int_type = scratch_ts_sp->GetBasicType(eBasicTypeInt);
Value debug_value;
debug_value.SetValueType(Value::ValueType::Scalar);
debug_value.SetCompilerType(clang_int_type);
CompilerType clang_uint64_type =
- clang_ast_context->GetBasicType(eBasicTypeUnsignedLongLong);
+ scratch_ts_sp->GetBasicType(eBasicTypeUnsignedLongLong);
Value thread_id_value;
thread_id_value.SetValueType(Value::ValueType::Scalar);
thread_id_value.SetCompilerType(clang_uint64_type);
}
#endif
- TypeSystemClang *ast_ctx =
+ TypeSystemClangSP scratch_ts_sp =
ScratchTypeSystemClang::GetForTarget(m_process->GetTarget());
if (m_dispatch_tsd_indexes_addr != LLDB_INVALID_ADDRESS) {
CompilerType uint16 =
- ast_ctx->GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, 16);
- CompilerType dispatch_tsd_indexes_s = ast_ctx->CreateRecordType(
+ scratch_ts_sp->GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, 16);
+ CompilerType dispatch_tsd_indexes_s = scratch_ts_sp->CreateRecordType(
nullptr, OptionalClangModuleID(), lldb::eAccessPublic,
"__lldb_dispatch_tsd_indexes_s", clang::TTK_Struct,
lldb::eLanguageTypeC);
#include "llvm/Support/FormatVariadic.h"
#include <mutex>
+#include <memory>
#include <string>
#include <vector>
m_scratch_ast_source_up.reset();
}
-TypeSystemClang *
+TypeSystemClangSP
ScratchTypeSystemClang::GetForTarget(Target &target,
std::optional<IsolatedASTKind> ast_kind,
bool create_on_demand) {
"Couldn't get scratch TypeSystemClang");
return nullptr;
}
- auto ts = *type_system_or_err;
+ auto ts_sp = *type_system_or_err;
ScratchTypeSystemClang *scratch_ast =
- llvm::dyn_cast_or_null<ScratchTypeSystemClang>(ts.get());
+ llvm::dyn_cast_or_null<ScratchTypeSystemClang>(ts_sp.get());
if (!scratch_ast)
return nullptr;
// If no dedicated sub-AST was requested, just return the main AST.
if (ast_kind == DefaultAST)
- return scratch_ast;
+ return std::static_pointer_cast<TypeSystemClang>(ts_sp);
// Search the sub-ASTs.
- return &scratch_ast->GetIsolatedAST(*ast_kind);
+ return std::static_pointer_cast<TypeSystemClang>(
+ scratch_ast->GetIsolatedAST(*ast_kind).shared_from_this());
}
/// Returns a human-readable name that uniquely identifiers the sub-AST kind.
/// this parameter is false, this function returns a nullptr.
/// \return The scratch type system of the target or a nullptr in case an
/// error occurred.
- static TypeSystemClang *
+ static lldb::TypeSystemClangSP
GetForTarget(Target &target,
std::optional<IsolatedASTKind> ast_kind = DefaultAST,
bool create_on_demand = true);
/// \param lang_opts The LangOptions of a clang ASTContext that the caller
/// wants to export type information from. This is used to
/// find the best matching sub-AST that will be returned.
- static TypeSystemClang *GetForTarget(Target &target,
- const clang::LangOptions &lang_opts) {
+ static lldb::TypeSystemClangSP
+ GetForTarget(Target &target, const clang::LangOptions &lang_opts) {
return GetForTarget(target, InferIsolatedASTKindFromLangOpts(lang_opts));
}