[Lldb-commits] [lldb] Centralize the handling of completion for simple argument lists. (PR #82085)

via lldb-commits lldb-commits at lists.llvm.org
Fri Feb 16 17:14:15 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 6ce03ff3fef8fb6fa9afe8eb22c6d98bced26d48 d08b2b0f10fd449a2b47252aa0da75d515a68664 -- lldb/include/lldb/Interpreter/CommandObject.h lldb/include/lldb/Interpreter/CommandOptionArgumentTable.h lldb/include/lldb/lldb-enumerations.h lldb/source/Commands/CommandObjectCommands.cpp lldb/source/Commands/CommandObjectDWIMPrint.cpp lldb/source/Commands/CommandObjectDWIMPrint.h lldb/source/Commands/CommandObjectFrame.cpp lldb/source/Commands/CommandObjectPlatform.cpp lldb/source/Commands/CommandObjectPlugin.cpp lldb/source/Commands/CommandObjectProcess.cpp lldb/source/Commands/CommandObjectRegister.cpp lldb/source/Commands/CommandObjectSession.cpp lldb/source/Commands/CommandObjectSettings.cpp lldb/source/Commands/CommandObjectTarget.cpp lldb/source/Commands/CommandObjectThread.cpp lldb/source/Commands/CommandObjectType.cpp lldb/source/Commands/CommandObjectWatchpoint.cpp lldb/source/Interpreter/CommandObject.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/lldb/include/lldb/Interpreter/CommandObject.h b/lldb/include/lldb/Interpreter/CommandObject.h
index 537acb4502..6f058c5628 100644
--- a/lldb/include/lldb/Interpreter/CommandObject.h
+++ b/lldb/include/lldb/Interpreter/CommandObject.h
@@ -241,11 +241,11 @@ public:
 
   /// The default version handles argument definitions that have only one
   /// argument type, and use one of the argument types that have an entry in
-  /// the CommonCompletions.  Override this if you have a more complex 
-  /// argument setup.  
-  /// FIXME: we should be able to extend this to more complex argument 
+  /// the CommonCompletions.  Override this if you have a more complex
+  /// argument setup.
+  /// FIXME: we should be able to extend this to more complex argument
   /// definitions provided we have completers for all the argument types.
-  ///  
+  ///
   /// The input array contains a parsed version of the line.
   ///
   /// We've constructed the map of options and their arguments as well if that
diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp
index 7b960029d3..b25c391bd4 100644
--- a/lldb/source/Commands/CommandObjectPlatform.cpp
+++ b/lldb/source/Commands/CommandObjectPlatform.cpp
@@ -1103,7 +1103,8 @@ public:
     // I didn't make a type for RemoteRunArgs, but since we're going to run
     // this on the remote system we should use the remote completer.
     lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), lldb::eRemoteDiskFileCompletion, request, nullptr);
+        GetCommandInterpreter(), lldb::eRemoteDiskFileCompletion, request,
+        nullptr);
   }
 
   ~CommandObjectPlatformProcessLaunch() override = default;
diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp
index 50e6a78d31..1abc3bf45f 100644
--- a/lldb/source/Interpreter/CommandObject.cpp
+++ b/lldb/source/Interpreter/CommandObject.cpp
@@ -305,9 +305,8 @@ void CommandObject::HandleCompletion(CompletionRequest &request) {
   }
 }
 
-void
-CommandObject::HandleArgumentCompletion(CompletionRequest &request,
-                           OptionElementVector &opt_element_vector) {
+void CommandObject::HandleArgumentCompletion(
+    CompletionRequest &request, OptionElementVector &opt_element_vector) {
   size_t num_arg_entries = GetNumArgumentEntries();
   if (num_arg_entries != 1)
     return;
@@ -315,32 +314,30 @@ CommandObject::HandleArgumentCompletion(CompletionRequest &request,
   CommandArgumentEntry *entry_ptr = GetArgumentEntryAtIndex(0);
   if (!entry_ptr)
     return; // Maybe this should be an assert, this shouldn't be possible.
-  
+
   CommandArgumentEntry &entry = *entry_ptr;
   // For now, we only handle the simple case of one homogenous argument type.
   if (entry.size() != 1)
     return;
 
   // Look up the completion type, and if it has one, invoke it:
-  const CommandObject::ArgumentTableEntry *arg_entry 
-      = FindArgumentDataByType(entry[0].arg_type);
+  const CommandObject::ArgumentTableEntry *arg_entry =
+      FindArgumentDataByType(entry[0].arg_type);
   const ArgumentRepetitionType repeat = entry[0].arg_repetition;
-  
+
   if (arg_entry == nullptr || arg_entry->completion_type == lldb::eNoCompletion)
     return;
-  
+
   // FIXME: This should be handled higher in the Command Parser.
   // Check the case where this command only takes one argument, and don't do
   // the completion if we aren't on the first entry:
   if (repeat == eArgRepeatPlain && request.GetCursorIndex() != 0)
     return;
-  
-  lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
-            GetCommandInterpreter(), arg_entry->completion_type, request, nullptr);
 
+  lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+      GetCommandInterpreter(), arg_entry->completion_type, request, nullptr);
 }
 
-
 bool CommandObject::HelpTextContainsWord(llvm::StringRef search_word,
                                          bool search_short_help,
                                          bool search_long_help,

``````````

</details>


https://github.com/llvm/llvm-project/pull/82085


More information about the lldb-commits mailing list