[Lldb-commits] [lldb] 440460f - [lldb][NFC] Move common_completions mapping out of CommandCompletions header.

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Wed Feb 12 00:49:11 PST 2020


Author: Raphael Isemann
Date: 2020-02-12T09:48:51+01:00
New Revision: 440460f1e70193f5805e2fdbc6d91ab5d5d0bbab

URL: https://github.com/llvm/llvm-project/commit/440460f1e70193f5805e2fdbc6d91ab5d5d0bbab
DIFF: https://github.com/llvm/llvm-project/commit/440460f1e70193f5805e2fdbc6d91ab5d5d0bbab.diff

LOG: [lldb][NFC] Move common_completions mapping out of CommandCompletions header.

Added: 
    

Modified: 
    lldb/include/lldb/Interpreter/CommandCompletions.h
    lldb/source/Commands/CommandCompletions.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Interpreter/CommandCompletions.h b/lldb/include/lldb/Interpreter/CommandCompletions.h
index c4eb1ae878f4..a678a1173c36 100644
--- a/lldb/include/lldb/Interpreter/CommandCompletions.h
+++ b/lldb/include/lldb/Interpreter/CommandCompletions.h
@@ -23,13 +23,6 @@ namespace lldb_private {
 class TildeExpressionResolver;
 class CommandCompletions {
 public:
-  // This is the command completion callback that is used to complete the
-  // argument of the option it is bound to (in the OptionDefinition table
-  // below).  Return the total number of matches.
-  typedef void (*CompletionCallback)(CommandInterpreter &interpreter,
-                                     CompletionRequest &request,
-                                     // A search filter to limit the search...
-                                     lldb_private::SearchFilter *searcher);
   enum CommonCompletionTypes {
     eNoCompletion = 0u,
     eSourceFileCompletion = (1u << 0),
@@ -47,11 +40,6 @@ class CommandCompletions {
     eCustomCompletion = (1u << 9)
   };
 
-  struct CommonCompletionElement {
-    uint32_t type;
-    CompletionCallback callback;
-  };
-
   static bool InvokeCommonCompletionCallbacks(
       CommandInterpreter &interpreter, uint32_t completion_mask,
       lldb_private::CompletionRequest &request, SearchFilter *searcher);
@@ -93,9 +81,6 @@ class CommandCompletions {
 
   static void VariablePath(CommandInterpreter &interpreter,
                            CompletionRequest &request, SearchFilter *searcher);
-
-private:
-  static CommonCompletionElement g_common_completions[];
 };
 
 } // namespace lldb_private

diff  --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp
index 31c8e6ab17cc..bc3a2ec4bd9e 100644
--- a/lldb/source/Commands/CommandCompletions.cpp
+++ b/lldb/source/Commands/CommandCompletions.cpp
@@ -27,18 +27,17 @@
 
 using namespace lldb_private;
 
-CommandCompletions::CommonCompletionElement
-    CommandCompletions::g_common_completions[] = {
-        {eSourceFileCompletion, CommandCompletions::SourceFiles},
-        {eDiskFileCompletion, CommandCompletions::DiskFiles},
-        {eDiskDirectoryCompletion, CommandCompletions::DiskDirectories},
-        {eSymbolCompletion, CommandCompletions::Symbols},
-        {eModuleCompletion, CommandCompletions::Modules},
-        {eSettingsNameCompletion, CommandCompletions::SettingsNames},
-        {ePlatformPluginCompletion, CommandCompletions::PlatformPluginNames},
-        {eArchitectureCompletion, CommandCompletions::ArchitectureNames},
-        {eVariablePathCompletion, CommandCompletions::VariablePath},
-        {eNoCompletion, nullptr} // This one has to be last in the list.
+// This is the command completion callback that is used to complete the
+// argument of the option it is bound to (in the OptionDefinition table
+// below).
+typedef void (*CompletionCallback)(CommandInterpreter &interpreter,
+                                   CompletionRequest &request,
+                                   // A search filter to limit the search...
+                                   lldb_private::SearchFilter *searcher);
+
+struct CommonCompletionElement {
+  uint32_t type;
+  CompletionCallback callback;
 };
 
 bool CommandCompletions::InvokeCommonCompletionCallbacks(
@@ -46,14 +45,27 @@ bool CommandCompletions::InvokeCommonCompletionCallbacks(
     CompletionRequest &request, SearchFilter *searcher) {
   bool handled = false;
 
+  const CommonCompletionElement common_completions[] = {
+      {eSourceFileCompletion, CommandCompletions::SourceFiles},
+      {eDiskFileCompletion, CommandCompletions::DiskFiles},
+      {eDiskDirectoryCompletion, CommandCompletions::DiskDirectories},
+      {eSymbolCompletion, CommandCompletions::Symbols},
+      {eModuleCompletion, CommandCompletions::Modules},
+      {eSettingsNameCompletion, CommandCompletions::SettingsNames},
+      {ePlatformPluginCompletion, CommandCompletions::PlatformPluginNames},
+      {eArchitectureCompletion, CommandCompletions::ArchitectureNames},
+      {eVariablePathCompletion, CommandCompletions::VariablePath},
+      {eNoCompletion, nullptr} // This one has to be last in the list.
+  };
+
   for (int i = 0;; i++) {
-    if (g_common_completions[i].type == eNoCompletion)
+    if (common_completions[i].type == eNoCompletion)
       break;
-    else if ((g_common_completions[i].type & completion_mask) ==
-                 g_common_completions[i].type &&
-             g_common_completions[i].callback != nullptr) {
+    else if ((common_completions[i].type & completion_mask) ==
+                 common_completions[i].type &&
+             common_completions[i].callback != nullptr) {
       handled = true;
-      g_common_completions[i].callback(interpreter, request, searcher);
+      common_completions[i].callback(interpreter, request, searcher);
     }
   }
   return handled;


        


More information about the lldb-commits mailing list