@@ -1444,9 +1444,13 @@ SwiftLanguageRuntime::MetadataPromise::FulfillTypePromise(Status *error) {
14441444 if (m_compiler_type.hasValue ())
14451445 return m_compiler_type.getValue ();
14461446
1447- auto swift_ast_ctx = m_for_object_sp->GetScratchSwiftASTContext ();
1447+ TargetSP target_sp = m_for_object_sp->GetTargetSP ();
1448+ Status type_system_error;
1449+ auto swift_ast_ctx =
1450+ target_sp->GetScratchSwiftASTContext (type_system_error, *m_for_object_sp);
14481451 if (!swift_ast_ctx) {
1449- error->SetErrorString (" couldn't get Swift scratch context" );
1452+ error->SetErrorStringWithFormat (" couldn't get Swift scratch context: %s" ,
1453+ type_system_error.AsCString ());
14501454 return CompilerType ();
14511455 }
14521456 auto &remote_ast = m_swift_runtime.GetRemoteASTContext (*swift_ast_ctx);
@@ -1486,9 +1490,13 @@ SwiftLanguageRuntime::MetadataPromise::FulfillKindPromise(Status *error) {
14861490 if (m_metadata_kind.hasValue ())
14871491 return m_metadata_kind;
14881492
1489- auto swift_ast_ctx = m_for_object_sp->GetScratchSwiftASTContext ();
1493+ TargetSP target_sp = m_for_object_sp->GetTargetSP ();
1494+ Status type_system_error;
1495+ auto swift_ast_ctx =
1496+ target_sp->GetScratchSwiftASTContext (type_system_error, *m_for_object_sp);
14901497 if (!swift_ast_ctx) {
1491- error->SetErrorString (" couldn't get Swift scratch context" );
1498+ error->SetErrorStringWithFormat (" couldn't get Swift scratch context: %s" ,
1499+ type_system_error.AsCString ());
14921500 return llvm::None;
14931501 }
14941502 auto &remote_ast = m_swift_runtime.GetRemoteASTContext (*swift_ast_ctx);
@@ -1530,8 +1538,10 @@ bool SwiftLanguageRuntime::MetadataPromise::IsStaticallyDetermined() {
15301538SwiftLanguageRuntime::MetadataPromiseSP
15311539SwiftLanguageRuntime::GetMetadataPromise (lldb::addr_t addr,
15321540 ValueObject &for_object) {
1533- auto swift_ast_ctx = for_object.GetScratchSwiftASTContext ();
1534- if (!swift_ast_ctx || swift_ast_ctx->HasFatalErrors ())
1541+ Status error;
1542+ auto swift_ast_ctx =
1543+ m_process->GetTarget ().GetScratchSwiftASTContext (error, for_object);
1544+ if (!error.Success () || swift_ast_ctx->HasFatalErrors ())
15351545 return nullptr ;
15361546
15371547 if (addr == 0 || addr == LLDB_INVALID_ADDRESS)
@@ -1619,8 +1629,9 @@ SwiftLanguageRuntime::GetMemberVariableOffset(CompilerType instance_type,
16191629
16201630 llvm::Optional<SwiftASTContextReader> scratch_ctx;
16211631 if (instance) {
1622- scratch_ctx = instance->GetScratchSwiftASTContext ();
1623- if (!scratch_ctx)
1632+ Status error;
1633+ scratch_ctx = m_process->GetTarget ().GetScratchSwiftASTContext (error, *instance);
1634+ if (!error.Success ())
16241635 return llvm::None;
16251636 }
16261637
@@ -2350,8 +2361,10 @@ bool SwiftLanguageRuntime::GetDynamicTypeAndAddress(
23502361 // use the scratch context where such operations are legal and safe.
23512362 assert (IsScratchContextLocked (in_value.GetTargetSP ()) &&
23522363 " Swift scratch context not locked ahead of dynamic type resolution" );
2353- auto scratch_ctx = in_value.GetScratchSwiftASTContext ();
2354- if (!scratch_ctx)
2364+ Status error;
2365+ auto scratch_ctx =
2366+ m_process->GetTarget ().GetScratchSwiftASTContext (error, in_value);
2367+ if (!error.Success ())
23552368 return false ;
23562369
23572370 auto retry_once = [&]() {
@@ -3748,7 +3761,9 @@ SwiftLanguageRuntime::GetBridgedSyntheticChildProvider(ValueObject &valobj) {
37483761 ProjectionSyntheticChildren::TypeProjectionUP type_projection (
37493762 new ProjectionSyntheticChildren::TypeProjectionUP::element_type ());
37503763
3751- if (auto swift_ast_ctx = valobj.GetScratchSwiftASTContext ()) {
3764+ Status type_system_error;
3765+ auto swift_ast_ctx = m_process->GetTarget ().GetScratchSwiftASTContext (type_system_error, valobj);
3766+ if (type_system_error.Success ()) {
37523767 Status error;
37533768 CompilerType swift_type =
37543769 swift_ast_ctx->GetTypeFromMangledTypename (type_name, error);
0 commit comments