@@ -792,7 +792,7 @@ static void ResolveSpecialNames(
792
792
793
793
// / Initialize the SwiftASTContext and return the wrapped
794
794
// / swift::ASTContext when successful.
795
- static swift::ASTContext *
795
+ static ThreadSafeASTContext
796
796
SetupASTContext (SwiftASTContextForExpressions &swift_ast_context,
797
797
DiagnosticManager &diagnostic_manager,
798
798
std::function<bool ()> disable_objc_runtime, bool repl,
@@ -806,27 +806,27 @@ SetupASTContext(SwiftASTContextForExpressions &swift_ast_context,
806
806
diagnostic_manager.PutString (eSeverityInfo,
807
807
" Couldn't initialize Swift expression "
808
808
" evaluator due to previous errors." );
809
- return nullptr ;
809
+ return ThreadSafeASTContext () ;
810
810
}
811
811
812
812
if (swift_ast_context.HasFatalErrors ()) {
813
813
diagnostic_manager.PutString (eSeverityError,
814
814
" The AST context is in a fatal error state." );
815
- return nullptr ;
815
+ return ThreadSafeASTContext () ;
816
816
}
817
817
818
- swift::ASTContext * ast_context = swift_ast_context.GetASTContext ();
818
+ ThreadSafeASTContext ast_context = swift_ast_context.GetASTContext ();
819
819
if (!ast_context) {
820
820
diagnostic_manager.PutString (
821
821
eSeverityError,
822
822
" Couldn't initialize the AST context. Please check your settings." );
823
- return nullptr ;
823
+ return ThreadSafeASTContext () ;
824
824
}
825
825
826
826
if (swift_ast_context.HasFatalErrors ()) {
827
827
diagnostic_manager.PutString (eSeverityError,
828
828
" The AST context is in a fatal error state." );
829
- return nullptr ;
829
+ return ThreadSafeASTContext () ;
830
830
}
831
831
832
832
// TODO: Find a way to get contraint-solver output sent to a stream
@@ -1126,7 +1126,7 @@ char ModuleImportError::ID = 0;
1126
1126
// / This holds the result of ParseAndImport.
1127
1127
struct ParsedExpression {
1128
1128
std::unique_ptr<SwiftASTManipulator> code_manipulator;
1129
- swift::ASTContext & ast_context;
1129
+ ThreadSafeASTContext ast_context;
1130
1130
swift::ModuleDecl &module ;
1131
1131
LLDBNameLookup &external_lookup;
1132
1132
swift::SourceFile &source_file;
@@ -1293,7 +1293,7 @@ static llvm::Expected<ParsedExpression> ParseAndImport(
1293
1293
return !ObjCLanguageRuntime::Get (*process_sp);
1294
1294
};
1295
1295
1296
- swift::ASTContext * ast_context =
1296
+ ThreadSafeASTContext ast_context =
1297
1297
SetupASTContext (swift_ast_context, diagnostic_manager,
1298
1298
should_disable_objc_runtime, repl, playground);
1299
1299
if (!ast_context)
@@ -1352,7 +1352,7 @@ static llvm::Expected<ParsedExpression> ParseAndImport(
1352
1352
importInfo.AdditionalImports .emplace_back (attributed_import);
1353
1353
1354
1354
auto module_id = ast_context->getIdentifier (expr_name_buf);
1355
- auto &module = *swift::ModuleDecl::create (module_id, *ast_context,
1355
+ auto &module = *swift::ModuleDecl::create (module_id, ** ast_context,
1356
1356
importInfo);
1357
1357
1358
1358
swift::SourceFileKind source_file_kind = swift::SourceFileKind::Library;
@@ -1362,7 +1362,7 @@ static llvm::Expected<ParsedExpression> ParseAndImport(
1362
1362
1363
1363
// Create the source file. Note, we disable delayed parsing for the
1364
1364
// swift expression parser.
1365
- swift::SourceFile *source_file = new (*ast_context)
1365
+ swift::SourceFile *source_file = new (** ast_context)
1366
1366
swift::SourceFile (module , source_file_kind, buffer_id,
1367
1367
swift::SourceFile::ParsingFlags::DisableDelayedBodies);
1368
1368
module .addFile (*source_file);
@@ -1520,8 +1520,13 @@ static llvm::Expected<ParsedExpression> ParseAndImport(
1520
1520
swift::verify (*source_file);
1521
1521
1522
1522
ParsedExpression result = {
1523
- std::move (code_manipulator), *ast_context, module , *external_lookup,
1524
- *source_file, std::move (main_filename), /* buffer_id*/ 0 ,
1523
+ std::move (code_manipulator),
1524
+ std::move (ast_context),
1525
+ module ,
1526
+ *external_lookup,
1527
+ *source_file,
1528
+ std::move (main_filename),
1529
+ /* buffer_id*/ 0 ,
1525
1530
};
1526
1531
return std::move (result);
1527
1532
}
@@ -2140,7 +2145,7 @@ SwiftExpressionParser::Parse(DiagnosticManager &diagnostic_manager,
2140
2145
// part of the parse from the staging area in the external lookup
2141
2146
// object into the SwiftPersistentExpressionState.
2142
2147
swift::ModuleDecl *module = &parsed_expr->module ;
2143
- parsed_expr->ast_context . addLoadedModule (module );
2148
+ parsed_expr->ast_context -> addLoadedModule (module );
2144
2149
m_swift_ast_ctx.CacheModule (module );
2145
2150
if (m_sc.target_sp ) {
2146
2151
auto *persistent_state =
0 commit comments