[Lldb-commits] [PATCH] D154643: [lldb] Prevent crash when completing ambiguous subcommands
Jonas Devlieghere via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Mon Jul 10 14:50:48 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfb10b01cca85: [lldb] Prevent crash when completing ambiguous subcommands (authored by JDevlieghere).
Herald added a project: LLDB.
Changed prior to commit:
https://reviews.llvm.org/D154643?vs=537829&id=538837#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D154643/new/
https://reviews.llvm.org/D154643
Files:
lldb/source/Commands/CommandObjectMultiword.cpp
lldb/test/API/functionalities/completion/TestCompletion.py
Index: lldb/test/API/functionalities/completion/TestCompletion.py
===================================================================
--- lldb/test/API/functionalities/completion/TestCompletion.py
+++ lldb/test/API/functionalities/completion/TestCompletion.py
@@ -880,3 +880,11 @@
self.complete_from_to("breakpoint set -N n", "breakpoint set -N n")
self.assertTrue(bp1.AddNameWithErrorHandling("nn"))
self.complete_from_to("breakpoint set -N ", "breakpoint set -N nn")
+
+ def test_ambiguous_command(self):
+ """Test completing an ambiguous commands"""
+ self.complete_from_to("settings s", ['set', 'show'])
+
+ def test_ambiguous_subcommand(self):
+ """Test completing a subcommand of an ambiguous command"""
+ self.complete_from_to("settings s ta", [])
Index: lldb/source/Commands/CommandObjectMultiword.cpp
===================================================================
--- lldb/source/Commands/CommandObjectMultiword.cpp
+++ lldb/source/Commands/CommandObjectMultiword.cpp
@@ -274,10 +274,10 @@
StringList new_matches;
CommandObject *sub_command_object = GetSubcommandObject(arg0, &new_matches);
- if (sub_command_object == nullptr) {
- request.AddCompletions(new_matches);
+
+ // The subcommand is ambiguous. The completion isn't meaningful.
+ if (!sub_command_object)
return;
- }
// Remove the one match that we got from calling GetSubcommandObject.
new_matches.DeleteStringAtIndex(0);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154643.538837.patch
Type: text/x-patch
Size: 1486 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230710/7c2014d7/attachment.bin>
More information about the lldb-commits
mailing list