Fix DIL FormatDiagnostics issues.

Fix the bug, so we can now use the full formatting again. Also, move
FormatDiagnostics out of the DILParser class, so both the parser and
the intepreter can call it, and remove the static redundant copy of the
function from DILEval.
diff --git a/lldb/include/lldb/ValueObject/DILParser.h b/lldb/include/lldb/ValueObject/DILParser.h
index 8fc9ad81..587959f2 100644
--- a/lldb/include/lldb/ValueObject/DILParser.h
+++ b/lldb/include/lldb/ValueObject/DILParser.h
@@ -59,6 +59,9 @@
   kUnknown,
 };
 
+std::string FormatDiagnostics(DILSourceManager& sm, const std::string& message,
+                              uint32_t loc);
+
 void SetUbStatus(Status& error, ErrorCode code);
 
 /// TypeDeclaration builds information about the literal type definition as
@@ -220,10 +223,6 @@
 
   std::string TokenDescription(const DILToken& token);
 
-  std::string FormatDiagnostics(DILSourceManager& sm,
-                                const std::string& message,
-                                uint32_t loc);
-
   template <typename... Ts>
   void ExpectOneOf(dil::TokenKind k, Ts... ks);
 
diff --git a/lldb/source/ValueObject/DILEval.cpp b/lldb/source/ValueObject/DILEval.cpp
index 396a379..a0ac3b5 100644
--- a/lldb/source/ValueObject/DILEval.cpp
+++ b/lldb/source/ValueObject/DILEval.cpp
@@ -237,46 +237,6 @@
   return member_val_sp;
 }
 
