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.

<rdar://problem/25351938>

llvm-svn: 264793
diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp
index 3f55088..25a8844 100644
--- a/lldb/source/Commands/CommandObjectExpression.cpp
+++ b/lldb/source/Commands/CommandObjectExpression.cpp
@@ -336,7 +336,14 @@
         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 @@
 CommandObjectExpression::DoExecute(const char *command,
                                    CommandReturnObject &result)
 {
+    m_fixed_expression.clear();
     m_option_group.NotifyOptionParsingStarting();
 
     const char * expr = nullptr;
@@ -598,7 +606,26 @@
         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;