Skip to content

Commit 4d18d97

Browse files
committed
[lldb] Fix dwim-print error message for missing expr
1 parent 71a5958 commit 4d18d97

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

lldb/source/Commands/CommandObjectDWIMPrint.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,16 @@ bool CommandObjectDWIMPrint::DoExecute(StringRef command,
6161
OptionsWithRaw args{command};
6262
StringRef expr = args.GetRawPart();
6363

64+
if (expr.empty()) {
65+
result.AppendErrorWithFormatv("'{0}' takes a variable or expression",
66+
m_cmd_name);
67+
return false;
68+
}
69+
6470
if (args.HasArgs()) {
6571
if (!ParseOptionsAndNotify(args.GetArgs(), result, m_option_group,
6672
m_exe_ctx))
6773
return false;
68-
} else if (command.empty()) {
69-
result.AppendErrorWithFormatv("'{0}' takes a variable or expression",
70-
m_cmd_name);
71-
return false;
7274
}
7375

7476
// If the user has not specified, default to disabling persistent results.

lldb/test/API/commands/dwim-print/TestDWIMPrint.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,10 @@ def test_expression_language(self):
107107
lldbutil.run_to_name_breakpoint(self, "main")
108108
self._expect_cmd(f"dwim-print -l c++ -- argc", "frame variable")
109109
self._expect_cmd(f"dwim-print -l c++ -- argc + 1", "expression")
110+
111+
def test_empty_expression(self):
112+
self.build()
113+
lldbutil.run_to_name_breakpoint(self, "main")
114+
error_msg = "error: 'dwim-print' takes a variable or expression"
115+
self.expect(f"dwim-print", error=True, startstr=error_msg)
116+
self.expect(f"dwim-print -- ", error=True, startstr=error_msg)

0 commit comments

Comments
 (0)