@@ -774,9 +774,8 @@ static void ResolveSpecialNames(
774
774
}
775
775
}
776
776
777
- ThreadSafeASTContext SwiftExpressionParser::GetASTContext (
778
- DiagnosticManager &diagnostic_manager,
779
- std::function<bool ()> disable_objc_runtime, bool repl, bool playground) {
777
+ ThreadSafeASTContext
778
+ SwiftExpressionParser::GetASTContext (DiagnosticManager &diagnostic_manager) {
780
779
llvm::call_once (m_ast_init_once_flag, [&] {
781
780
// Lazily get the clang importer if we can to make sure it exists in
782
781
// case we need it.
@@ -810,6 +809,8 @@ ThreadSafeASTContext SwiftExpressionParser::GetASTContext(
810
809
return ;
811
810
}
812
811
812
+ bool repl = m_options.GetREPLEnabled ();
813
+ bool playground = m_options.GetPlaygroundTransformEnabled ();
813
814
// TODO: Find a way to get contraint-solver output sent to a stream
814
815
// so we can log it.
815
816
// swift_ast_context.GetLanguageOptions().DebugConstraintSolver = true;
@@ -820,7 +821,16 @@ ThreadSafeASTContext SwiftExpressionParser::GetASTContext(
820
821
(repl || playground);
821
822
m_swift_ast_ctx.GetLanguageOptions ().EnableTargetOSChecking = false ;
822
823
823
- if (disable_objc_runtime ())
824
+ auto should_disable_objc_runtime = [&]() {
825
+ lldb::StackFrameSP this_frame_sp (m_stack_frame_wp.lock ());
826
+ if (!this_frame_sp)
827
+ return false ;
828
+ lldb::ProcessSP process_sp (this_frame_sp->CalculateProcess ());
829
+ if (!process_sp)
830
+ return false ;
831
+ return !ObjCLanguageRuntime::Get (*process_sp);
832
+ };
833
+ if (should_disable_objc_runtime ())
824
834
m_swift_ast_ctx.GetLanguageOptions ().EnableObjCInterop = false ;
825
835
826
836
m_swift_ast_ctx.GetLanguageOptions ().Playground = repl || playground;
@@ -1245,25 +1255,16 @@ llvm::Expected<SwiftExpressionParser::ParsedExpression>
1245
1255
SwiftExpressionParser::ParseAndImport (
1246
1256
SwiftASTContext::ScopedDiagnostics &expr_diagnostics,
1247
1257
SwiftExpressionParser::SILVariableMap &variable_map, unsigned &buffer_id,
1248
- DiagnosticManager &diagnostic_manager, bool repl, bool playground ) {
1258
+ DiagnosticManager &diagnostic_manager) {
1249
1259
Log *log = GetLog (LLDBLog::Expressions);
1250
1260
LLDB_SCOPED_TIMER ();
1251
1261
1252
- auto should_disable_objc_runtime = [&]() {
1253
- lldb::StackFrameSP this_frame_sp (m_stack_frame_wp.lock ());
1254
- if (!this_frame_sp)
1255
- return false ;
1256
- lldb::ProcessSP process_sp (this_frame_sp->CalculateProcess ());
1257
- if (!process_sp)
1258
- return false ;
1259
- return !ObjCLanguageRuntime::Get (*process_sp);
1260
- };
1261
-
1262
- ThreadSafeASTContext ast_context = GetASTContext (
1263
- diagnostic_manager, should_disable_objc_runtime, repl, playground);
1262
+ ThreadSafeASTContext ast_context = GetASTContext (diagnostic_manager);
1264
1263
if (!ast_context)
1265
1264
return make_error<SwiftASTContextError>();
1266
1265
1266
+ bool repl = m_options.GetREPLEnabled ();
1267
+ bool playground = m_options.GetPlaygroundTransformEnabled ();
1267
1268
// If we are using the playground, hand import the necessary
1268
1269
// modules.
1269
1270
//
@@ -1705,9 +1706,8 @@ SwiftExpressionParser::Parse(DiagnosticManager &diagnostic_manager,
1705
1706
return ParseResult::unrecoverable_error;
1706
1707
1707
1708
// Parse the expression and import all nececssary swift modules.
1708
- auto parsed_expr = ParseAndImport (
1709
- *expr_diagnostics, variable_map, buffer_id,
1710
- diagnostic_manager, repl, playground);
1709
+ auto parsed_expr = ParseAndImport (*expr_diagnostics, variable_map, buffer_id,
1710
+ diagnostic_manager);
1711
1711
1712
1712
if (!parsed_expr) {
1713
1713
bool retry = false ;
0 commit comments