Skip to content

Commit 93c97e8

Browse files
committed
[NFC][lldb] Remove function parameters that are also ivars
After making ParseASTContext and GetASTContext methods, some function parameters are now unnecessarily as they are also ivars. Remove those parameters.
1 parent 97da402 commit 93c97e8

File tree

2 files changed

+22
-25
lines changed

2 files changed

+22
-25
lines changed

lldb/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -774,9 +774,8 @@ static void ResolveSpecialNames(
774774
}
775775
}
776776

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) {
780779
llvm::call_once(m_ast_init_once_flag, [&] {
781780
// Lazily get the clang importer if we can to make sure it exists in
782781
// case we need it.
@@ -810,6 +809,8 @@ ThreadSafeASTContext SwiftExpressionParser::GetASTContext(
810809
return;
811810
}
812811

812+
bool repl = m_options.GetREPLEnabled();
813+
bool playground = m_options.GetPlaygroundTransformEnabled();
813814
// TODO: Find a way to get contraint-solver output sent to a stream
814815
// so we can log it.
815816
// swift_ast_context.GetLanguageOptions().DebugConstraintSolver = true;
@@ -820,7 +821,16 @@ ThreadSafeASTContext SwiftExpressionParser::GetASTContext(
820821
(repl || playground);
821822
m_swift_ast_ctx.GetLanguageOptions().EnableTargetOSChecking = false;
822823

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())
824834
m_swift_ast_ctx.GetLanguageOptions().EnableObjCInterop = false;
825835

826836
m_swift_ast_ctx.GetLanguageOptions().Playground = repl || playground;
@@ -1245,25 +1255,16 @@ llvm::Expected<SwiftExpressionParser::ParsedExpression>
12451255
SwiftExpressionParser::ParseAndImport(
12461256
SwiftASTContext::ScopedDiagnostics &expr_diagnostics,
12471257
SwiftExpressionParser::SILVariableMap &variable_map, unsigned &buffer_id,
1248-
DiagnosticManager &diagnostic_manager, bool repl, bool playground) {
1258+
DiagnosticManager &diagnostic_manager) {
12491259
Log *log = GetLog(LLDBLog::Expressions);
12501260
LLDB_SCOPED_TIMER();
12511261

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);
12641263
if (!ast_context)
12651264
return make_error<SwiftASTContextError>();
12661265

1266+
bool repl = m_options.GetREPLEnabled();
1267+
bool playground = m_options.GetPlaygroundTransformEnabled();
12671268
// If we are using the playground, hand import the necessary
12681269
// modules.
12691270
//
@@ -1705,9 +1706,8 @@ SwiftExpressionParser::Parse(DiagnosticManager &diagnostic_manager,
17051706
return ParseResult::unrecoverable_error;
17061707

17071708
// 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);
17111711

17121712
if (!parsed_expr) {
17131713
bool retry = false;

lldb/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,11 @@ class SwiftExpressionParser : public ExpressionParser {
198198
llvm::Expected<ParsedExpression>
199199
ParseAndImport(SwiftASTContext::ScopedDiagnostics &expr_diagnostics,
200200
SwiftExpressionParser::SILVariableMap &variable_map,
201-
unsigned &buffer_id, DiagnosticManager &diagnostic_manager,
202-
bool repl, bool playground);
201+
unsigned &buffer_id, DiagnosticManager &diagnostic_manager);
203202

204203
/// Initialize the SwiftASTContext and return the wrapped
205204
/// ThreadSafeASTContext when successful.
206-
ThreadSafeASTContext GetASTContext(DiagnosticManager &diagnostic_manager,
207-
std::function<bool()> disable_objc_runtime,
208-
bool repl, bool playground);
205+
ThreadSafeASTContext GetASTContext(DiagnosticManager &diagnostic_manager);
209206

210207
/// The expression to be parsed.
211208
Expression &m_expr;

0 commit comments

Comments
 (0)