This revision was automatically updated to reflect the committed changes.
Closed by commit rG133c3eaac0a5: Streamline expression parser error messages.
(authored by aprantl).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D152590/new/
https://reviews.llvm.org/D152590
Files:
lldb/source/Expression/UserExpression.cpp
lldb/source/Interpreter/CommandReturnObject.cpp
lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
lldb/test/API/commands/expression/fixits/TestFixIts.py
Index: lldb/test/API/commands/expression/fixits/TestFixIts.py
===================================================================
--- lldb/test/API/commands/expression/fixits/TestFixIts.py
+++ 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)
Index: lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
===================================================================
--- lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
+++ 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: <user expression 9>:1:8: redefinition of 'Redef'
+ """error: <user expression 9>:1:8: redefinition of 'Redef'
1 | struct Redef { float y; };
| ^
<user expression 8>:1:8: previous definition is here
Index: lldb/source/Interpreter/CommandReturnObject.cpp
===================================================================
--- lldb/source/Interpreter/CommandReturnObject.cpp
+++ 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,
Index: lldb/source/Expression/UserExpression.cpp
===================================================================
--- lldb/source/Expression/UserExpression.cpp
+++ 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;
Index: lldb/test/API/commands/expression/fixits/TestFixIts.py
===================================================================
--- lldb/test/API/commands/expression/fixits/TestFixIts.py
+++ 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)
Index: lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
===================================================================
--- lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
+++ 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: <user expression 9>:1:8: redefinition of 'Redef'
+ """error: <user expression 9>:1:8: redefinition of 'Redef'
1 | struct Redef { float y; };
| ^
<user expression 8>:1:8: previous definition is here
Index: lldb/source/Interpreter/CommandReturnObject.cpp
===================================================================
--- lldb/source/Interpreter/CommandReturnObject.cpp
+++ 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,
Index: lldb/source/Expression/UserExpression.cpp
===================================================================
--- lldb/source/Expression/UserExpression.cpp
+++ 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;
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits