Index: lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp =================================================================== --- lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp +++ lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp @@ -1112,8 +1112,7 @@ } StackFrameSP frame_sp = thread_sp->GetStackFrameAtIndex(0); if (frame_sp) { - TypeSystemClang *clang_ast_context = - ScratchTypeSystemClang::GetForTarget(target); + auto clang_ast_context = ScratchTypeSystemClang::GetForTarget(target); if (!clang_ast_context) return LLDB_INVALID_ADDRESS; Index: lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp =================================================================== --- lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp +++ lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp @@ -260,7 +260,7 @@ // Build up the value array to store the three arguments given above, then // get the values from the ABI: - TypeSystemClang *clang_ast_context = + auto clang_ast_context = ScratchTypeSystemClang::GetForTarget(process->GetTarget()); if (!clang_ast_context) return false; Index: lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp =================================================================== --- lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp +++ lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp @@ -347,7 +347,7 @@ // Build up the value array to store the three arguments given above, then // get the values from the ABI: - TypeSystemClang *clang_ast_context = + auto clang_ast_context = ScratchTypeSystemClang::GetForTarget(process->GetTarget()); if (!clang_ast_context) return false; Index: lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp =================================================================== --- lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp +++ lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp @@ -470,7 +470,7 @@ auto *persistent_vars = llvm::cast(state); - TypeSystemClang *scratch_ctx = ScratchTypeSystemClang::GetForTarget( + auto scratch_ctx = ScratchTypeSystemClang::GetForTarget( m_target, m_ast_context->getLangOpts()); for (clang::NamedDecl *decl : m_decls) { Index: lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp =================================================================== --- lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp +++ lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp @@ -78,14 +78,14 @@ // 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( + auto scratch_ast = ScratchTypeSystemClang::GetForTarget( *m_target, ScratchTypeSystemClang::DefaultAST, false); if (!scratch_ast) return; ScratchTypeSystemClang *default_scratch_ast = - llvm::cast(scratch_ast); + llvm::cast(scratch_ast.get()); // Unregister from the default scratch AST (and all sub-ASTs). default_scratch_ast->ForgetSource(m_ast_context, *m_ast_importer_sp); } Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h =================================================================== --- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h +++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h @@ -12,6 +12,7 @@ #include #include +#include #include #include "ClangASTSource.h" @@ -377,7 +378,7 @@ /// Deallocate struct variables void DisableStructVars() { m_struct_vars.reset(); } - TypeSystemClang *GetScratchContext(Target &target) { + std::shared_ptr GetScratchContext(Target &target) { return ScratchTypeSystemClang::GetForTarget(target, m_ast_context->getLangOpts()); } Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp =================================================================== --- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -205,7 +205,7 @@ 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); @@ -242,7 +242,7 @@ if (target == nullptr) return false; - auto *clang_ast_context = GetScratchContext(*target); + auto clang_ast_context = GetScratchContext(*target); if (!clang_ast_context) return false; @@ -280,7 +280,7 @@ if (target == nullptr) return false; - TypeSystemClang *context = GetScratchContext(*target); + auto context = GetScratchContext(*target); if (!context) return false; @@ -1728,7 +1728,7 @@ if (target == nullptr) return; - TypeSystemClang *scratch_ast_context = GetScratchContext(*target); + auto scratch_ast_context = GetScratchContext(*target); if (!scratch_ast_context) return; Index: lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h =================================================================== --- lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h +++ lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h @@ -69,7 +69,7 @@ GetCompilerTypeFromPersistentDecl(ConstString type_name) override; void RegisterPersistentDecl(ConstString name, clang::NamedDecl *decl, - TypeSystemClang *ctx); + std::shared_ptr ctx); clang::NamedDecl *GetPersistentDecl(ConstString name); Index: lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp =================================================================== --- lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp +++ lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp @@ -20,6 +20,7 @@ #include "clang/AST/Decl.h" #include "llvm/ADT/StringMap.h" +#include using namespace lldb; using namespace lldb_private; @@ -84,15 +85,15 @@ 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 ctx) { + PersistentDecl p = {decl, ctx}; m_persistent_decls.insert(std::make_pair(name.GetCString(), p)); if (clang::EnumDecl *enum_decl = llvm::dyn_cast(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)); } Index: lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp =================================================================== --- lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -852,7 +852,7 @@ return false; // std::wstring::size() is measured in 'characters', not bytes - TypeSystemClang *ast_context = + auto ast_context = ScratchTypeSystemClang::GetForTarget(*valobj.GetTargetSP()); if (!ast_context) return false; Index: lldb/source/Plugins/Language/ObjC/NSArray.cpp =================================================================== --- lldb/source/Plugins/Language/ObjC/NSArray.cpp +++ lldb/source/Plugins/Language/ObjC/NSArray.cpp @@ -463,7 +463,7 @@ NSArrayMSyntheticFrontEndBase(lldb::ValueObjectSP valobj_sp) : SyntheticChildrenFrontEnd(*valobj_sp), m_exe_ctx_ref(), m_id_type() { if (valobj_sp) { - auto *clang_ast_context = ScratchTypeSystemClang::GetForTarget( + auto clang_ast_context = ScratchTypeSystemClang::GetForTarget( *valobj_sp->GetExecutionContextRef().GetTargetSP()); if (clang_ast_context) m_id_type = CompilerType( @@ -609,7 +609,7 @@ if (valobj_sp) { CompilerType type = valobj_sp->GetCompilerType(); if (type) { - auto *clang_ast_context = ScratchTypeSystemClang::GetForTarget( + auto clang_ast_context = ScratchTypeSystemClang::GetForTarget( *valobj_sp->GetExecutionContextRef().GetTargetSP()); if (clang_ast_context) m_id_type = clang_ast_context->GetType( @@ -776,7 +776,7 @@ static const ConstString g_zero("[0]"); if (idx == 0) { - auto *clang_ast_context = + auto clang_ast_context = ScratchTypeSystemClang::GetForTarget(*m_backend.GetTargetSP()); if (clang_ast_context) { CompilerType id_type( Index: lldb/source/Plugins/Language/ObjC/NSDictionary.cpp =================================================================== --- lldb/source/Plugins/Language/ObjC/NSDictionary.cpp +++ lldb/source/Plugins/Language/ObjC/NSDictionary.cpp @@ -66,8 +66,7 @@ static CompilerType GetLLDBNSPairType(TargetSP target_sp) { CompilerType compiler_type; - TypeSystemClang *target_ast_context = - ScratchTypeSystemClang::GetForTarget(*target_sp); + auto target_ast_context = ScratchTypeSystemClang::GetForTarget(*target_sp); if (target_ast_context) { ConstString g_lldb_autogen_nspair("__lldb_autogen_nspair"); Index: lldb/source/Plugins/Language/ObjC/NSException.cpp =================================================================== --- lldb/source/Plugins/Language/ObjC/NSException.cpp +++ lldb/source/Plugins/Language/ObjC/NSException.cpp @@ -69,7 +69,7 @@ InferiorSizedWord userinfo_isw(userinfo, *process_sp); InferiorSizedWord reserved_isw(reserved, *process_sp); - auto *clang_ast_context = + auto clang_ast_context = ScratchTypeSystemClang::GetForTarget(process_sp->GetTarget()); if (!clang_ast_context) return false; Index: lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp =================================================================== --- lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp +++ lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp @@ -53,7 +53,7 @@ if (!type_system) return false; - TypeSystemClang *ast = ScratchTypeSystemClang::GetForTarget( + auto ast = ScratchTypeSystemClang::GetForTarget( *m_backend.GetExecutionContextRef().GetTargetSP()); if (!ast) return false; Index: lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp =================================================================== --- lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp +++ lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp @@ -525,7 +525,7 @@ if (!thread_sp->SafeToCallFunctions()) return {}; - TypeSystemClang *clang_ast_context = + auto clang_ast_context = ScratchTypeSystemClang::GetForTarget(m_process->GetTarget()); if (!clang_ast_context) return {}; Index: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp =================================================================== --- lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp +++ lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp @@ -123,8 +123,7 @@ } } else { // If it is not a pointer, see if we can make it into a pointer. - TypeSystemClang *ast_context = - ScratchTypeSystemClang::GetForTarget(*target); + auto ast_context = ScratchTypeSystemClang::GetForTarget(*target); if (!ast_context) return false; @@ -139,7 +138,7 @@ arg_value_list.PushValue(value); // This is the return value: - TypeSystemClang *ast_context = ScratchTypeSystemClang::GetForTarget(*target); + auto ast_context = ScratchTypeSystemClang::GetForTarget(*target); if (!ast_context) return false; @@ -521,7 +520,7 @@ if (!reserved_dict) return FailExceptionParsing("Failed to get synthetic value."); - TypeSystemClang *clang_ast_context = + auto clang_ast_context = ScratchTypeSystemClang::GetForTarget(*exception_sp->GetTargetSP()); if (!clang_ast_context) return FailExceptionParsing("Failed to get scratch AST."); Index: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp =================================================================== --- lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -1627,8 +1627,7 @@ LLDB_LOG(log, "Creating utility function {0}", name); - TypeSystemClang *ast = - ScratchTypeSystemClang::GetForTarget(exe_ctx.GetTargetRef()); + auto ast = ScratchTypeSystemClang::GetForTarget(exe_ctx.GetTargetRef()); if (!ast) return {}; @@ -1768,8 +1767,7 @@ LLDB_LOG(log, "Creating utility function {0}", g_get_shared_cache_class_info_name); - TypeSystemClang *ast = - ScratchTypeSystemClang::GetForTarget(exe_ctx.GetTargetRef()); + auto ast = ScratchTypeSystemClang::GetForTarget(exe_ctx.GetTargetRef()); if (!ast) return {}; @@ -1879,8 +1877,7 @@ return DescriptorMapUpdateResult::Retry(); thread_sp->CalculateExecutionContext(exe_ctx); - TypeSystemClang *ast = - ScratchTypeSystemClang::GetForTarget(process->GetTarget()); + auto ast = ScratchTypeSystemClang::GetForTarget(process->GetTarget()); if (!ast) return DescriptorMapUpdateResult::Fail(); @@ -2144,8 +2141,7 @@ return DescriptorMapUpdateResult::Retry(); thread_sp->CalculateExecutionContext(exe_ctx); - TypeSystemClang *ast = - ScratchTypeSystemClang::GetForTarget(process->GetTarget()); + auto ast = ScratchTypeSystemClang::GetForTarget(process->GetTarget()); if (!ast) return DescriptorMapUpdateResult::Fail(); @@ -3251,7 +3247,7 @@ if (!abi) return; - TypeSystemClang *clang_ast_context = + auto clang_ast_context = ScratchTypeSystemClang::GetForTarget(process_sp->GetTarget()); if (!clang_ast_context) return; Index: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp =================================================================== --- lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp +++ lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp @@ -416,7 +416,7 @@ Process *process = exe_ctx.GetProcessPtr(); const ABI *abi = process->GetABI().get(); - TypeSystemClang *clang_ast_context = + auto clang_ast_context = ScratchTypeSystemClang::GetForTarget(process->GetTarget()); if (!clang_ast_context) return false; @@ -730,7 +730,7 @@ } // Next make the runner function for our implementation utility function. - TypeSystemClang *clang_ast_context = ScratchTypeSystemClang::GetForTarget( + auto clang_ast_context = ScratchTypeSystemClang::GetForTarget( thread.GetProcess()->GetTarget()); if (!clang_ast_context) return LLDB_INVALID_ADDRESS; @@ -866,8 +866,7 @@ TargetSP target_sp(thread.CalculateTarget()); - TypeSystemClang *clang_ast_context = - ScratchTypeSystemClang::GetForTarget(*target_sp); + auto clang_ast_context = ScratchTypeSystemClang::GetForTarget(*target_sp); if (!clang_ast_context) return ret_plan_sp; Index: lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp =================================================================== --- lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp +++ lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp @@ -626,8 +626,7 @@ FunctionCaller *do_dlopen_function = nullptr; // Fetch the clang types we will need: - TypeSystemClang *ast = - ScratchTypeSystemClang::GetForTarget(process->GetTarget()); + auto ast = ScratchTypeSystemClang::GetForTarget(process->GetTarget()); if (!ast) return nullptr; @@ -876,8 +875,7 @@ Value return_value; // Fetch the clang types we will need: - TypeSystemClang *ast = - ScratchTypeSystemClang::GetForTarget(process->GetTarget()); + auto ast = ScratchTypeSystemClang::GetForTarget(process->GetTarget()); if (!ast) { error.SetErrorString("dlopen error: Unable to get TypeSystemClang"); return LLDB_INVALID_IMAGE_TOKEN; Index: lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp =================================================================== --- lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp +++ lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp @@ -335,12 +335,12 @@ 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 = - ScratchTypeSystemClang::GetForTarget(process->GetTarget()); + auto ast = ScratchTypeSystemClang::GetForTarget(process->GetTarget()); if (!ast) { error.SetErrorString("LoadLibrary error: unable to get (clang) type system"); return LLDB_INVALID_IMAGE_TOKEN; @@ -682,7 +682,7 @@ return nullptr; } - TypeSystemClang *ast = ScratchTypeSystemClang::GetForTarget(target); + auto ast = ScratchTypeSystemClang::GetForTarget(target); if (!ast) return nullptr; Index: lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp =================================================================== --- lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp +++ lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp @@ -221,8 +221,7 @@ lldb::StackFrameSP thread_cur_frame = thread.GetStackFrameAtIndex(0); ProcessSP process_sp(thread.CalculateProcess()); TargetSP target_sp(thread.CalculateTarget()); - TypeSystemClang *clang_ast_context = - ScratchTypeSystemClang::GetForTarget(*target_sp); + auto clang_ast_context = ScratchTypeSystemClang::GetForTarget(*target_sp); Log *log = GetLog(LLDBLog::SystemRuntime); GetItemInfoReturnInfo return_value; Index: lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp =================================================================== --- lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp +++ lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp @@ -164,7 +164,7 @@ // Next make the runner function for our implementation utility function. Status error; - TypeSystemClang *clang_ast_context = ScratchTypeSystemClang::GetForTarget( + auto clang_ast_context = ScratchTypeSystemClang::GetForTarget( thread.GetProcess()->GetTarget()); CompilerType get_pending_items_return_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); @@ -216,8 +216,7 @@ lldb::StackFrameSP thread_cur_frame = thread.GetStackFrameAtIndex(0); ProcessSP process_sp(thread.CalculateProcess()); TargetSP target_sp(thread.CalculateTarget()); - TypeSystemClang *clang_ast_context = - ScratchTypeSystemClang::GetForTarget(*target_sp); + auto clang_ast_context = ScratchTypeSystemClang::GetForTarget(*target_sp); Log *log = GetLog(LLDBLog::SystemRuntime); GetPendingItemsReturnInfo return_value; Index: lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp =================================================================== --- lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp +++ lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp @@ -180,7 +180,7 @@ } // Next make the runner function for our implementation utility function. - TypeSystemClang *clang_ast_context = + auto clang_ast_context = ScratchTypeSystemClang::GetForTarget(thread.GetProcess()->GetTarget()); CompilerType get_queues_return_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); @@ -221,8 +221,7 @@ lldb::StackFrameSP thread_cur_frame = thread.GetStackFrameAtIndex(0); ProcessSP process_sp(thread.CalculateProcess()); TargetSP target_sp(thread.CalculateTarget()); - TypeSystemClang *clang_ast_context = - ScratchTypeSystemClang::GetForTarget(*target_sp); + auto clang_ast_context = ScratchTypeSystemClang::GetForTarget(*target_sp); Log *log = GetLog(LLDBLog::SystemRuntime); GetQueuesReturnInfo return_value; Index: lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp =================================================================== --- lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp +++ lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp @@ -171,7 +171,7 @@ // Also make the FunctionCaller for this UtilityFunction: - TypeSystemClang *clang_ast_context = ScratchTypeSystemClang::GetForTarget( + auto clang_ast_context = ScratchTypeSystemClang::GetForTarget( thread.GetProcess()->GetTarget()); CompilerType get_thread_item_info_return_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); @@ -223,8 +223,7 @@ lldb::StackFrameSP thread_cur_frame = thread.GetStackFrameAtIndex(0); ProcessSP process_sp(thread.CalculateProcess()); TargetSP target_sp(thread.CalculateTarget()); - TypeSystemClang *clang_ast_context = - ScratchTypeSystemClang::GetForTarget(*target_sp); + auto clang_ast_context = ScratchTypeSystemClang::GetForTarget(*target_sp); Log *log = GetLog(LLDBLog::SystemRuntime); GetThreadItemInfoReturnInfo return_value; Index: lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp =================================================================== --- lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp +++ lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp @@ -414,8 +414,7 @@ } #endif - TypeSystemClang *ast_ctx = - ScratchTypeSystemClang::GetForTarget(m_process->GetTarget()); + auto ast_ctx = ScratchTypeSystemClang::GetForTarget(m_process->GetTarget()); if (m_dispatch_tsd_indexes_addr != LLDB_INVALID_ADDRESS) { CompilerType uint16 = ast_ctx->GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, 16); Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h =================================================================== --- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h +++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h @@ -1182,7 +1182,7 @@ /// 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 std::shared_ptr GetForTarget(Target &target, llvm::Optional ast_kind = DefaultAST, bool create_on_demand = true); @@ -1194,8 +1194,8 @@ /// \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 std::shared_ptr + GetForTarget(Target &target, const clang::LangOptions &lang_opts) { return GetForTarget(target, InferIsolatedASTKindFromLangOpts(lang_opts)); } Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp =================================================================== --- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -12,6 +12,7 @@ #include "llvm/Support/FormatVariadic.h" #include +#include #include #include @@ -9921,7 +9922,7 @@ m_scratch_ast_source_up.reset(); } -TypeSystemClang * +std::shared_ptr ScratchTypeSystemClang::GetForTarget(Target &target, llvm::Optional ast_kind, bool create_on_demand) { @@ -9932,16 +9933,17 @@ "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(ts.get()); + llvm::dyn_cast_or_null(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(ts_sp); // Search the sub-ASTs. - return &scratch_ast->GetIsolatedAST(*ast_kind); + return std::static_pointer_cast( + scratch_ast->GetIsolatedAST(*ast_kind).shared_from_this()); } /// Returns a human-readable name that uniquely identifiers the sub-AST kind.