[Lldb-commits] [lldb] 4d18d97 - [lldb] Fix dwim-print error message for missing expr
Dave Lee via lldb-commits
lldb-commits at lists.llvm.org
Wed Mar 22 14:25:37 PDT 2023
Author: Dave Lee
Date: 2023-03-22T14:25:32-07:00
New Revision: 4d18d97b594ccaa3cbd79beb4afef45e4156dc8d
URL: https://github.com/llvm/llvm-project/commit/4d18d97b594ccaa3cbd79beb4afef45e4156dc8d
DIFF: https://github.com/llvm/llvm-project/commit/4d18d97b594ccaa3cbd79beb4afef45e4156dc8d.diff
LOG: [lldb] Fix dwim-print error message for missing expr
Added:
Modified:
lldb/source/Commands/CommandObjectDWIMPrint.cpp
lldb/test/API/commands/dwim-print/TestDWIMPrint.py
Removed:
################################################################################
diff --git a/lldb/source/Commands/CommandObjectDWIMPrint.cpp b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
index 419a27acc8181..ed816195350e9 100644
--- a/lldb/source/Commands/CommandObjectDWIMPrint.cpp
+++ b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
@@ -61,14 +61,16 @@ bool CommandObjectDWIMPrint::DoExecute(StringRef command,
OptionsWithRaw args{command};
StringRef expr = args.GetRawPart();
+ if (expr.empty()) {
+ result.AppendErrorWithFormatv("'{0}' takes a variable or expression",
+ m_cmd_name);
+ return false;
+ }
+
if (args.HasArgs()) {
if (!ParseOptionsAndNotify(args.GetArgs(), result, m_option_group,
m_exe_ctx))
return false;
- } else if (command.empty()) {
- result.AppendErrorWithFormatv("'{0}' takes a variable or expression",
- m_cmd_name);
- return false;
}
// If the user has not specified, default to disabling persistent results.
diff --git a/lldb/test/API/commands/dwim-print/TestDWIMPrint.py b/lldb/test/API/commands/dwim-print/TestDWIMPrint.py
index 22d18f91d0a59..9f69895f43692 100644
--- a/lldb/test/API/commands/dwim-print/TestDWIMPrint.py
+++ b/lldb/test/API/commands/dwim-print/TestDWIMPrint.py
@@ -107,3 +107,10 @@ def test_expression_language(self):
lldbutil.run_to_name_breakpoint(self, "main")
self._expect_cmd(f"dwim-print -l c++ -- argc", "frame variable")
self._expect_cmd(f"dwim-print -l c++ -- argc + 1", "expression")
+
+ def test_empty_expression(self):
+ self.build()
+ lldbutil.run_to_name_breakpoint(self, "main")
+ error_msg = "error: 'dwim-print' takes a variable or expression"
+ self.expect(f"dwim-print", error=True, startstr=error_msg)
+ self.expect(f"dwim-print -- ", error=True, startstr=error_msg)
More information about the lldb-commits
mailing list