@@ -1652,7 +1652,7 @@ void Target::ModulesDidLoad(ModuleList &module_list) {
1652
1652
return true ;
1653
1653
auto *swift_ast_ctx =
1654
1654
llvm::dyn_cast_or_null<SwiftASTContextForExpressions>(
1655
- swift_scratch_ctx->GetSwiftASTContext ());
1655
+ swift_scratch_ctx->GetSwiftASTContextOrNull ());
1656
1656
if (!swift_ast_ctx)
1657
1657
return true ;
1658
1658
swift_ast_ctx->ModulesDidLoad (module_list);
@@ -2288,7 +2288,9 @@ Target::GetScratchTypeSystemForLanguage(lldb::LanguageType language,
2288
2288
&*type_system_or_err)) {
2289
2289
auto *swift_ast_ctx =
2290
2290
llvm::dyn_cast_or_null<SwiftASTContextForExpressions>(
2291
- swift_scratch_ctx->GetSwiftASTContext ());
2291
+ swift_scratch_ctx->GetSwiftASTContextOrNull ());
2292
+ // Replace the scratch context if it contains fatal errors or
2293
+ // needs to be replaced because new lldb::Modules were loaded.
2292
2294
if (swift_ast_ctx && (swift_ast_ctx->CheckProcessChanged () ||
2293
2295
swift_ast_ctx->HasFatalErrors ())) {
2294
2296
// If it is safe to replace the scratch context, do so. If
@@ -2587,7 +2589,7 @@ llvm::Optional<SwiftScratchContextReader> Target::GetSwiftScratchContext(
2587
2589
StackFrameSP frame_sp = exe_scope.CalculateStackFrame ();
2588
2590
if (frame_sp && frame_sp.get () && swift_scratch_ctx) {
2589
2591
auto *swift_ast_ctx = llvm::dyn_cast_or_null<SwiftASTContextForExpressions>(
2590
- swift_scratch_ctx->GetSwiftASTContext ());
2592
+ swift_scratch_ctx->GetSwiftASTContextOrNull ());
2591
2593
if (swift_ast_ctx && !swift_ast_ctx->HasFatalErrors ()) {
2592
2594
StackFrameWP frame_wp (frame_sp);
2593
2595
SymbolContext sc =
0 commit comments