Index: include/lldb/Symbol/ClangASTContext.h =================================================================== --- include/lldb/Symbol/ClangASTContext.h +++ include/lldb/Symbol/ClangASTContext.h @@ -58,6 +58,9 @@ void Finalize() override; + static ClangASTContext *GetScratch(Target &target, + bool create_on_demand = true); + // PluginInterface functions ConstString GetPluginName() override; Index: include/lldb/Target/Target.h =================================================================== --- include/lldb/Target/Target.h +++ include/lldb/Target/Target.h @@ -1067,8 +1067,6 @@ const char *name, Status &error); - ClangASTContext *GetScratchClangASTContext(bool create_on_demand = true); - lldb::ClangASTImporterSP GetClangASTImporter(); // Install any files through the platform that need be to installed prior to Index: source/API/SBTarget.cpp =================================================================== --- source/API/SBTarget.cpp +++ source/API/SBTarget.cpp @@ -1858,7 +1858,7 @@ } // No matches, search for basic typename matches - ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext(); + auto *clang_ast = ClangASTContext::GetScratch(*target_sp); if (clang_ast) return LLDB_RECORD_RESULT(SBType(ClangASTContext::GetBasicType( clang_ast->getASTContext(), const_typename))); @@ -1872,7 +1872,7 @@ TargetSP target_sp(GetSP()); if (target_sp) { - ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext(); + auto *clang_ast = ClangASTContext::GetScratch(*target_sp); if (clang_ast) return LLDB_RECORD_RESULT(SBType( ClangASTContext::GetBasicType(clang_ast->getASTContext(), type))); @@ -1918,7 +1918,7 @@ if (sb_type_list.GetSize() == 0) { // No matches, search for basic typename matches - ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext(); + auto *clang_ast = ClangASTContext::GetScratch(*target_sp); if (clang_ast) sb_type_list.Append(SBType(ClangASTContext::GetBasicType( clang_ast->getASTContext(), const_typename))); Index: source/Breakpoint/Watchpoint.cpp =================================================================== --- source/Breakpoint/Watchpoint.cpp +++ source/Breakpoint/Watchpoint.cpp @@ -35,7 +35,7 @@ else { // If we don't have a known type, then we force it to unsigned int of the // right size. - ClangASTContext *ast_context = target.GetScratchClangASTContext(); + auto *ast_context = ClangASTContext::GetScratch(target); m_type = ast_context->GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, 8 * size); } Index: source/Core/DumpDataExtractor.cpp =================================================================== --- source/Core/DumpDataExtractor.cpp +++ source/Core/DumpDataExtractor.cpp @@ -555,7 +555,7 @@ if (exe_scope) target_sp = exe_scope->CalculateTarget(); if (target_sp) { - ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext(); + auto *clang_ast = ClangASTContext::GetScratch(*target_sp); if (clang_ast) { clang::ASTContext *ast = clang_ast->getASTContext(); if (ast) { Index: source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp =================================================================== --- source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp +++ source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp @@ -1034,8 +1034,7 @@ } StackFrameSP frame_sp = thread_sp->GetStackFrameAtIndex(0); if (frame_sp) { - ClangASTContext *clang_ast_context = - target.GetScratchClangASTContext(); + auto *clang_ast_context = ClangASTContext::GetScratch(target); if (!clang_ast_context) return LLDB_INVALID_ADDRESS; Index: source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp =================================================================== --- source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp +++ source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp @@ -223,8 +223,7 @@ // Build up the value array to store the three arguments given above, then // get the values from the ABI: - ClangASTContext *clang_ast_context = - process->GetTarget().GetScratchClangASTContext(); + auto *clang_ast_context = ClangASTContext::GetScratch(process->GetTarget()); ValueList argument_values; Value mode_value; // enum dyld_notify_mode { dyld_notify_adding=0, Index: source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp =================================================================== --- source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp +++ source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp @@ -340,8 +340,7 @@ // Build up the value array to store the three arguments given above, then // get the values from the ABI: - ClangASTContext *clang_ast_context = - process->GetTarget().GetScratchClangASTContext(); + auto *clang_ast_context = ClangASTContext::GetScratch(process->GetTarget()); ValueList argument_values; Value input_value; Index: source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp =================================================================== --- source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp +++ source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp @@ -455,7 +455,7 @@ ConstString name_cs(name.str().c_str()); Decl *D_scratch = m_target.GetClangASTImporter()->DeportDecl( - m_target.GetScratchClangASTContext()->getASTContext(), m_ast_context, + ClangASTContext::GetScratch(m_target)->getASTContext(), m_ast_context, decl); if (!D_scratch) { Index: source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp =================================================================== --- source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp +++ source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp @@ -118,8 +118,8 @@ // Update the scratch AST context's merger to reflect any new sources we // might have come across since the last time an expression was parsed. - auto scratch_ast_context = static_cast( - m_target->GetScratchClangASTContext()); + auto *scratch_ast_context = static_cast( + ClangASTContext::GetScratch(*m_target)); scratch_ast_context->GetMergerUnchecked().AddSources(sources); @@ -142,10 +142,9 @@ m_ast_importer_sp->ForgetDestination(m_ast_context); // We are in the process of destruction, don't create clang ast context on - // demand by passing false to - // Target::GetScratchClangASTContext(create_on_demand). - ClangASTContext *scratch_clang_ast_context = - m_target->GetScratchClangASTContext(false); + // demand by passing false to ClangASTContext::GetScratch(). + auto *scratch_clang_ast_context = + ClangASTContext::GetScratch(*m_target, false); if (!scratch_clang_ast_context) return; Index: source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp =================================================================== --- source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -110,7 +110,7 @@ m_parser_vars->m_persistent_vars = llvm::cast( target->GetPersistentExpressionStateForLanguage(eLanguageTypeC)); - if (!target->GetScratchClangASTContext()) + if (!ClangASTContext::GetScratch(*target)) return false; } @@ -286,7 +286,7 @@ TypeFromUser ClangExpressionDeclMap::DeportType(ClangASTContext &target, ClangASTContext &source, TypeFromParser parser_type) { - assert (&target == m_target->GetScratchClangASTContext()); + assert(&target == ClangASTContext::GetScratch(*m_target)); assert ((TypeSystem*)&source == parser_type.GetTypeSystem()); assert (source.getASTContext() == m_ast_context); @@ -299,8 +299,8 @@ clang::FileID source_file = source.getASTContext()->getSourceManager().getFileID( source.getASTContext()->getTranslationUnitDecl()->getLocation()); - auto scratch_ast_context = static_cast( - m_target->GetScratchClangASTContext()); + auto scratch_ast_context = static_cast( + ClangASTContext::GetScratch(*m_target)); clang::QualType exported_type = ExportAllDeclaredTypes( scratch_ast_context->GetMergerUnchecked(), *source.getASTContext(), *source.getFileManager(), @@ -335,7 +335,7 @@ return false; TypeFromUser user_type = - DeportType(*target->GetScratchClangASTContext(), *ast, parser_type); + DeportType(*ClangASTContext::GetScratch(*target), *ast, parser_type); uint32_t offset = m_parser_vars->m_materializer->AddResultVariable( user_type, is_lvalue, m_keep_result_in_memory, m_result_delegate, err); @@ -370,7 +370,7 @@ if (target == nullptr) return false; - ClangASTContext *context(target->GetScratchClangASTContext()); + auto *context(ClangASTContext::GetScratch(*target)); TypeFromUser user_type = DeportType(*context, *ast, parser_type); @@ -888,8 +888,7 @@ if (!target) break; - ClangASTContext *scratch_clang_ast_context = - target->GetScratchClangASTContext(); + auto *scratch_clang_ast_context = ClangASTContext::GetScratch(*target); if (!scratch_clang_ast_context) break; @@ -1807,7 +1806,7 @@ return; ASTContext *scratch_ast_context = - target->GetScratchClangASTContext()->getASTContext(); + ClangASTContext::GetScratch(*target)->getASTContext(); TypeFromUser user_type( ClangASTContext::GetBasicType(scratch_ast_context, eBasicTypeVoid) @@ -1857,9 +1856,8 @@ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr(); - ClangASTContextForExpressions *scratch_ast_context = - static_cast( - target->GetScratchClangASTContext()); + auto *scratch_ast_context = static_cast( + ClangASTContext::GetScratch(*target)); for (size_t index = 0, num_entities = m_found_entities.GetSize(); index < num_entities; ++index) { Index: source/Plugins/Language/CPlusPlus/LibCxx.cpp =================================================================== --- source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -572,8 +572,7 @@ location_sp->GetPointeeData(extractor, 0, size); // std::wstring::size() is measured in 'characters', not bytes - auto wchar_t_size = valobj.GetTargetSP() - ->GetScratchClangASTContext() + auto wchar_t_size = ClangASTContext::GetScratch(*(valobj.GetTargetSP())) ->GetBasicType(lldb::eBasicTypeWChar) .GetByteSize(nullptr); if (!wchar_t_size) Index: source/Plugins/Language/ObjC/NSArray.cpp =================================================================== --- source/Plugins/Language/ObjC/NSArray.cpp +++ source/Plugins/Language/ObjC/NSArray.cpp @@ -461,10 +461,10 @@ : SyntheticChildrenFrontEnd(*valobj_sp), m_exe_ctx_ref(), m_ptr_size(8), m_id_type() { if (valobj_sp) { - clang::ASTContext *ast = valobj_sp->GetExecutionContextRef() - .GetTargetSP() - ->GetScratchClangASTContext() - ->getASTContext(); + clang::ASTContext *ast = + ClangASTContext::GetScratch( + *(valobj_sp->GetExecutionContextRef().GetTargetSP())) + ->getASTContext(); if (ast) m_id_type = CompilerType(ast, ast->ObjCBuiltinIdTy); if (valobj_sp->GetProcessSP()) @@ -609,9 +609,8 @@ if (valobj_sp) { CompilerType type = valobj_sp->GetCompilerType(); if (type) { - ClangASTContext *ast = valobj_sp->GetExecutionContextRef() - .GetTargetSP() - ->GetScratchClangASTContext(); + auto *ast = ClangASTContext::GetScratch( + *(valobj_sp->GetExecutionContextRef().GetTargetSP())); if (ast) m_id_type = CompilerType(ast->getASTContext(), ast->getASTContext()->ObjCBuiltinIdTy); @@ -778,9 +777,8 @@ static const ConstString g_zero("[0]"); if (idx == 0) { - CompilerType id_type( - m_backend.GetTargetSP()->GetScratchClangASTContext()->GetBasicType( - lldb::eBasicTypeObjCID)); + CompilerType id_type(ClangASTContext::GetScratch(*(m_backend.GetTargetSP())) + ->GetBasicType(lldb::eBasicTypeObjCID)); return m_backend.GetSyntheticChildAtOffset( m_backend.GetProcessSP()->GetAddressByteSize(), id_type, true, g_zero); } Index: source/Plugins/Language/ObjC/NSDictionary.cpp =================================================================== --- source/Plugins/Language/ObjC/NSDictionary.cpp +++ source/Plugins/Language/ObjC/NSDictionary.cpp @@ -65,7 +65,7 @@ static CompilerType GetLLDBNSPairType(TargetSP target_sp) { CompilerType compiler_type; - ClangASTContext *target_ast_context = target_sp->GetScratchClangASTContext(); + auto *target_ast_context = ClangASTContext::GetScratch(*target_sp); if (target_ast_context) { ConstString g___lldb_autogen_nspair("__lldb_autogen_nspair"); Index: source/Plugins/Language/ObjC/NSError.cpp =================================================================== --- source/Plugins/Language/ObjC/NSError.cpp +++ source/Plugins/Language/ObjC/NSError.cpp @@ -86,10 +86,10 @@ ValueObjectSP domain_str_sp = ValueObject::CreateValueObjectFromData( "domain_str", isw.GetAsData(process_sp->GetByteOrder()), - valobj.GetExecutionContextRef(), process_sp->GetTarget() - .GetScratchClangASTContext() - ->GetBasicType(lldb::eBasicTypeVoid) - .GetPointerType()); + valobj.GetExecutionContextRef(), + ClangASTContext::GetScratch(process_sp->GetTarget()) + ->GetBasicType(lldb::eBasicTypeVoid) + .GetPointerType()); if (!domain_str_sp) return false; @@ -156,8 +156,8 @@ m_child_sp = CreateValueObjectFromData( "_userInfo", isw.GetAsData(process_sp->GetByteOrder()), m_backend.GetExecutionContextRef(), - process_sp->GetTarget().GetScratchClangASTContext()->GetBasicType( - lldb::eBasicTypeObjCID)); + ClangASTContext::GetScratch(process_sp->GetTarget()) + ->GetBasicType(lldb::eBasicTypeObjCID)); return false; } Index: source/Plugins/Language/ObjC/NSException.cpp =================================================================== --- source/Plugins/Language/ObjC/NSException.cpp +++ source/Plugins/Language/ObjC/NSException.cpp @@ -69,8 +69,7 @@ InferiorSizedWord userinfo_isw(userinfo, *process_sp); InferiorSizedWord reserved_isw(reserved, *process_sp); - CompilerType voidstar = process_sp->GetTarget() - .GetScratchClangASTContext() + CompilerType voidstar = ClangASTContext::GetScratch(process_sp->GetTarget()) ->GetBasicType(lldb::eBasicTypeVoid) .GetPointerType(); Index: source/Plugins/Language/ObjC/NSIndexPath.cpp =================================================================== --- source/Plugins/Language/ObjC/NSIndexPath.cpp +++ source/Plugins/Language/ObjC/NSIndexPath.cpp @@ -53,9 +53,8 @@ if (!type_system) return false; - ClangASTContext *ast = m_backend.GetExecutionContextRef() - .GetTargetSP() - ->GetScratchClangASTContext(); + auto *ast = ClangASTContext::GetScratch( + *m_backend.GetExecutionContextRef().GetTargetSP()); if (!ast) return false; Index: source/Plugins/Language/ObjC/NSString.cpp =================================================================== --- source/Plugins/Language/ObjC/NSString.cpp +++ source/Plugins/Language/ObjC/NSString.cpp @@ -35,7 +35,7 @@ static CompilerType GetNSPathStore2Type(Target &target) { static ConstString g_type_name("__lldb_autogen_nspathstore2"); - ClangASTContext *ast_ctx = target.GetScratchClangASTContext(); + auto *ast_ctx = ClangASTContext::GetScratch(target); if (!ast_ctx) return CompilerType(); Index: source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp =================================================================== --- source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp +++ source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp @@ -543,8 +543,7 @@ if (!thread_sp->SafeToCallFunctions()) return {}; - ClangASTContext *clang_ast_context = - m_process->GetTarget().GetScratchClangASTContext(); + auto *clang_ast_context = ClangASTContext::GetScratch(m_process->GetTarget()); CompilerType voidstar = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); Index: source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp =================================================================== --- source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp +++ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp @@ -111,7 +111,7 @@ } } else { // If it is not a pointer, see if we can make it into a pointer. - ClangASTContext *ast_context = target->GetScratchClangASTContext(); + auto *ast_context = ClangASTContext::GetScratch(*target); CompilerType opaque_type = ast_context->GetBasicType(eBasicTypeObjCID); if (!opaque_type) opaque_type = ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); @@ -123,7 +123,7 @@ arg_value_list.PushValue(value); // This is the return value: - ClangASTContext *ast_context = target->GetScratchClangASTContext(); + auto *ast_context = ClangASTContext::GetScratch(*target); CompilerType return_compiler_type = ast_context->GetCStringType(true); Value ret; @@ -490,8 +490,8 @@ if (!reserved_dict) return ThreadSP(); CompilerType objc_id = - exception_sp->GetTargetSP()->GetScratchClangASTContext()->GetBasicType( - lldb::eBasicTypeObjCID); + ClangASTContext::GetScratch(*(exception_sp->GetTargetSP())) + ->GetBasicType(lldb::eBasicTypeObjCID); ValueObjectSP return_addresses; auto objc_object_from_address = [&exception_sp, &objc_id](uint64_t addr, Index: source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp =================================================================== --- source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -1301,7 +1301,7 @@ return DescriptorMapUpdateResult::Fail(); thread_sp->CalculateExecutionContext(exe_ctx); - ClangASTContext *ast = process->GetTarget().GetScratchClangASTContext(); + auto *ast = ClangASTContext::GetScratch(process->GetTarget()); if (!ast) return DescriptorMapUpdateResult::Fail(); @@ -1565,7 +1565,7 @@ return DescriptorMapUpdateResult::Fail(); thread_sp->CalculateExecutionContext(exe_ctx); - ClangASTContext *ast = process->GetTarget().GetScratchClangASTContext(); + auto *ast = ClangASTContext::GetScratch(process->GetTarget()); if (!ast) return DescriptorMapUpdateResult::Fail(); @@ -2684,8 +2684,7 @@ const lldb::ABISP &abi = process_sp->GetABI(); if (!abi) return; - CompilerType voidstar = process_sp->GetTarget() - .GetScratchClangASTContext() + CompilerType voidstar = ClangASTContext::GetScratch(process_sp->GetTarget()) ->GetBasicType(lldb::eBasicTypeVoid) .GetPointerType(); Index: source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp =================================================================== --- source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp +++ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp @@ -522,7 +522,7 @@ const ABI *abi = process->GetABI().get(); ClangASTContext *clang_ast_context = - process->GetTarget().GetScratchClangASTContext(); + ClangASTContext::GetScratch(process->GetTarget()); ValueList argument_values; Value input_value; CompilerType clang_void_ptr_type = @@ -803,7 +803,7 @@ // Next make the runner function for our implementation utility function. ClangASTContext *clang_ast_context = - thread.GetProcess()->GetTarget().GetScratchClangASTContext(); + ClangASTContext::GetScratch(thread.GetProcess()->GetTarget()); CompilerType clang_void_ptr_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); Status error; @@ -897,7 +897,7 @@ TargetSP target_sp(thread.CalculateTarget()); - ClangASTContext *clang_ast_context = target_sp->GetScratchClangASTContext(); + auto *clang_ast_context = ClangASTContext::GetScratch(*target_sp); ValueList argument_values; Value void_ptr_value; CompilerType clang_void_ptr_type = Index: source/Plugins/Platform/POSIX/PlatformPOSIX.cpp =================================================================== --- source/Plugins/Platform/POSIX/PlatformPOSIX.cpp +++ source/Plugins/Platform/POSIX/PlatformPOSIX.cpp @@ -712,7 +712,7 @@ FunctionCaller *do_dlopen_function = nullptr; // Fetch the clang types we will need: - ClangASTContext *ast = process->GetTarget().GetScratchClangASTContext(); + auto *ast = ClangASTContext::GetScratch(process->GetTarget()); CompilerType clang_void_pointer_type = ast->GetBasicType(eBasicTypeVoid).GetPointerType(); @@ -947,7 +947,7 @@ Value return_value; // Fetch the clang types we will need: - ClangASTContext *ast = process->GetTarget().GetScratchClangASTContext(); + auto *ast = ClangASTContext::GetScratch(process->GetTarget()); CompilerType clang_void_pointer_type = ast->GetBasicType(eBasicTypeVoid).GetPointerType(); Index: source/Plugins/Process/Utility/InferiorCallPOSIX.cpp =================================================================== --- source/Plugins/Process/Utility/InferiorCallPOSIX.cpp +++ source/Plugins/Process/Utility/InferiorCallPOSIX.cpp @@ -79,8 +79,7 @@ AddressRange mmap_range; if (sc.GetAddressRange(range_scope, 0, use_inline_block_range, mmap_range)) { - ClangASTContext *clang_ast_context = - process->GetTarget().GetScratchClangASTContext(); + auto *clang_ast_context = ClangASTContext::GetScratch(process->GetTarget()); CompilerType clang_void_ptr_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); const ArchSpec arch = process->GetTarget().GetArchitecture(); @@ -200,8 +199,7 @@ options.SetTimeout(process->GetUtilityExpressionTimeout()); options.SetTrapExceptions(trap_exceptions); - ClangASTContext *clang_ast_context = - process->GetTarget().GetScratchClangASTContext(); + auto *clang_ast_context = ClangASTContext::GetScratch(process->GetTarget()); CompilerType clang_void_ptr_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); lldb::ThreadPlanSP call_plan_sp( Index: source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp =================================================================== --- source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp +++ source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp @@ -228,7 +228,7 @@ lldb::StackFrameSP thread_cur_frame = thread.GetStackFrameAtIndex(0); ProcessSP process_sp(thread.CalculateProcess()); TargetSP target_sp(thread.CalculateTarget()); - ClangASTContext *clang_ast_context = target_sp->GetScratchClangASTContext(); + auto *clang_ast_context = ClangASTContext::GetScratch(*target_sp); Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYSTEM_RUNTIME)); GetItemInfoReturnInfo return_value; Index: source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp =================================================================== --- source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp +++ source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp @@ -177,8 +177,8 @@ // Next make the runner function for our implementation utility function. Status error; - ClangASTContext *clang_ast_context = - thread.GetProcess()->GetTarget().GetScratchClangASTContext(); + auto *clang_ast_context = + ClangASTContext::GetScratch(thread.GetProcess()->GetTarget()); CompilerType get_pending_items_return_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); get_pending_items_caller = @@ -230,7 +230,7 @@ lldb::StackFrameSP thread_cur_frame = thread.GetStackFrameAtIndex(0); ProcessSP process_sp(thread.CalculateProcess()); TargetSP target_sp(thread.CalculateTarget()); - ClangASTContext *clang_ast_context = target_sp->GetScratchClangASTContext(); + auto *clang_ast_context = ClangASTContext::GetScratch(*target_sp); Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYSTEM_RUNTIME)); GetPendingItemsReturnInfo return_value; Index: source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp =================================================================== --- source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp +++ source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp @@ -190,8 +190,8 @@ } // Next make the runner function for our implementation utility function. - ClangASTContext *clang_ast_context = - thread.GetProcess()->GetTarget().GetScratchClangASTContext(); + auto *clang_ast_context = + ClangASTContext::GetScratch(thread.GetProcess()->GetTarget()); CompilerType get_queues_return_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); Status error; @@ -232,7 +232,7 @@ lldb::StackFrameSP thread_cur_frame = thread.GetStackFrameAtIndex(0); ProcessSP process_sp(thread.CalculateProcess()); TargetSP target_sp(thread.CalculateTarget()); - ClangASTContext *clang_ast_context = target_sp->GetScratchClangASTContext(); + auto *clang_ast_context = ClangASTContext::GetScratch(*target_sp); Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYSTEM_RUNTIME)); GetQueuesReturnInfo return_value; Index: source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp =================================================================== --- source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp +++ source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp @@ -186,8 +186,8 @@ // Also make the FunctionCaller for this UtilityFunction: - ClangASTContext *clang_ast_context = - thread.GetProcess()->GetTarget().GetScratchClangASTContext(); + auto *clang_ast_context = + ClangASTContext::GetScratch(thread.GetProcess()->GetTarget()); CompilerType get_thread_item_info_return_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); @@ -238,7 +238,7 @@ lldb::StackFrameSP thread_cur_frame = thread.GetStackFrameAtIndex(0); ProcessSP process_sp(thread.CalculateProcess()); TargetSP target_sp(thread.CalculateTarget()); - ClangASTContext *clang_ast_context = target_sp->GetScratchClangASTContext(); + auto *clang_ast_context = ClangASTContext::GetScratch(*target_sp); Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYSTEM_RUNTIME)); GetThreadItemInfoReturnInfo return_value; Index: source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp =================================================================== --- source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp +++ source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp @@ -411,8 +411,7 @@ } #endif - ClangASTContext *ast_ctx = - m_process->GetTarget().GetScratchClangASTContext(); + auto *ast_ctx = ClangASTContext::GetScratch(m_process->GetTarget()); if (ast_ctx->getASTContext() && m_dispatch_tsd_indexes_addr != LLDB_INVALID_ADDRESS) { CompilerType uint16 = Index: source/Symbol/ClangASTContext.cpp =================================================================== --- source/Symbol/ClangASTContext.cpp +++ source/Symbol/ClangASTContext.cpp @@ -331,6 +331,13 @@ return *g_map_ptr; } +ClangASTContext *ClangASTContext::GetScratch(Target &target, + bool create_on_demand) { + return llvm::cast_or_null( + target.GetScratchTypeSystemForLanguage(nullptr, eLanguageTypeC, + create_on_demand)); +} + bool ClangASTContext::IsOperator(const char *name, clang::OverloadedOperatorKind &op_kind) { if (name == nullptr || name[0] == '\0') Index: source/Target/Target.cpp =================================================================== --- source/Target/Target.cpp +++ source/Target/Target.cpp @@ -27,6 +27,7 @@ #include "lldb/Core/StreamFile.h" #include "lldb/Core/StructuredDataImpl.h" #include "lldb/Core/ValueObject.h" +#include "lldb/Expression/ExpressionVariable.h" #include "lldb/Expression/REPL.h" #include "lldb/Expression/UserExpression.h" #include "lldb/Host/Host.h" @@ -36,7 +37,6 @@ #include "lldb/Interpreter/OptionGroupWatchpoint.h" #include "lldb/Interpreter/OptionValues.h" #include "lldb/Interpreter/Property.h" -#include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/ClangASTImporter.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/ObjectFile.h" @@ -2293,15 +2293,6 @@ return utility_fn; } -ClangASTContext *Target::GetScratchClangASTContext(bool create_on_demand) { - if (m_valid) { - if (TypeSystem *type_system = GetScratchTypeSystemForLanguage( - nullptr, eLanguageTypeC, create_on_demand)) - return llvm::dyn_cast(type_system); - } - return nullptr; -} - ClangASTImporterSP Target::GetClangASTImporter() { if (m_valid) { if (!m_ast_importer_sp) {