diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2020-11-09 15:25:59 -0800 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2020-11-09 15:42:27 -0800 |
commit | b2fa3b922ecb219429ec7b839d15a06aedbc955a (patch) | |
tree | 266e4fc62625a1487f7620934bbc6b57fdf32d09 /lldb/source/Commands/CommandObjectExpression.cpp | |
parent | 554939583a122c48e8c3ffa1bff734b3ce963627 (diff) | |
download | llvm-b2fa3b922ecb219429ec7b839d15a06aedbc955a.zip llvm-b2fa3b922ecb219429ec7b839d15a06aedbc955a.tar.gz llvm-b2fa3b922ecb219429ec7b839d15a06aedbc955a.tar.bz2 |
[lldb] Make GetSelectedOrDummyTarget return the target by reference (NFC)
Return references from GetDummyTarget and GetSelectedOrDummyTarget. This
matches how the APIs are already used in practice.
Diffstat (limited to 'lldb/source/Commands/CommandObjectExpression.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectExpression.cpp | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp index b23adb0..58eaa3f 100644 --- a/lldb/source/Commands/CommandObjectExpression.cpp +++ b/lldb/source/Commands/CommandObjectExpression.cpp @@ -304,11 +304,8 @@ void CommandObjectExpression::HandleCompletion(CompletionRequest &request) { return; ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); - - Target *target = exe_ctx.GetTargetPtr(); - - if (!target) - target = &GetDummyTarget(); + Target *exe_target = exe_ctx.GetTargetPtr(); + Target &target = exe_target ? *exe_target : GetDummyTarget(); unsigned cursor_pos = request.GetRawCursorPos(); // Get the full user input including the suffix. The suffix is necessary @@ -342,7 +339,7 @@ void CommandObjectExpression::HandleCompletion(CompletionRequest &request) { auto language = exe_ctx.GetFrameRef().GetLanguage(); Status error; - lldb::UserExpressionSP expr(target->GetUserExpressionForLanguage( + lldb::UserExpressionSP expr(target.GetUserExpressionForLanguage( code, llvm::StringRef(), language, UserExpression::eResultTypeAny, options, nullptr, error)); if (error.Fail()) @@ -411,22 +408,19 @@ bool CommandObjectExpression::EvaluateExpression(llvm::StringRef expr, // command object DoExecute has finished when doing multi-line expression // that use an input reader... ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); - - Target *target = exe_ctx.GetTargetPtr(); - - if (!target) - target = &GetDummyTarget(); + Target *exe_target = exe_ctx.GetTargetPtr(); + Target &target = exe_target ? *exe_target : GetDummyTarget(); lldb::ValueObjectSP result_valobj_sp; StackFrame *frame = exe_ctx.GetFramePtr(); - const EvaluateExpressionOptions options = GetEvalOptions(*target); - ExpressionResults success = target->EvaluateExpression( + const EvaluateExpressionOptions options = GetEvalOptions(target); + ExpressionResults success = target.EvaluateExpression( expr, frame, result_valobj_sp, options, &m_fixed_expression); // We only tell you about the FixIt if we applied it. The compiler errors // will suggest the FixIt if it parsed. - if (!m_fixed_expression.empty() && target->GetEnableNotifyAboutFixIts()) { + if (!m_fixed_expression.empty() && target.GetEnableNotifyAboutFixIts()) { if (success == eExpressionCompleted) error_stream.Printf(" Fix-it applied, fixed expression was: \n %s\n", m_fixed_expression.c_str()); |