diff options
Diffstat (limited to 'lldb/source/Commands')
-rw-r--r-- | lldb/source/Commands/CommandObjectExpression.cpp | 29 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectExpression.h | 1 |
2 files changed, 29 insertions, 1 deletions
diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp index 3f550883b29..25a88449c52 100644 --- a/lldb/source/Commands/CommandObjectExpression.cpp +++ b/lldb/source/Commands/CommandObjectExpression.cpp @@ -336,7 +336,14 @@ CommandObjectExpression::EvaluateExpression(const char *expr, else options.SetTimeoutUsec(0); - target->EvaluateExpression(expr, frame, result_valobj_sp, options); + 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 (error_stream && !m_fixed_expression.empty() && target->GetEnableNotifyAboutFixIts()) + { + if (success == eExpressionCompleted) + error_stream->Printf (" Fixit applied, fixed expression was: \n %s\n", m_fixed_expression.c_str()); + } if (result_valobj_sp) { @@ -477,6 +484,7 @@ bool CommandObjectExpression::DoExecute(const char *command, CommandReturnObject &result) { + m_fixed_expression.clear(); m_option_group.NotifyOptionParsingStarting(); const char * expr = nullptr; @@ -598,7 +606,26 @@ CommandObjectExpression::DoExecute(const char *command, expr = command; if (EvaluateExpression (expr, &(result.GetOutputStream()), &(result.GetErrorStream()), &result)) + { + Target *target = m_interpreter.GetExecutionContext().GetTargetPtr(); + if (!m_fixed_expression.empty() && target->GetEnableNotifyAboutFixIts()) + { + CommandHistory &history = m_interpreter.GetCommandHistory(); + // FIXME: Can we figure out what the user actually typed (e.g. some alias for expr???) + // If we can it would be nice to show that. + std::string fixed_command("expression "); + if (expr == command) + fixed_command.append(m_fixed_expression); + else + { + // Add in any options that might have been in the original command: + fixed_command.append(command, expr - command); + fixed_command.append(m_fixed_expression); + } + history.AppendString(fixed_command); + } return true; + } result.SetStatus (eReturnStatusFailed); return false; diff --git a/lldb/source/Commands/CommandObjectExpression.h b/lldb/source/Commands/CommandObjectExpression.h index 4c5bff8e2a9..f26ee7a8a25 100644 --- a/lldb/source/Commands/CommandObjectExpression.h +++ b/lldb/source/Commands/CommandObjectExpression.h @@ -108,6 +108,7 @@ protected: CommandOptions m_command_options; uint32_t m_expr_line_count; std::string m_expr_lines; // Multi-line expression support + std::string m_fixed_expression; // Holds the current expression's fixed text. }; } // namespace lldb_private |