From e5ee6f04ab2a5fb162454a5b9ccc968c3c9105f1 Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Tue, 29 Mar 2016 22:00:08 +0000 Subject: Figure out what the fixed expression is, and print it. Added another target setting to quietly apply fixits for those who really trust clang's fixits. Also, moved the retry into ClangUserExpression::Evaluate, where I can make a whole new ClangUserExpression to do the work. Reusing any of the parts of a UserExpression in situ isn't supported at present. llvm-svn: 264793 --- lldb/source/Commands/CommandObjectExpression.cpp | 29 +++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'lldb/source/Commands/CommandObjectExpression.cpp') 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; -- cgit v1.2.3