Skip to content

Commit 0b8c8c6

Browse files
Merge pull request #3963 from adrian-prantl/target-lazy
Make SwiftASTContext initalization in Target lazy (NFC)
2 parents a90bf6a + 0f2634b commit 0b8c8c6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lldb/source/Target/Target.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,7 +1652,7 @@ void Target::ModulesDidLoad(ModuleList &module_list) {
16521652
return true;
16531653
auto *swift_ast_ctx =
16541654
llvm::dyn_cast_or_null<SwiftASTContextForExpressions>(
1655-
swift_scratch_ctx->GetSwiftASTContext());
1655+
swift_scratch_ctx->GetSwiftASTContextOrNull());
16561656
if (!swift_ast_ctx)
16571657
return true;
16581658
swift_ast_ctx->ModulesDidLoad(module_list);
@@ -2288,7 +2288,9 @@ Target::GetScratchTypeSystemForLanguage(lldb::LanguageType language,
22882288
&*type_system_or_err)) {
22892289
auto *swift_ast_ctx =
22902290
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.
22922294
if (swift_ast_ctx && (swift_ast_ctx->CheckProcessChanged() ||
22932295
swift_ast_ctx->HasFatalErrors())) {
22942296
// If it is safe to replace the scratch context, do so. If
@@ -2587,7 +2589,7 @@ llvm::Optional<SwiftScratchContextReader> Target::GetSwiftScratchContext(
25872589
StackFrameSP frame_sp = exe_scope.CalculateStackFrame();
25882590
if (frame_sp && frame_sp.get() && swift_scratch_ctx) {
25892591
auto *swift_ast_ctx = llvm::dyn_cast_or_null<SwiftASTContextForExpressions>(
2590-
swift_scratch_ctx->GetSwiftASTContext());
2592+
swift_scratch_ctx->GetSwiftASTContextOrNull());
25912593
if (swift_ast_ctx && !swift_ast_ctx->HasFatalErrors()) {
25922594
StackFrameWP frame_wp(frame_sp);
25932595
SymbolContext sc =

0 commit comments

Comments
 (0)