diff --git a/lldb/source/Expression/UserExpression.cpp b/lldb/source/Expression/UserExpression.cpp --- a/lldb/source/Expression/UserExpression.cpp +++ b/lldb/source/Expression/UserExpression.cpp @@ -330,11 +330,10 @@ std::string msg; { llvm::raw_string_ostream os(msg); - os << "expression failed to parse:\n"; if (!diagnostic_manager.Diagnostics().empty()) os << diagnostic_manager.GetString(); else - os << "unknown error"; + os << "expression failed to parse (no further compiler diagnostics)"; if (target->GetEnableNotifyAboutFixIts() && fixed_expression && !fixed_expression->empty()) os << "\nfixed expression suggested:\n " << *fixed_expression; diff --git a/lldb/source/Interpreter/CommandReturnObject.cpp b/lldb/source/Interpreter/CommandReturnObject.cpp --- a/lldb/source/Interpreter/CommandReturnObject.cpp +++ b/lldb/source/Interpreter/CommandReturnObject.cpp @@ -101,7 +101,10 @@ SetStatus(eReturnStatusFailed); if (in_string.empty()) return; - error(GetErrorStream()) << in_string.rtrim() << '\n'; + // Workaround to deal with already fully formatted compiler diagnostics. + llvm::StringRef msg(in_string.rtrim()); + msg.consume_front("error: "); + error(GetErrorStream()) << msg << '\n'; } void CommandReturnObject::SetError(const Status &error, diff --git a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py --- a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py +++ b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py @@ -151,8 +151,7 @@ value = frame.EvaluateExpression("struct Redef { float y; };", top_level_opts) self.assertFalse(value.GetError().Success()) self.assertIn( - """ -error: :1:8: redefinition of 'Redef' + """error: :1:8: redefinition of 'Redef' 1 | struct Redef { float y; }; | ^ :1:8: previous definition is here diff --git a/lldb/test/API/commands/expression/fixits/TestFixIts.py b/lldb/test/API/commands/expression/fixits/TestFixIts.py --- a/lldb/test/API/commands/expression/fixits/TestFixIts.py +++ b/lldb/test/API/commands/expression/fixits/TestFixIts.py @@ -154,7 +154,6 @@ multiple_runs_options.SetRetriesWithFixIts(0) value = frame.EvaluateExpression(two_runs_expr, multiple_runs_options) errmsg = value.GetError().GetCString() - self.assertIn("expression failed to parse", errmsg) self.assertIn("using declaration resolved to type without 'typename'", errmsg) self.assertIn("fixed expression suggested:", errmsg) self.assertIn("using typename T::TypeDef", errmsg) @@ -166,7 +165,6 @@ multiple_runs_options.SetRetriesWithFixIts(1) value = frame.EvaluateExpression(two_runs_expr, multiple_runs_options) errmsg = value.GetError().GetCString() - self.assertIn("expression failed to parse", errmsg) self.assertIn("fixed expression suggested:", errmsg) # Both our fixed expressions should be in the suggested expression. self.assertIn("using typename T::TypeDef", errmsg)