-static std::string FormatDiagnostics(std::shared_ptr<DILSourceManager> sm,
-                                     const std::string& message,
-                                     uint32_t loc,
-                                     ErrorCode code)
-{
-  const char *ecode_names[7] = {
-    "kOK", "kInvalidExpressionSyntax", "kInvalidNumericLiteral",
-    "kInvalidOperandType", "kUndeclaredIdentifier", "kNotImplemented",
-    "kUnknown"};
-
-  // Translate ErrorCode
-  llvm::StringRef error_code = ecode_names[(int)code];
-
-  // Get the source buffer and the location of the current token.
-  llvm::StringRef text(sm->GetSource());
-  size_t loc_offset = (size_t) loc;
-
-  // Look for the start of the line.
-  size_t line_start = text.rfind('\n', loc_offset);
-  line_start = line_start == llvm::StringRef::npos ? 0 : line_start + 1;
-
-  // Look for the end of the line.
-  size_t line_end = text.find('\n', loc_offset);
-  line_end = line_end == llvm::StringRef::npos ? text.size() : line_end;
-
-  // Get a view of the current line in the source code and the position of the
-  // diagnostics pointer.
-  llvm::StringRef line = text.slice(line_start, line_end);
-  int32_t arrow = loc;
-
-  // Calculate the padding in case we point outside of the expression (this can
-  // happen if the parser expected something, but got EOF).
-  size_t expr_rpad = std::max(0, arrow - static_cast<int32_t>(line.size()));
-  size_t arrow_rpad = std::max(0, static_cast<int32_t>(line.size()) - arrow);
-
-  return llvm::formatv("{0}: {1}\n{2}\n{3}", error_code, message,
-                       llvm::fmt_pad(line, 0, expr_rpad),
-                       llvm::fmt_pad("^", arrow - 1, arrow_rpad));
-}
-
 void SetUbStatus(Status& error, ErrorCode code) {
   llvm::StringRef err_str;
   switch ((int) code) {
@@ -372,7 +332,8 @@
 void DILInterpreter::SetError(ErrorCode code, std::string error,
                               uint32_t loc) {
   assert(m_error.Success() && "interpreter can error only once");
-  m_error = Status(FormatDiagnostics(m_sm, error, loc, code));
+  m_error = Status((uint32_t) code, lldb::eErrorTypeGeneric,
+                   FormatDiagnostics(*m_sm, error, loc));
 }
 
 void DILInterpreter::Visit(const ErrorNode* node) {
diff --git a/lldb/source/ValueObject/DILParser.cpp b/lldb/source/ValueObject/DILParser.cpp
index 2d82823..147af6c 100644
--- a/lldb/source/ValueObject/DILParser.cpp
+++ b/lldb/source/ValueObject/DILParser.cpp
@@ -679,6 +679,35 @@
   return lldb::eBasicTypeChar;
 }
 
+std::string FormatDiagnostics(DILSourceManager& sm, const std::string& message,
+                              uint32_t loc) {
+  // Get the source buffer and the location of the current token.
+  llvm::StringRef text = sm.GetSource();
+  size_t loc_offset = (size_t) loc;
+
+  // Look for the start of the line.
+  size_t line_start = text.rfind('\n', loc_offset);
+  line_start = line_start == llvm::StringRef::npos ? 0 : line_start + 1;
+
+  // Look for the end of the line.
+  size_t line_end = text.find('\n', loc_offset);
+  line_end = line_end == llvm::StringRef::npos ? text.size() : line_end;
+
+  // Get a view of the current line in the source code and the position of the
+  // diagnostics pointer.
+  llvm::StringRef line = text.slice(line_start, line_end);
+  int32_t arrow = loc + 1; // Column offset starts at 1, not 0.
+
+  // Calculate the padding in case we point outside of the expression (this can
+  // happen if the parser expected something, but got EOF).˚
+  size_t expr_rpad = std::max(0, arrow - static_cast<int32_t>(line.size()));
+  size_t arrow_rpad = std::max(0, static_cast<int32_t>(line.size()) - arrow);
+
+  return llvm::formatv("<expr:1:{0}>: {1}\n{2}\n{3}", loc,
+                       message, llvm::fmt_pad(line, 0, expr_rpad),
+                       llvm::fmt_pad("^", arrow - 1, arrow_rpad));
+}
+
 DILParser::DILParser(std::shared_ptr<DILSourceManager> dil_sm,
                      std::shared_ptr<ExecutionContextScope> exe_ctx_scope,
                      lldb::DynamicValueType use_dynamic, bool use_synthetic,
@@ -4046,40 +4075,6 @@
   return llvm::formatv("<'{0}' ({1})>", spelling, kind_name);
 }
 
-std::string DILParser::FormatDiagnostics(
-    DILSourceManager& sm,
-    const std::string& message,
-    uint32_t loc) {
-  return message; // CAROLINE!!  TODO: Fix this?
-
-  // Get the source buffer and the location of the current token.
-  llvm::StringRef text = sm.GetSource();
-  size_t loc_offset = (size_t) loc;
-
-  // Look for the start of the line.
-  size_t line_start = text.rfind('\n', loc_offset);
-  line_start = line_start == llvm::StringRef::npos ? 0 : line_start + 1;
-
-  // Look for the end of the line.
-  size_t line_end = text.find('\n', loc_offset);
-  line_end = line_end == llvm::StringRef::npos ? text.size() : line_end;
-
-  // Get a view of the current line in the source code and the position of the
-  // diagnostics pointer.
-  llvm::StringRef line = text.slice(line_start, line_end);
-  int32_t arrow = loc;
-
-  // Calculate the padding in case we point outside of the expression (this can
-  // happen if the parser expected something, but got EOF).˚
-  size_t expr_rpad = std::max(0, arrow - static_cast<int32_t>(line.size()));
-  size_t arrow_rpad = std::max(0, static_cast<int32_t>(line.size()) - arrow);
-
-  //return llvm::formatv("<expr:1:{0}>: {1}\n{2}\n{3}", loc,
-  return llvm::formatv("{0}: {1}\n{2}\n{3}", loc,
-                       message, llvm::fmt_pad(line, 0, expr_rpad),
-                       llvm::fmt_pad("^", arrow - 1, arrow_rpad));
-}
-
 bool DILParser::ImplicitConversionIsAllowed(CompilerType src, CompilerType dst,
                                             bool is_src_literal_zero) {
   if (dst.IsInteger() || dst.IsFloat()) {