[Lldb-commits] [lldb] 6a9c3e6 - [lldb/Commands] Add support to auto-completion for user commands

Med Ismail Bennani via lldb-commits lldb-commits at lists.llvm.org
Tue Jun 6 10:58:52 PDT 2023


Author: Med Ismail Bennani
Date: 2023-06-06T10:58:34-07:00
New Revision: 6a9c3e611505b7637b46fbaacaf50362c97a263d

URL: https://github.com/llvm/llvm-project/commit/6a9c3e611505b7637b46fbaacaf50362c97a263d
DIFF: https://github.com/llvm/llvm-project/commit/6a9c3e611505b7637b46fbaacaf50362c97a263d.diff

LOG: [lldb/Commands] Add support to auto-completion for user commands

This patch should allow the user to set specific auto-completion type
for their custom commands.

To do so, we had to hoist the `CompletionType` enum so the user can
access it and add a new completion type flag to the CommandScriptAdd
Command Object.

So now, the user can specify which completion type will be used with
their custom command, when they register it.

This also makes the `crashlog` custom commands use disk-file completion
type, to browse through the user file system and load the report.

Differential Revision: https://reviews.llvm.org/D152011

Signed-off-by: Med Ismail Bennani <ismail at bennani.ma>

Added: 
    lldb/test/API/functionalities/completion/my_test_cmd.py

Modified: 
    lldb/docs/python_api_enums.rst
    lldb/examples/python/crashlog.py
    lldb/include/lldb/Interpreter/CommandCompletions.h
    lldb/include/lldb/Interpreter/CommandObject.h
    lldb/include/lldb/Interpreter/CommandOptionArgumentTable.h
    lldb/include/lldb/Interpreter/OptionValueFileColonLine.h
    lldb/include/lldb/Interpreter/OptionValueFileSpec.h
    lldb/include/lldb/Utility/OptionDefinition.h
    lldb/include/lldb/lldb-enumerations.h
    lldb/source/Commands/CommandCompletions.cpp
    lldb/source/Commands/CommandObjectBreakpoint.cpp
    lldb/source/Commands/CommandObjectCommands.cpp
    lldb/source/Commands/CommandObjectDWIMPrint.cpp
    lldb/source/Commands/CommandObjectFrame.cpp
    lldb/source/Commands/CommandObjectPlatform.cpp
    lldb/source/Commands/CommandObjectPlugin.cpp
    lldb/source/Commands/CommandObjectProcess.cpp
    lldb/source/Commands/CommandObjectRegexCommand.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/CommandObjectTrace.cpp
    lldb/source/Commands/CommandObjectType.cpp
    lldb/source/Commands/CommandObjectWatchpoint.cpp
    lldb/source/Commands/Options.td
    lldb/source/Core/IOHandler.cpp
    lldb/source/Core/IOHandlerCursesGUI.cpp
    lldb/source/Interpreter/CommandInterpreter.cpp
    lldb/source/Interpreter/OptionValueArch.cpp
    lldb/source/Interpreter/OptionValueFileColonLine.cpp
    lldb/source/Interpreter/OptionValueFileSpec.cpp
    lldb/source/Interpreter/Options.cpp
    lldb/test/API/functionalities/completion/TestCompletion.py
    lldb/utils/TableGen/LLDBOptionDefEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/docs/python_api_enums.rst b/lldb/docs/python_api_enums.rst
index 3fbaaec78cbef..e34f4656b6ad8 100644
--- a/lldb/docs/python_api_enums.rst
+++ b/lldb/docs/python_api_enums.rst
@@ -876,6 +876,7 @@ CommandArgumentType
 .. py:data:: eArgTypeColumnNum
 .. py:data:: eArgTypeModuleUUID
 .. py:data:: eArgTypeLastArg
+.. py:data:: eArgTypeCompletionType
 
 .. _SymbolType:
 

diff  --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py
index 8f7bde3429b8f..4a14e99bea10e 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -1666,10 +1666,10 @@ def should_run_in_interactive_mode(options, ci):
 
 def __lldb_init_module(debugger, internal_dict):
     debugger.HandleCommand(
-        "command script add -o -c lldb.macosx.crashlog.Symbolicate crashlog"
+        "command script add -o -c lldb.macosx.crashlog.Symbolicate -C disk-file crashlog"
     )
     debugger.HandleCommand(
-        "command script add -o -f lldb.macosx.crashlog.save_crashlog save_crashlog"
+        "command script add -o -f lldb.macosx.crashlog.save_crashlog -C disk-file save_crashlog"
     )
     print(
         '"crashlog" and "save_crashlog" commands have been installed, use '

diff  --git a/lldb/include/lldb/Interpreter/CommandCompletions.h b/lldb/include/lldb/Interpreter/CommandCompletions.h
index 8578782e9fdd7..a89a5be95b801 100644
--- a/lldb/include/lldb/Interpreter/CommandCompletions.h
+++ b/lldb/include/lldb/Interpreter/CommandCompletions.h
@@ -24,39 +24,6 @@ namespace lldb_private {
 class TildeExpressionResolver;
 class CommandCompletions {
 public:
-  enum CommonCompletionTypes {
-    eNoCompletion = 0u,
-    eSourceFileCompletion = (1u << 0),
-    eDiskFileCompletion = (1u << 1),
-    eDiskDirectoryCompletion = (1u << 2),
-    eSymbolCompletion = (1u << 3),
-    eModuleCompletion = (1u << 4),
-    eSettingsNameCompletion = (1u << 5),
-    ePlatformPluginCompletion = (1u << 6),
-    eArchitectureCompletion = (1u << 7),
-    eVariablePathCompletion = (1u << 8),
-    eRegisterCompletion = (1u << 9),
-    eBreakpointCompletion = (1u << 10),
-    eProcessPluginCompletion = (1u << 11),
-    eDisassemblyFlavorCompletion = (1u << 12),
-    eTypeLanguageCompletion = (1u << 13),
-    eFrameIndexCompletion = (1u << 14),
-    eModuleUUIDCompletion = (1u << 15),
-    eStopHookIDCompletion = (1u << 16),
-    eThreadIndexCompletion = (1u << 17),
-    eWatchPointIDCompletion = (1u << 18),
-    eBreakpointNameCompletion = (1u << 19),
-    eProcessIDCompletion = (1u << 20),
-    eProcessNameCompletion = (1u << 21),
-    eRemoteDiskFileCompletion = (1u << 22),
-    eRemoteDiskDirectoryCompletion = (1u << 23),
-    eTypeCategoryNameCompletion = (1u << 24),
-    // This item serves two purposes.  It is the last element in the enum, so
-    // you can add custom enums starting from here in your Option class. Also
-    // if you & in this bit the base code will not process the option.
-    eCustomCompletion = (1u << 24)
-  };
-
   static bool InvokeCommonCompletionCallbacks(
       CommandInterpreter &interpreter, uint32_t completion_mask,
       lldb_private::CompletionRequest &request, SearchFilter *searcher);

diff  --git a/lldb/include/lldb/Interpreter/CommandObject.h b/lldb/include/lldb/Interpreter/CommandObject.h
index 86750a49bd323..c601570ab90e8 100644
--- a/lldb/include/lldb/Interpreter/CommandObject.h
+++ b/lldb/include/lldb/Interpreter/CommandObject.h
@@ -83,7 +83,7 @@ class CommandObject : public std::enable_shared_from_this<CommandObject> {
   struct ArgumentTableEntry {
     lldb::CommandArgumentType arg_type;
     const char *arg_name;
-    CommandCompletions::CommonCompletionTypes completion_type;
+    lldb::CompletionType completion_type;
     OptionEnumValues enum_values;
     ArgumentHelpCallback help_function;
     const char *help_text;

diff  --git a/lldb/include/lldb/Interpreter/CommandOptionArgumentTable.h b/lldb/include/lldb/Interpreter/CommandOptionArgumentTable.h
index 233ad34ff0f5d..4bf71393bb07d 100644
--- a/lldb/include/lldb/Interpreter/CommandOptionArgumentTable.h
+++ b/lldb/include/lldb/Interpreter/CommandOptionArgumentTable.h
@@ -149,6 +149,51 @@ static constexpr OptionEnumValueElement g_running_mode[] = {
      "Run only this thread while stepping"},
 };
 
+static constexpr OptionEnumValueElement g_completion_type[] = {
+    {lldb::eNoCompletion, "none", "No completion."},
+    {lldb::eSourceFileCompletion, "source-file", "Completes to a source file."},
+    {lldb::eDiskFileCompletion, "disk-file", "Completes to a disk file."},
+    {lldb::eDiskDirectoryCompletion, "disk-directory",
+     "Completes to a disk directory."},
+    {lldb::eSymbolCompletion, "symbol", "Completes to a symbol."},
+    {lldb::eModuleCompletion, "module", "Completes to a module."},
+    {lldb::eSettingsNameCompletion, "settings-name",
+     "Completes to a settings name."},
+    {lldb::ePlatformPluginCompletion, "platform-plugin",
+     "Completes to a platform plugin."},
+    {lldb::eArchitectureCompletion, "architecture",
+     "Completes to a architecture."},
+    {lldb::eVariablePathCompletion, "variable-path",
+     "Completes to a variable path."},
+    {lldb::eRegisterCompletion, "register", "Completes to a register."},
+    {lldb::eBreakpointCompletion, "breakpoint", "Completes to a breakpoint."},
+    {lldb::eProcessPluginCompletion, "process-plugin",
+     "Completes to a process plugin."},
+    {lldb::eDisassemblyFlavorCompletion, "disassembly-flavor",
+     "Completes to a disassembly flavor."},
+    {lldb::eTypeLanguageCompletion, "type-language",
+     "Completes to a type language."},
+    {lldb::eFrameIndexCompletion, "frame-index", "Completes to a frame index."},
+    {lldb::eModuleUUIDCompletion, "module-uuid", "Completes to a module uuid."},
+    {lldb::eStopHookIDCompletion, "stophook-id", "Completes to a stophook id."},
+    {lldb::eThreadIndexCompletion, "thread-index",
+     "Completes to a thread index."},
+    {lldb::eWatchpointIDCompletion, "watchpoint-id",
+     "Completes to a watchpoint id."},
+    {lldb::eBreakpointNameCompletion, "breakpoint-name",
+     "Completes to a breakpoint name."},
+    {lldb::eProcessIDCompletion, "process-id", "Completes to a process id."},
+    {lldb::eProcessNameCompletion, "process-name",
+     "Completes to a process name."},
+    {lldb::eRemoteDiskFileCompletion, "remote-disk-file",
+     "Completes to a remote disk file."},
+    {lldb::eRemoteDiskDirectoryCompletion, "remote-disk-directory",
+     "Completes to a remote disk directory."},
+    {lldb::eTypeCategoryNameCompletion, "type-category-name",
+     "Completes to a type category name."},
+    {lldb::eCustomCompletion, "custom", "Custom completion."},
+};
+
 llvm::StringRef RegisterNameHelpTextCallback();
 llvm::StringRef BreakpointIDHelpTextCallback();
 llvm::StringRef BreakpointIDRangeHelpTextCallback();
@@ -162,101 +207,102 @@ llvm::StringRef arch_helper();
 
 static constexpr CommandObject::ArgumentTableEntry g_argument_table[] = {
     // clang-format off
-    { lldb::eArgTypeAddress, "address", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "A valid address in the target program's execution space." },
-    { lldb::eArgTypeAddressOrExpression, "address-expression", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "An expression that resolves to an address." },
-    { lldb::eArgTypeAliasName, "alias-name", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "The name of an abbreviation (alias) for a debugger command." },
-    { lldb::eArgTypeAliasOptions, "options-for-aliased-command", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "Command options to be used as part of an alias (abbreviation) definition.  (See 'help commands alias' for more information.)" },
-    { lldb::eArgTypeArchitecture, "arch", CommandCompletions::eArchitectureCompletion, {}, { arch_helper, true }, "The architecture name, e.g. i386 or x86_64." },
-    { lldb::eArgTypeBoolean, "boolean", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "A Boolean value: 'true' or 'false'" },
-    { lldb::eArgTypeBreakpointID, "breakpt-id", CommandCompletions::eNoCompletion, {}, { BreakpointIDHelpTextCallback, false }, nullptr },
-    { lldb::eArgTypeBreakpointIDRange, "breakpt-id-list", CommandCompletions::eNoCompletion, {}, { BreakpointIDRangeHelpTextCallback, false }, nullptr },
-    { lldb::eArgTypeBreakpointName, "breakpoint-name", CommandCompletions::eBreakpointNameCompletion, {}, { BreakpointNameHelpTextCallback, false }, nullptr },
-    { lldb::eArgTypeByteSize, "byte-size", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "Number of bytes to use." },
-    { lldb::eArgTypeClassName, "class-name", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "Then name of a class from the debug information in the program." },
-    { lldb::eArgTypeCommandName, "cmd-name", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "A debugger command (may be multiple words), without any options or arguments." },
-    { lldb::eArgTypeCount, "count", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "An unsigned integer." },
-    { lldb::eArgTypeDescriptionVerbosity, "description-verbosity", CommandCompletions::eNoCompletion, g_description_verbosity_type, { nullptr, false }, "How verbose the output of 'po' should be." },
-    { lldb::eArgTypeDirectoryName, "directory", CommandCompletions::eDiskDirectoryCompletion, {}, { nullptr, false }, "A directory name." },
-    { lldb::eArgTypeDisassemblyFlavor, "disassembly-flavor", CommandCompletions::eDisassemblyFlavorCompletion, {}, { nullptr, false }, "A disassembly flavor recognized by your disassembly plugin.  Currently the only valid options are \"att\" and \"intel\" for Intel targets" },
-    { lldb::eArgTypeEndAddress, "end-address", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "Help text goes here." },
-    { lldb::eArgTypeExpression, "expr", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "Help text goes here." },
-    { lldb::eArgTypeExpressionPath, "expr-path", CommandCompletions::eNoCompletion, {}, { ExprPathHelpTextCallback, true }, nullptr },
-    { lldb::eArgTypeExprFormat, "expression-format", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "[ [bool|b] | [bin] | [char|c] | [oct|o] | [dec|i|d|u] | [hex|x] | [float|f] | [cstr|s] ]" },
-    { lldb::eArgTypeFileLineColumn, "linespec", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "A source specifier in the form file:line[:column]" },
-    { lldb::eArgTypeFilename, "filename", CommandCompletions::eDiskFileCompletion, {}, { nullptr, false }, "The name of a file (can include path)." },
-    { lldb::eArgTypeFormat, "format", CommandCompletions::eNoCompletion, {}, { FormatHelpTextCallback, true }, nullptr },
-    { lldb::eArgTypeFrameIndex, "frame-index", CommandCompletions::eFrameIndexCompletion, {}, { nullptr, false }, "Index into a thread's list of frames." },
-    { lldb::eArgTypeFullName, "fullname", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "Help text goes here." },
-    { lldb::eArgTypeFunctionName, "function-name", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "The name of a function." },
-    { lldb::eArgTypeFunctionOrSymbol, "function-or-symbol", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "The name of a function or symbol." },
-    { lldb::eArgTypeGDBFormat, "gdb-format", CommandCompletions::eNoCompletion, {}, { GDBFormatHelpTextCallback, true }, nullptr },
-    { lldb::eArgTypeHelpText, "help-text", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "Text to be used as help for some other entity in LLDB" },
-    { lldb::eArgTypeIndex, "index", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "An index into a list." },
-    { lldb::eArgTypeLanguage, "source-language", CommandCompletions::eTypeLanguageCompletion, {}, { LanguageTypeHelpTextCallback, true }, nullptr },
-    { lldb::eArgTypeLineNum, "linenum", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "Line number in a source file." },
-    { lldb::eArgTypeLogCategory, "log-category", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "The name of a category within a log channel, e.g. all (try \"log list\" to see a list of all channels and their categories." },
-    { lldb::eArgTypeLogChannel, "log-channel", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "The name of a log channel, e.g. process.gdb-remote (try \"log list\" to see a list of all channels and their categories)." },
-    { lldb::eArgTypeMethod, "method", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "A C++ method name." },
-    { lldb::eArgTypeName, "name", CommandCompletions::eTypeCategoryNameCompletion, {}, { nullptr, false }, "Help text goes here." },
-    { lldb::eArgTypeNewPathPrefix, "new-path-prefix", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "Help text goes here." },
-    { lldb::eArgTypeNumLines, "num-lines", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "The number of lines to use." },
-    { lldb::eArgTypeNumberPerLine, "number-per-line", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "The number of items per line to display." },
-    { lldb::eArgTypeOffset, "offset", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "Help text goes here." },
-    { lldb::eArgTypeOldPathPrefix, "old-path-prefix", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "Help text goes here." },
-    { lldb::eArgTypeOneLiner, "one-line-command", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "A command that is entered as a single line of text." },
-    { lldb::eArgTypePath, "path", CommandCompletions::eDiskFileCompletion, {}, { nullptr, false }, "Path." },
-    { lldb::eArgTypePermissionsNumber, "perms-numeric", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "Permissions given as an octal number (e.g. 755)." },
-    { lldb::eArgTypePermissionsString, "perms=string", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "Permissions given as a string value (e.g. rw-r-xr--)." },
-    { lldb::eArgTypePid, "pid", CommandCompletions::eProcessIDCompletion, {}, { nullptr, false }, "The process ID number." },
-    { lldb::eArgTypePlugin, "plugin", CommandCompletions::eProcessPluginCompletion, {}, { nullptr, false }, "Help text goes here." },
-    { lldb::eArgTypeProcessName, "process-name", CommandCompletions::eProcessNameCompletion, {}, { nullptr, false }, "The name of the process." },
-    { lldb::eArgTypePythonClass, "python-class", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "The name of a Python class." },
-    { lldb::eArgTypePythonFunction, "python-function", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "The name of a Python function." },
-    { lldb::eArgTypePythonScript, "python-script", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "Source code written in Python." },
-    { lldb::eArgTypeQueueName, "queue-name", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "The name of the thread queue." },
-    { lldb::eArgTypeRegisterName, "register-name", CommandCompletions::eNoCompletion, {}, { RegisterNameHelpTextCallback, true }, nullptr },
-    { lldb::eArgTypeRegularExpression, "regular-expression", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "A POSIX-compliant extended regular expression." },
-    { lldb::eArgTypeRunArgs, "run-args", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "Arguments to be passed to the target program when it starts executing." },
-    { lldb::eArgTypeRunMode, "run-mode", CommandCompletions::eNoCompletion, g_running_mode, { nullptr, false }, "Help text goes here." },
-    { lldb::eArgTypeScriptedCommandSynchronicity, "script-cmd-synchronicity", CommandCompletions::eNoCompletion, g_script_synchro_type, { nullptr, false }, "The synchronicity to use to run scripted commands with regard to LLDB event system." },
-    { lldb::eArgTypeScriptLang, "script-language", CommandCompletions::eNoCompletion, g_script_option_enumeration, { nullptr, false }, "The scripting language to be used for script-based commands.  Supported languages are python and lua." },
-    { lldb::eArgTypeSearchWord, "search-word", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "Any word of interest for search purposes." },
-    { lldb::eArgTypeSelector, "selector", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "An Objective-C selector name." },
-    { lldb::eArgTypeSettingIndex, "setting-index", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "An index into a settings variable that is an array (try 'settings list' to see all the possible settings variables and their types)." },
-    { lldb::eArgTypeSettingKey, "setting-key", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "A key into a settings variables that is a dictionary (try 'settings list' to see all the possible settings variables and their types)." },
-    { lldb::eArgTypeSettingPrefix, "setting-prefix", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "The name of a settable internal debugger variable up to a dot ('.'), e.g. 'target.process.'" },
-    { lldb::eArgTypeSettingVariableName, "setting-variable-name", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "The name of a settable internal debugger variable.  Type 'settings list' to see a complete list of such variables." },
-    { lldb::eArgTypeShlibName, "shlib-name", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "The name of a shared library." },
-    { lldb::eArgTypeSourceFile, "source-file", CommandCompletions::eSourceFileCompletion, {}, { nullptr, false }, "The name of a source file.." },
-    { lldb::eArgTypeSortOrder, "sort-order", CommandCompletions::eNoCompletion, g_sort_option_enumeration, { nullptr, false }, "Specify a sort order when dumping lists." },
-    { lldb::eArgTypeStartAddress, "start-address", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "Help text goes here." },
-    { lldb::eArgTypeSummaryString, "summary-string", CommandCompletions::eNoCompletion, {}, { SummaryStringHelpTextCallback, true }, nullptr },
-    { lldb::eArgTypeSymbol, "symbol", CommandCompletions::eSymbolCompletion, {}, { nullptr, false }, "Any symbol name (function name, variable, argument, etc.)" },
-    { lldb::eArgTypeThreadID, "thread-id", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "Thread ID number." },
-    { lldb::eArgTypeThreadIndex, "thread-index", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "Index into the process' list of threads." },
-    { lldb::eArgTypeThreadName, "thread-name", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "The thread's name." },
-    { lldb::eArgTypeTypeName, "type-name", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "A type name." },
-    { lldb::eArgTypeUnsignedInteger, "unsigned-integer", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "An unsigned integer." },
-    { lldb::eArgTypeUnixSignal, "unix-signal", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "A valid Unix signal name or number (e.g. SIGKILL, KILL or 9)." },
-    { lldb::eArgTypeVarName, "variable-name", CommandCompletions::eNoCompletion, {} ,{ nullptr, false }, "The name of a variable in your program." },
-    { lldb::eArgTypeValue, "value", CommandCompletions::eNoCompletion, g_dependents_enumeration, { nullptr, false }, "A value could be anything, depending on where and how it is used." },
-    { lldb::eArgTypeWidth, "width", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "Help text goes here." },
-    { lldb::eArgTypeNone, "none", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "No help available for this." },
-    { lldb::eArgTypePlatform, "platform-name", CommandCompletions::ePlatformPluginCompletion, {}, { nullptr, false }, "The name of an installed platform plug-in . Type 'platform list' to see a complete list of installed platforms." },
-    { lldb::eArgTypeWatchpointID, "watchpt-id", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "Watchpoint IDs are positive integers." },
-    { lldb::eArgTypeWatchpointIDRange, "watchpt-id-list", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "For example, '1-3' or '1 to 3'." },
-    { lldb::eArgTypeWatchType, "watch-type", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "Specify the type for a watchpoint." },
-    { lldb::eArgRawInput, "raw-input", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "Free-form text passed to a command without prior interpretation, allowing spaces without requiring quotes.  To pass arguments and free form text put two dashes ' -- ' between the last argument and any raw input." },
-    { lldb::eArgTypeCommand, "command", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "An LLDB Command line command element." },
-    { lldb::eArgTypeColumnNum, "column", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "Column number in a source file." },
-    { lldb::eArgTypeModuleUUID, "module-uuid", CommandCompletions::eModuleUUIDCompletion, {}, { nullptr, false }, "A module UUID value." },
-    { lldb::eArgTypeSaveCoreStyle, "corefile-style", CommandCompletions::eNoCompletion, g_corefile_save_style, { nullptr, false }, "The type of corefile that lldb will try to create, dependant on this target's capabilities." },
-    { lldb::eArgTypeLogHandler, "log-handler", CommandCompletions::eNoCompletion, g_log_handler_type ,{ nullptr, false }, "The log handle that will be used to write out log messages." },
-    { lldb::eArgTypeSEDStylePair, "substitution-pair", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "A sed-style pattern and target pair." },
-    { lldb::eArgTypeRecognizerID, "frame-recognizer-id", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "The ID for a stack frame recognizer." },
-    { lldb::eArgTypeConnectURL, "process-connect-url", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "A URL-style specification for a remote connection." },
-    { lldb::eArgTypeTargetID, "target-id", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "The index ID for an lldb Target." },
-    { lldb::eArgTypeStopHookID, "stop-hook-id", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "The ID you receive when you create a stop-hook." },
+    { lldb::eArgTypeAddress, "address", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "A valid address in the target program's execution space." },
+    { lldb::eArgTypeAddressOrExpression, "address-expression", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "An expression that resolves to an address." },
+    { lldb::eArgTypeAliasName, "alias-name", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The name of an abbreviation (alias) for a debugger command." },
+    { lldb::eArgTypeAliasOptions, "options-for-aliased-command", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Command options to be used as part of an alias (abbreviation) definition.  (See 'help commands alias' for more information.)" },
+    { lldb::eArgTypeArchitecture, "arch", lldb::eArchitectureCompletion, {}, { arch_helper, true }, "The architecture name, e.g. i386 or x86_64." },
+    { lldb::eArgTypeBoolean, "boolean", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "A Boolean value: 'true' or 'false'" },
+    { lldb::eArgTypeBreakpointID, "breakpt-id", lldb::CompletionType::eNoCompletion, {}, { BreakpointIDHelpTextCallback, false }, nullptr },
+    { lldb::eArgTypeBreakpointIDRange, "breakpt-id-list", lldb::CompletionType::eNoCompletion, {}, { BreakpointIDRangeHelpTextCallback, false }, nullptr },
+    { lldb::eArgTypeBreakpointName, "breakpoint-name", lldb::eBreakpointNameCompletion, {}, { BreakpointNameHelpTextCallback, false }, nullptr },
+    { lldb::eArgTypeByteSize, "byte-size", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Number of bytes to use." },
+    { lldb::eArgTypeClassName, "class-name", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Then name of a class from the debug information in the program." },
+    { lldb::eArgTypeCommandName, "cmd-name", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "A debugger command (may be multiple words), without any options or arguments." },
+    { lldb::eArgTypeCount, "count", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "An unsigned integer." },
+    { lldb::eArgTypeDescriptionVerbosity, "description-verbosity", lldb::CompletionType::eNoCompletion, g_description_verbosity_type, { nullptr, false }, "How verbose the output of 'po' should be." },
+    { lldb::eArgTypeDirectoryName, "directory", lldb::eDiskDirectoryCompletion, {}, { nullptr, false }, "A directory name." },
+    { lldb::eArgTypeDisassemblyFlavor, "disassembly-flavor", lldb::eDisassemblyFlavorCompletion, {}, { nullptr, false }, "A disassembly flavor recognized by your disassembly plugin.  Currently the only valid options are \"att\" and \"intel\" for Intel targets" },
+    { lldb::eArgTypeEndAddress, "end-address", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Help text goes here." },
+    { lldb::eArgTypeExpression, "expr", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Help text goes here." },
+    { lldb::eArgTypeExpressionPath, "expr-path", lldb::CompletionType::eNoCompletion, {}, { ExprPathHelpTextCallback, true }, nullptr },
+    { lldb::eArgTypeExprFormat, "expression-format", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "[ [bool|b] | [bin] | [char|c] | [oct|o] | [dec|i|d|u] | [hex|x] | [float|f] | [cstr|s] ]" },
+    { lldb::eArgTypeFileLineColumn, "linespec", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "A source specifier in the form file:line[:column]" },
+    { lldb::eArgTypeFilename, "filename", lldb::eDiskFileCompletion, {}, { nullptr, false }, "The name of a file (can include path)." },
+    { lldb::eArgTypeFormat, "format", lldb::CompletionType::eNoCompletion, {}, { FormatHelpTextCallback, true }, nullptr },
+    { lldb::eArgTypeFrameIndex, "frame-index", lldb::eFrameIndexCompletion, {}, { nullptr, false }, "Index into a thread's list of frames." },
+    { lldb::eArgTypeFullName, "fullname", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Help text goes here." },
+    { lldb::eArgTypeFunctionName, "function-name", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The name of a function." },
+    { lldb::eArgTypeFunctionOrSymbol, "function-or-symbol", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The name of a function or symbol." },
+    { lldb::eArgTypeGDBFormat, "gdb-format", lldb::CompletionType::eNoCompletion, {}, { GDBFormatHelpTextCallback, true }, nullptr },
+    { lldb::eArgTypeHelpText, "help-text", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Text to be used as help for some other entity in LLDB" },
+    { lldb::eArgTypeIndex, "index", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "An index into a list." },
+    { lldb::eArgTypeLanguage, "source-language", lldb::eTypeLanguageCompletion, {}, { LanguageTypeHelpTextCallback, true }, nullptr },
+    { lldb::eArgTypeLineNum, "linenum", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Line number in a source file." },
+    { lldb::eArgTypeLogCategory, "log-category", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The name of a category within a log channel, e.g. all (try \"log list\" to see a list of all channels and their categories." },
+    { lldb::eArgTypeLogChannel, "log-channel", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The name of a log channel, e.g. process.gdb-remote (try \"log list\" to see a list of all channels and their categories)." },
+    { lldb::eArgTypeMethod, "method", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "A C++ method name." },
+    { lldb::eArgTypeName, "name", lldb::eTypeCategoryNameCompletion, {}, { nullptr, false }, "Help text goes here." },
+    { lldb::eArgTypeNewPathPrefix, "new-path-prefix", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Help text goes here." },
+    { lldb::eArgTypeNumLines, "num-lines", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The number of lines to use." },
+    { lldb::eArgTypeNumberPerLine, "number-per-line", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The number of items per line to display." },
+    { lldb::eArgTypeOffset, "offset", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Help text goes here." },
+    { lldb::eArgTypeOldPathPrefix, "old-path-prefix", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Help text goes here." },
+    { lldb::eArgTypeOneLiner, "one-line-command", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "A command that is entered as a single line of text." },
+    { lldb::eArgTypePath, "path", lldb::eDiskFileCompletion, {}, { nullptr, false }, "Path." },
+    { lldb::eArgTypePermissionsNumber, "perms-numeric", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Permissions given as an octal number (e.g. 755)." },
+    { lldb::eArgTypePermissionsString, "perms=string", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Permissions given as a string value (e.g. rw-r-xr--)." },
+    { lldb::eArgTypePid, "pid", lldb::eProcessIDCompletion, {}, { nullptr, false }, "The process ID number." },
+    { lldb::eArgTypePlugin, "plugin", lldb::eProcessPluginCompletion, {}, { nullptr, false }, "Help text goes here." },
+    { lldb::eArgTypeProcessName, "process-name", lldb::eProcessNameCompletion, {}, { nullptr, false }, "The name of the process." },
+    { lldb::eArgTypePythonClass, "python-class", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The name of a Python class." },
+    { lldb::eArgTypePythonFunction, "python-function", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The name of a Python function." },
+    { lldb::eArgTypePythonScript, "python-script", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Source code written in Python." },
+    { lldb::eArgTypeQueueName, "queue-name", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The name of the thread queue." },
+    { lldb::eArgTypeRegisterName, "register-name", lldb::CompletionType::eNoCompletion, {}, { RegisterNameHelpTextCallback, true }, nullptr },
+    { lldb::eArgTypeRegularExpression, "regular-expression", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "A POSIX-compliant extended regular expression." },
+    { lldb::eArgTypeRunArgs, "run-args", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Arguments to be passed to the target program when it starts executing." },
+    { lldb::eArgTypeRunMode, "run-mode", lldb::CompletionType::eNoCompletion, g_running_mode, { nullptr, false }, "Help text goes here." },
+    { lldb::eArgTypeScriptedCommandSynchronicity, "script-cmd-synchronicity", lldb::CompletionType::eNoCompletion, g_script_synchro_type, { nullptr, false }, "The synchronicity to use to run scripted commands with regard to LLDB event system." },
+    { lldb::eArgTypeScriptLang, "script-language", lldb::CompletionType::eNoCompletion, g_script_option_enumeration, { nullptr, false }, "The scripting language to be used for script-based commands.  Supported languages are python and lua." },
+    { lldb::eArgTypeSearchWord, "search-word", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Any word of interest for search purposes." },
+    { lldb::eArgTypeSelector, "selector", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "An Objective-C selector name." },
+    { lldb::eArgTypeSettingIndex, "setting-index", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "An index into a settings variable that is an array (try 'settings list' to see all the possible settings variables and their types)." },
+    { lldb::eArgTypeSettingKey, "setting-key", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "A key into a settings variables that is a dictionary (try 'settings list' to see all the possible settings variables and their types)." },
+    { lldb::eArgTypeSettingPrefix, "setting-prefix", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The name of a settable internal debugger variable up to a dot ('.'), e.g. 'target.process.'" },
+    { lldb::eArgTypeSettingVariableName, "setting-variable-name", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The name of a settable internal debugger variable.  Type 'settings list' to see a complete list of such variables." },
+    { lldb::eArgTypeShlibName, "shlib-name", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The name of a shared library." },
+    { lldb::eArgTypeSourceFile, "source-file", lldb::eSourceFileCompletion, {}, { nullptr, false }, "The name of a source file.." },
+    { lldb::eArgTypeSortOrder, "sort-order", lldb::CompletionType::eNoCompletion, g_sort_option_enumeration, { nullptr, false }, "Specify a sort order when dumping lists." },
+    { lldb::eArgTypeStartAddress, "start-address", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Help text goes here." },
+    { lldb::eArgTypeSummaryString, "summary-string", lldb::CompletionType::eNoCompletion, {}, { SummaryStringHelpTextCallback, true }, nullptr },
+    { lldb::eArgTypeSymbol, "symbol", lldb::eSymbolCompletion, {}, { nullptr, false }, "Any symbol name (function name, variable, argument, etc.)" },
+    { lldb::eArgTypeThreadID, "thread-id", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Thread ID number." },
+    { lldb::eArgTypeThreadIndex, "thread-index", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Index into the process' list of threads." },
+    { lldb::eArgTypeThreadName, "thread-name", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The thread's name." },
+    { lldb::eArgTypeTypeName, "type-name", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "A type name." },
+    { lldb::eArgTypeUnsignedInteger, "unsigned-integer", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "An unsigned integer." },
+    { lldb::eArgTypeUnixSignal, "unix-signal", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "A valid Unix signal name or number (e.g. SIGKILL, KILL or 9)." },
+    { lldb::eArgTypeVarName, "variable-name", lldb::CompletionType::eNoCompletion, {} ,{ nullptr, false }, "The name of a variable in your program." },
+    { lldb::eArgTypeValue, "value", lldb::CompletionType::eNoCompletion, g_dependents_enumeration, { nullptr, false }, "A value could be anything, depending on where and how it is used." },
+    { lldb::eArgTypeWidth, "width", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Help text goes here." },
+    { lldb::eArgTypeNone, "none", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "No help available for this." },
+    { lldb::eArgTypePlatform, "platform-name", lldb::ePlatformPluginCompletion, {}, { nullptr, false }, "The name of an installed platform plug-in . Type 'platform list' to see a complete list of installed platforms." },
+    { lldb::eArgTypeWatchpointID, "watchpt-id", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Watchpoint IDs are positive integers." },
+    { lldb::eArgTypeWatchpointIDRange, "watchpt-id-list", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "For example, '1-3' or '1 to 3'." },
+    { lldb::eArgTypeWatchType, "watch-type", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Specify the type for a watchpoint." },
+    { lldb::eArgRawInput, "raw-input", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Free-form text passed to a command without prior interpretation, allowing spaces without requiring quotes.  To pass arguments and free form text put two dashes ' -- ' between the last argument and any raw input." },
+    { lldb::eArgTypeCommand, "command", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "An LLDB Command line command element." },
+    { lldb::eArgTypeColumnNum, "column", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Column number in a source file." },
+    { lldb::eArgTypeModuleUUID, "module-uuid", lldb::eModuleUUIDCompletion, {}, { nullptr, false }, "A module UUID value." },
+    { lldb::eArgTypeSaveCoreStyle, "corefile-style", lldb::CompletionType::eNoCompletion, g_corefile_save_style, { nullptr, false }, "The type of corefile that lldb will try to create, dependant on this target's capabilities." },
+    { lldb::eArgTypeLogHandler, "log-handler", lldb::CompletionType::eNoCompletion, g_log_handler_type ,{ nullptr, false }, "The log handle that will be used to write out log messages." },
+    { lldb::eArgTypeSEDStylePair, "substitution-pair", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "A sed-style pattern and target pair." },
+    { lldb::eArgTypeRecognizerID, "frame-recognizer-id", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The ID for a stack frame recognizer." },
+    { lldb::eArgTypeConnectURL, "process-connect-url", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "A URL-style specification for a remote connection." },
+    { lldb::eArgTypeTargetID, "target-id", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The index ID for an lldb Target." },
+    { lldb::eArgTypeStopHookID, "stop-hook-id", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The ID you receive when you create a stop-hook." },
+    { lldb::eArgTypeCompletionType, "completion-type", lldb::CompletionType::eNoCompletion, g_completion_type, { nullptr, false }, "The completion type to use when adding custom commands. If none is specified, the command won't use auto-completion." },
     // clang-format on
 };
 

diff  --git a/lldb/include/lldb/Interpreter/OptionValueFileColonLine.h b/lldb/include/lldb/Interpreter/OptionValueFileColonLine.h
index 83d36edc1e9a0..181ef18bbcdf1 100644
--- a/lldb/include/lldb/Interpreter/OptionValueFileColonLine.h
+++ b/lldb/include/lldb/Interpreter/OptionValueFileColonLine.h
@@ -52,7 +52,7 @@ class OptionValueFileColonLine :
   FileSpec m_file_spec;
   uint32_t m_line_number = LLDB_INVALID_LINE_NUMBER;
   uint32_t m_column_number = LLDB_INVALID_COLUMN_NUMBER;
-  uint32_t m_completion_mask = CommandCompletions::eSourceFileCompletion;
+  uint32_t m_completion_mask = lldb::eSourceFileCompletion;
 };
 
 } // namespace lldb_private

diff  --git a/lldb/include/lldb/Interpreter/OptionValueFileSpec.h b/lldb/include/lldb/Interpreter/OptionValueFileSpec.h
index b680a89688d97..52349bf36262f 100644
--- a/lldb/include/lldb/Interpreter/OptionValueFileSpec.h
+++ b/lldb/include/lldb/Interpreter/OptionValueFileSpec.h
@@ -79,7 +79,7 @@ class OptionValueFileSpec : public Cloneable<OptionValueFileSpec, OptionValue> {
   FileSpec m_default_value;
   lldb::DataBufferSP m_data_sp;
   llvm::sys::TimePoint<> m_data_mod_time;
-  uint32_t m_completion_mask = CommandCompletions::eDiskFileCompletion;
+  uint32_t m_completion_mask = lldb::eDiskFileCompletion;
   bool m_resolve;
 };
 

diff  --git a/lldb/include/lldb/Utility/OptionDefinition.h b/lldb/include/lldb/Utility/OptionDefinition.h
index 082f0f0aa3fa6..096e687b622ab 100644
--- a/lldb/include/lldb/Utility/OptionDefinition.h
+++ b/lldb/include/lldb/Utility/OptionDefinition.h
@@ -38,7 +38,7 @@ struct OptionDefinition {
   /// If not empty, an array of enum values.
   OptionEnumValues enum_values;
   /// The kind of completion for this option.
-  /// Contains values of the CommandCompletions::CommonCompletionTypes enum.
+  /// Contains values of the lldb::CompletionType enum.
   uint32_t completion_type;
   /// Type of argument this option takes.
   lldb::CommandArgumentType argument_type;

diff  --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h
index 524a4789b813d..da5b88c1fb164 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -629,6 +629,7 @@ enum CommandArgumentType {
   eArgTypeConnectURL,
   eArgTypeTargetID,
   eArgTypeStopHookID,
+  eArgTypeCompletionType,
   eArgTypeLastArg // Always keep this entry as the last entry in this
                   // enumeration!!
 };
@@ -1245,6 +1246,39 @@ enum WatchpointValueKind {
   eWatchPointValueKindExpression = 2,
 };
 
+enum CompletionType {
+  eNoCompletion = 0u,
+  eSourceFileCompletion = (1u << 0),
+  eDiskFileCompletion = (1u << 1),
+  eDiskDirectoryCompletion = (1u << 2),
+  eSymbolCompletion = (1u << 3),
+  eModuleCompletion = (1u << 4),
+  eSettingsNameCompletion = (1u << 5),
+  ePlatformPluginCompletion = (1u << 6),
+  eArchitectureCompletion = (1u << 7),
+  eVariablePathCompletion = (1u << 8),
+  eRegisterCompletion = (1u << 9),
+  eBreakpointCompletion = (1u << 10),
+  eProcessPluginCompletion = (1u << 11),
+  eDisassemblyFlavorCompletion = (1u << 12),
+  eTypeLanguageCompletion = (1u << 13),
+  eFrameIndexCompletion = (1u << 14),
+  eModuleUUIDCompletion = (1u << 15),
+  eStopHookIDCompletion = (1u << 16),
+  eThreadIndexCompletion = (1u << 17),
+  eWatchpointIDCompletion = (1u << 18),
+  eBreakpointNameCompletion = (1u << 19),
+  eProcessIDCompletion = (1u << 20),
+  eProcessNameCompletion = (1u << 21),
+  eRemoteDiskFileCompletion = (1u << 22),
+  eRemoteDiskDirectoryCompletion = (1u << 23),
+  eTypeCategoryNameCompletion = (1u << 24),
+  // This item serves two purposes.  It is the last element in the enum, so
+  // you can add custom enums starting from here in your Option class. Also
+  // if you & in this bit the base code will not process the option.
+  eCustomCompletion = (1u << 25)
+};
+
 } // namespace lldb
 
 #endif // LLDB_LLDB_ENUMERATIONS_H

diff  --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp
index bacb00cfe35ff..1fe25d9655dc9 100644
--- a/lldb/source/Commands/CommandCompletions.cpp
+++ b/lldb/source/Commands/CommandCompletions.cpp
@@ -54,37 +54,41 @@ bool CommandCompletions::InvokeCommonCompletionCallbacks(
   bool handled = false;
 
   const CommonCompletionElement common_completions[] = {
-      {eSourceFileCompletion, CommandCompletions::SourceFiles},
-      {eDiskFileCompletion, CommandCompletions::DiskFiles},
-      {eDiskDirectoryCompletion, CommandCompletions::DiskDirectories},
-      {eSymbolCompletion, CommandCompletions::Symbols},
-      {eModuleCompletion, CommandCompletions::Modules},
-      {eModuleUUIDCompletion, CommandCompletions::ModuleUUIDs},
-      {eSettingsNameCompletion, CommandCompletions::SettingsNames},
-      {ePlatformPluginCompletion, CommandCompletions::PlatformPluginNames},
-      {eArchitectureCompletion, CommandCompletions::ArchitectureNames},
-      {eVariablePathCompletion, CommandCompletions::VariablePath},
-      {eRegisterCompletion, CommandCompletions::Registers},
-      {eBreakpointCompletion, CommandCompletions::Breakpoints},
-      {eProcessPluginCompletion, CommandCompletions::ProcessPluginNames},
-      {eDisassemblyFlavorCompletion, CommandCompletions::DisassemblyFlavors},
-      {eTypeLanguageCompletion, CommandCompletions::TypeLanguages},
-      {eFrameIndexCompletion, CommandCompletions::FrameIndexes},
-      {eStopHookIDCompletion, CommandCompletions::StopHookIDs},
-      {eThreadIndexCompletion, CommandCompletions::ThreadIndexes},
-      {eWatchPointIDCompletion, CommandCompletions::WatchPointIDs},
-      {eBreakpointNameCompletion, CommandCompletions::BreakpointNames},
-      {eProcessIDCompletion, CommandCompletions::ProcessIDs},
-      {eProcessNameCompletion, CommandCompletions::ProcessNames},
-      {eRemoteDiskFileCompletion, CommandCompletions::RemoteDiskFiles},
-      {eRemoteDiskDirectoryCompletion,
+      {lldb::eSourceFileCompletion, CommandCompletions::SourceFiles},
+      {lldb::eDiskFileCompletion, CommandCompletions::DiskFiles},
+      {lldb::eDiskDirectoryCompletion, CommandCompletions::DiskDirectories},
+      {lldb::eSymbolCompletion, CommandCompletions::Symbols},
+      {lldb::eModuleCompletion, CommandCompletions::Modules},
+      {lldb::eModuleUUIDCompletion, CommandCompletions::ModuleUUIDs},
+      {lldb::eSettingsNameCompletion, CommandCompletions::SettingsNames},
+      {lldb::ePlatformPluginCompletion,
+       CommandCompletions::PlatformPluginNames},
+      {lldb::eArchitectureCompletion, CommandCompletions::ArchitectureNames},
+      {lldb::eVariablePathCompletion, CommandCompletions::VariablePath},
+      {lldb::eRegisterCompletion, CommandCompletions::Registers},
+      {lldb::eBreakpointCompletion, CommandCompletions::Breakpoints},
+      {lldb::eProcessPluginCompletion, CommandCompletions::ProcessPluginNames},
+      {lldb::eDisassemblyFlavorCompletion,
+       CommandCompletions::DisassemblyFlavors},
+      {lldb::eTypeLanguageCompletion, CommandCompletions::TypeLanguages},
+      {lldb::eFrameIndexCompletion, CommandCompletions::FrameIndexes},
+      {lldb::eStopHookIDCompletion, CommandCompletions::StopHookIDs},
+      {lldb::eThreadIndexCompletion, CommandCompletions::ThreadIndexes},
+      {lldb::eWatchpointIDCompletion, CommandCompletions::WatchPointIDs},
+      {lldb::eBreakpointNameCompletion, CommandCompletions::BreakpointNames},
+      {lldb::eProcessIDCompletion, CommandCompletions::ProcessIDs},
+      {lldb::eProcessNameCompletion, CommandCompletions::ProcessNames},
+      {lldb::eRemoteDiskFileCompletion, CommandCompletions::RemoteDiskFiles},
+      {lldb::eRemoteDiskDirectoryCompletion,
        CommandCompletions::RemoteDiskDirectories},
-      {eTypeCategoryNameCompletion, CommandCompletions::TypeCategoryNames},
-      {eNoCompletion, nullptr} // This one has to be last in the list.
+      {lldb::eTypeCategoryNameCompletion,
+       CommandCompletions::TypeCategoryNames},
+      {lldb::CompletionType::eNoCompletion,
+       nullptr} // This one has to be last in the list.
   };
 
   for (int i = 0;; i++) {
-    if (common_completions[i].type == eNoCompletion)
+    if (common_completions[i].type == lldb::eNoCompletion)
       break;
     else if ((common_completions[i].type & completion_mask) ==
                  common_completions[i].type &&

diff  --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp
index 30d2434981016..327dae4fd2afb 100644
--- a/lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -828,9 +828,8 @@ class CommandObjectBreakpointModify : public CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eBreakpointCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eBreakpointCompletion, request, nullptr);
   }
 
   Options *GetOptions() override { return &m_options; }
@@ -902,9 +901,8 @@ class CommandObjectBreakpointEnable : public CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eBreakpointCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eBreakpointCompletion, request, nullptr);
   }
 
 protected:
@@ -1017,9 +1015,8 @@ the second re-enables the first location.");
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eBreakpointCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eBreakpointCompletion, request, nullptr);
   }
 
 protected:
@@ -1394,9 +1391,8 @@ class CommandObjectBreakpointDelete : public CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eBreakpointCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eBreakpointCompletion, request, nullptr);
   }
 
   Options *GetOptions() override { return &m_options; }
@@ -1803,9 +1799,8 @@ class CommandObjectBreakpointNameAdd : public CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eBreakpointCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eBreakpointCompletion, request, nullptr);
   }
 
   Options *GetOptions() override { return &m_option_group; }
@@ -1887,9 +1882,8 @@ class CommandObjectBreakpointNameDelete : public CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eBreakpointCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eBreakpointCompletion, request, nullptr);
   }
 
   Options *GetOptions() override { return &m_option_group; }
@@ -2203,9 +2197,8 @@ class CommandObjectBreakpointRead : public CommandObjectParsed {
 
       switch (GetDefinitions()[opt_defs_index].short_option) {
       case 'f':
-        CommandCompletions::InvokeCommonCompletionCallbacks(
-            interpreter, CommandCompletions::eDiskFileCompletion, request,
-            nullptr);
+        lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+            interpreter, lldb::eDiskFileCompletion, request, nullptr);
         break;
 
       case 'N':
@@ -2343,9 +2336,8 @@ class CommandObjectBreakpointWrite : public CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eBreakpointCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eBreakpointCompletion, request, nullptr);
   }
 
   Options *GetOptions() override { return &m_options; }

diff  --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp
index 254e226772dfa..656ace223b5f1 100644
--- a/lldb/source/Commands/CommandObjectCommands.cpp
+++ b/lldb/source/Commands/CommandObjectCommands.cpp
@@ -66,9 +66,8 @@ class CommandObjectCommandsSource : public CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eDiskFileCompletion, request, nullptr);
   }
 
   Options *GetOptions() override { return &m_options; }
@@ -1080,9 +1079,10 @@ class CommandObjectPythonFunction : public CommandObjectRaw {
 public:
   CommandObjectPythonFunction(CommandInterpreter &interpreter, std::string name,
                               std::string funct, std::string help,
-                              ScriptedCommandSynchronicity synch)
+                              ScriptedCommandSynchronicity synch,
+                              CompletionType completion_type)
       : CommandObjectRaw(interpreter, name), m_function_name(funct),
-        m_synchro(synch) {
+        m_synchro(synch), m_completion_type(completion_type) {
     if (!help.empty())
       SetHelp(help);
     else {
@@ -1116,6 +1116,15 @@ class CommandObjectPythonFunction : public CommandObjectRaw {
     return CommandObjectRaw::GetHelpLong();
   }
 
+  void
+  HandleArgumentCompletion(CompletionRequest &request,
+                           OptionElementVector &opt_element_vector) override {
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), m_completion_type, request, nullptr);
+  }
+
+  bool WantsCompletion() override { return true; }
+
 protected:
   bool DoExecute(llvm::StringRef raw_command_line,
                  CommandReturnObject &result) override {
@@ -1146,6 +1155,7 @@ class CommandObjectPythonFunction : public CommandObjectRaw {
   std::string m_function_name;
   ScriptedCommandSynchronicity m_synchro;
   bool m_fetched_help_long = false;
+  CompletionType m_completion_type = eNoCompletion;
 };
 
 class CommandObjectScriptingObject : public CommandObjectRaw {
@@ -1153,10 +1163,11 @@ class CommandObjectScriptingObject : public CommandObjectRaw {
   CommandObjectScriptingObject(CommandInterpreter &interpreter,
                                std::string name,
                                StructuredData::GenericSP cmd_obj_sp,
-                               ScriptedCommandSynchronicity synch)
+                               ScriptedCommandSynchronicity synch,
+                               CompletionType completion_type)
       : CommandObjectRaw(interpreter, name), m_cmd_obj_sp(cmd_obj_sp),
         m_synchro(synch), m_fetched_help_short(false),
-        m_fetched_help_long(false) {
+        m_fetched_help_long(false), m_completion_type(completion_type) {
     StreamString stream;
     stream.Printf("For more information run 'help %s'", name.c_str());
     SetHelp(stream.GetString());
@@ -1166,6 +1177,15 @@ class CommandObjectScriptingObject : public CommandObjectRaw {
 
   ~CommandObjectScriptingObject() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest &request,
+                           OptionElementVector &opt_element_vector) override {
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), m_completion_type, request, nullptr);
+  }
+
+  bool WantsCompletion() override { return true; }
+
   bool IsRemovable() const override { return true; }
 
   ScriptedCommandSynchronicity GetSynchronicity() { return m_synchro; }
@@ -1232,6 +1252,7 @@ class CommandObjectScriptingObject : public CommandObjectRaw {
   ScriptedCommandSynchronicity m_synchro;
   bool m_fetched_help_short : 1;
   bool m_fetched_help_long : 1;
+  CompletionType m_completion_type = eNoCompletion;
 };
 
 // CommandObjectCommandsScriptImport
@@ -1263,9 +1284,8 @@ class CommandObjectCommandsScriptImport : public CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eDiskFileCompletion, request, nullptr);
   }
 
   Options *GetOptions() override { return &m_options; }
@@ -1439,6 +1459,18 @@ class CommandObjectCommandsScriptAdd : public CommandObjectParsed,
               "unrecognized value for synchronicity '%s'",
               option_arg.str().c_str());
         break;
+      case 'C': {
+        Status error;
+        OptionDefinition definition = GetDefinitions()[option_idx];
+        lldb::CompletionType completion_type =
+            static_cast<lldb::CompletionType>(OptionArgParser::ToOptionEnum(
+                option_arg, definition.enum_values, eNoCompletion, error));
+        if (!error.Success())
+          error.SetErrorStringWithFormat(
+              "unrecognized value for command completion type '%s'",
+              option_arg.str().c_str());
+        m_completion_type = completion_type;
+      } break;
       default:
         llvm_unreachable("Unimplemented option");
       }
@@ -1450,6 +1482,7 @@ class CommandObjectCommandsScriptAdd : public CommandObjectParsed,
       m_class_name.clear();
       m_funct_name.clear();
       m_short_help.clear();
+      m_completion_type = eNoCompletion;
       m_overwrite_lazy = eLazyBoolCalculate;
       m_synchronicity = eScriptedCommandSynchronicitySynchronous;
     }
@@ -1466,6 +1499,7 @@ class CommandObjectCommandsScriptAdd : public CommandObjectParsed,
     LazyBool m_overwrite_lazy = eLazyBoolCalculate;
     ScriptedCommandSynchronicity m_synchronicity =
         eScriptedCommandSynchronicitySynchronous;
+    CompletionType m_completion_type = eNoCompletion;
   };
 
   void IOHandlerActivated(IOHandler &io_handler, bool interactive) override {
@@ -1496,7 +1530,7 @@ class CommandObjectCommandsScriptAdd : public CommandObjectParsed,
 
             CommandObjectSP command_obj_sp(new CommandObjectPythonFunction(
                 m_interpreter, m_cmd_name, funct_name_str, m_short_help,
-                m_synchronicity));
+                m_synchronicity, m_completion_type));
             if (!m_container) {
               Status error = m_interpreter.AddUserCommand(
                   m_cmd_name, command_obj_sp, m_overwrite);
@@ -1577,6 +1611,7 @@ class CommandObjectCommandsScriptAdd : public CommandObjectParsed,
 
     m_short_help.assign(m_options.m_short_help);
     m_synchronicity = m_options.m_synchronicity;
+    m_completion_type = m_options.m_completion_type;
 
     // Handle the case where we prompt for the script code first:
     if (m_options.m_class_name.empty() && m_options.m_funct_name.empty()) {
@@ -1589,7 +1624,7 @@ class CommandObjectCommandsScriptAdd : public CommandObjectParsed,
     if (m_options.m_class_name.empty()) {
       new_cmd_sp.reset(new CommandObjectPythonFunction(
           m_interpreter, m_cmd_name, m_options.m_funct_name,
-          m_options.m_short_help, m_synchronicity));
+          m_options.m_short_help, m_synchronicity, m_completion_type));
     } else {
       ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
       if (!interpreter) {
@@ -1606,7 +1641,8 @@ class CommandObjectCommandsScriptAdd : public CommandObjectParsed,
       }
 
       new_cmd_sp.reset(new CommandObjectScriptingObject(
-          m_interpreter, m_cmd_name, cmd_obj_sp, m_synchronicity));
+          m_interpreter, m_cmd_name, cmd_obj_sp, m_synchronicity,
+          m_completion_type));
     }
     
     // Assume we're going to succeed...
@@ -1634,6 +1670,7 @@ class CommandObjectCommandsScriptAdd : public CommandObjectParsed,
   bool m_overwrite = false;
   ScriptedCommandSynchronicity m_synchronicity =
       eScriptedCommandSynchronicitySynchronous;
+  CompletionType m_completion_type = eNoCompletion;
 };
 
 // CommandObjectCommandsScriptList
@@ -1706,8 +1743,8 @@ class CommandObjectCommandsScriptDelete : public CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::CompleteModifiableCmdPathArgs(m_interpreter, request,
-                                                      opt_element_vector);
+    lldb_private::CommandCompletions::CompleteModifiableCmdPathArgs(
+        m_interpreter, request, opt_element_vector);
   }
 
 protected:
@@ -1857,8 +1894,8 @@ class CommandObjectCommandsContainerAdd : public CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::CompleteModifiableCmdPathArgs(m_interpreter, request,
-                                                      opt_element_vector);
+    lldb_private::CommandCompletions::CompleteModifiableCmdPathArgs(
+        m_interpreter, request, opt_element_vector);
   }
 
 protected:
@@ -1997,8 +2034,8 @@ class CommandObjectCommandsContainerDelete : public CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::CompleteModifiableCmdPathArgs(m_interpreter, request,
-                                                      opt_element_vector);
+    lldb_private::CommandCompletions::CompleteModifiableCmdPathArgs(
+        m_interpreter, request, opt_element_vector);
   }
 
 protected:

diff  --git a/lldb/source/Commands/CommandObjectDWIMPrint.cpp b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
index 7cb95fd622ba1..b2b7f201a5add 100644
--- a/lldb/source/Commands/CommandObjectDWIMPrint.cpp
+++ b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
@@ -52,9 +52,8 @@ Options *CommandObjectDWIMPrint::GetOptions() { return &m_option_group; }
 
 void CommandObjectDWIMPrint::HandleArgumentCompletion(
     CompletionRequest &request, OptionElementVector &opt_element_vector) {
-  CommandCompletions::InvokeCommonCompletionCallbacks(
-      GetCommandInterpreter(), CommandCompletions::eVariablePathCompletion,
-      request, nullptr);
+  lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+      GetCommandInterpreter(), lldb::eVariablePathCompletion, request, nullptr);
 }
 
 bool CommandObjectDWIMPrint::DoExecute(StringRef command,

diff  --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp
index 71fed65203a5b..db31b159f430d 100644
--- a/lldb/source/Commands/CommandObjectFrame.cpp
+++ b/lldb/source/Commands/CommandObjectFrame.cpp
@@ -292,9 +292,8 @@ class CommandObjectFrameSelect : public CommandObjectParsed {
     if (request.GetCursorIndex() != 0)
       return;
 
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eFrameIndexCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eFrameIndexCompletion, request, nullptr);
   }
 
   Options *GetOptions() override { return &m_options; }
@@ -445,9 +444,9 @@ may even involve JITing and running code in the target program.)");
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
     // Arguments are the standard source file completer.
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eVariablePathCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eVariablePathCompletion, request,
+        nullptr);
   }
 
 protected:

diff  --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp
index 60d37121844b4..92aa110cba7f1 100644
--- a/lldb/source/Commands/CommandObjectPlatform.cpp
+++ b/lldb/source/Commands/CommandObjectPlatform.cpp
@@ -161,8 +161,8 @@ class CommandObjectPlatformSelect : public CommandObjectParsed {
   ~CommandObjectPlatformSelect() override = default;
 
   void HandleCompletion(CompletionRequest &request) override {
-    CommandCompletions::PlatformPluginNames(GetCommandInterpreter(), request,
-                                            nullptr);
+    lldb_private::CommandCompletions::PlatformPluginNames(
+        GetCommandInterpreter(), request, nullptr);
   }
 
   Options *GetOptions() override { return &m_option_group; }
@@ -385,8 +385,7 @@ class CommandObjectPlatformSettings : public CommandObjectParsed {
                             "Set settings for the current target's platform.",
                             "platform settings", 0),
         m_option_working_dir(LLDB_OPT_SET_1, false, "working-dir", 'w',
-                             CommandCompletions::eRemoteDiskDirectoryCompletion,
-                             eArgTypePath,
+                             lldb::eRemoteDiskDirectoryCompletion, eArgTypePath,
                              "The working directory for the platform.") {
     m_options.Append(&m_option_working_dir, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
   }
@@ -484,9 +483,9 @@ class CommandObjectPlatformFOpen : public CommandObjectParsed {
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
     if (request.GetCursorIndex() == 0)
-      CommandCompletions::InvokeCommonCompletionCallbacks(
-          GetCommandInterpreter(),
-          CommandCompletions::eRemoteDiskFileCompletion, request, nullptr);
+      lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+          GetCommandInterpreter(), lldb::eRemoteDiskFileCompletion, request,
+          nullptr);
   }
 
   bool DoExecute(Args &args, CommandReturnObject &result) override {
@@ -831,13 +830,12 @@ class CommandObjectPlatformGetFile : public CommandObjectParsed {
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
     if (request.GetCursorIndex() == 0)
-      CommandCompletions::InvokeCommonCompletionCallbacks(
-          GetCommandInterpreter(),
-          CommandCompletions::eRemoteDiskFileCompletion, request, nullptr);
+      lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+          GetCommandInterpreter(), lldb::eRemoteDiskFileCompletion, request,
+          nullptr);
     else if (request.GetCursorIndex() == 1)
-      CommandCompletions::InvokeCommonCompletionCallbacks(
-          GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
-          request, nullptr);
+      lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+          GetCommandInterpreter(), lldb::eDiskFileCompletion, request, nullptr);
   }
 
   bool DoExecute(Args &args, CommandReturnObject &result) override {
@@ -907,9 +905,9 @@ class CommandObjectPlatformGetSize : public CommandObjectParsed {
     if (request.GetCursorIndex() != 0)
       return;
 
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eRemoteDiskFileCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eRemoteDiskFileCompletion, request,
+        nullptr);
   }
 
   bool DoExecute(Args &args, CommandReturnObject &result) override {
@@ -978,9 +976,9 @@ class CommandObjectPlatformGetPermissions : public CommandObjectParsed {
     if (request.GetCursorIndex() != 0)
       return;
 
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eRemoteDiskFileCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eRemoteDiskFileCompletion, request,
+        nullptr);
   }
 
   bool DoExecute(Args &args, CommandReturnObject &result) override {
@@ -1048,9 +1046,9 @@ class CommandObjectPlatformFileExists : public CommandObjectParsed {
     if (request.GetCursorIndex() != 0)
       return;
 
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eRemoteDiskFileCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eRemoteDiskFileCompletion, request,
+        nullptr);
   }
 
   bool DoExecute(Args &args, CommandReturnObject &result) override {
@@ -1107,13 +1105,12 @@ class CommandObjectPlatformPutFile : public CommandObjectParsed {
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
     if (request.GetCursorIndex() == 0)
-      CommandCompletions::InvokeCommonCompletionCallbacks(
-          GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
-          request, nullptr);
+      lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+          GetCommandInterpreter(), lldb::eDiskFileCompletion, request, nullptr);
     else if (request.GetCursorIndex() == 1)
-      CommandCompletions::InvokeCommonCompletionCallbacks(
-          GetCommandInterpreter(),
-          CommandCompletions::eRemoteDiskFileCompletion, request, nullptr);
+      lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+          GetCommandInterpreter(), lldb::eRemoteDiskFileCompletion, request,
+          nullptr);
   }
 
   bool DoExecute(Args &args, CommandReturnObject &result) override {
@@ -1523,9 +1520,8 @@ class CommandObjectPlatformProcessInfo : public CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eProcessIDCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eProcessIDCompletion, request, nullptr);
   }
 
 protected:
@@ -1834,9 +1830,8 @@ class CommandObjectPlatformInstall : public CommandObjectParsed {
                            OptionElementVector &opt_element_vector) override {
     if (request.GetCursorIndex())
       return;
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eDiskFileCompletion, request, nullptr);
   }
 
   bool DoExecute(Args &args, CommandReturnObject &result) override {

diff  --git a/lldb/source/Commands/CommandObjectPlugin.cpp b/lldb/source/Commands/CommandObjectPlugin.cpp
index 881415a494728..8661ebb5022b8 100644
--- a/lldb/source/Commands/CommandObjectPlugin.cpp
+++ b/lldb/source/Commands/CommandObjectPlugin.cpp
@@ -39,9 +39,8 @@ class CommandObjectPluginLoad : public CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eDiskFileCompletion, request, nullptr);
   }
 
 protected:

diff  --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index 5b578454f1ad6..82d11687d377a 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -147,9 +147,8 @@ class CommandObjectProcessLaunch : public CommandObjectProcessLaunchOrAttach {
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
 
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eDiskFileCompletion, request, nullptr);
   }
 
   Options *GetOptions() override { return &m_all_options; }
@@ -1026,9 +1025,8 @@ class CommandObjectProcessLoad : public CommandObjectParsed {
     if (!m_exe_ctx.HasProcessScope())
       return;
 
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eDiskFileCompletion, request, nullptr);
   }
 
   Options *GetOptions() override { return &m_options; }

diff  --git a/lldb/source/Commands/CommandObjectRegexCommand.cpp b/lldb/source/Commands/CommandObjectRegexCommand.cpp
index 90b32b193e329..6ff1d281504ac 100644
--- a/lldb/source/Commands/CommandObjectRegexCommand.cpp
+++ b/lldb/source/Commands/CommandObjectRegexCommand.cpp
@@ -104,7 +104,7 @@ bool CommandObjectRegexCommand::AddRegexCommand(llvm::StringRef re_cstr,
 
 void CommandObjectRegexCommand::HandleCompletion(CompletionRequest &request) {
   if (m_completion_type_mask) {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
         GetCommandInterpreter(), m_completion_type_mask, request, nullptr);
   }
 }

diff  --git a/lldb/source/Commands/CommandObjectRegister.cpp b/lldb/source/Commands/CommandObjectRegister.cpp
index 7c1155b7ba381..c288dbef33499 100644
--- a/lldb/source/Commands/CommandObjectRegister.cpp
+++ b/lldb/source/Commands/CommandObjectRegister.cpp
@@ -79,9 +79,8 @@ class CommandObjectRegisterRead : public CommandObjectParsed {
     if (!m_exe_ctx.HasProcessScope())
       return;
 
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eRegisterCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eRegisterCompletion, request, nullptr);
   }
 
   Options *GetOptions() override { return &m_option_group; }
@@ -342,9 +341,8 @@ class CommandObjectRegisterWrite : public CommandObjectParsed {
     if (!m_exe_ctx.HasProcessScope() || request.GetCursorIndex() != 0)
       return;
 
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eRegisterCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eRegisterCompletion, request, nullptr);
   }
 
 protected:

diff  --git a/lldb/source/Commands/CommandObjectSession.cpp b/lldb/source/Commands/CommandObjectSession.cpp
index 7c7236e9793b8..6bf1ec99c8888 100644
--- a/lldb/source/Commands/CommandObjectSession.cpp
+++ b/lldb/source/Commands/CommandObjectSession.cpp
@@ -31,9 +31,8 @@ class CommandObjectSessionSave : public CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eDiskFileCompletion, request, nullptr);
   }
 
 protected:

diff  --git a/lldb/source/Commands/CommandObjectSettings.cpp b/lldb/source/Commands/CommandObjectSettings.cpp
index a2ad87a4395cf..7069cb1d83993 100644
--- a/lldb/source/Commands/CommandObjectSettings.cpp
+++ b/lldb/source/Commands/CommandObjectSettings.cpp
@@ -143,9 +143,9 @@ insert-before or insert-after.");
     }
     if (request.GetCursorIndex() == setting_var_idx) {
       // Attempting to complete setting variable name
-      CommandCompletions::InvokeCommonCompletionCallbacks(
-          GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion,
-          request, nullptr);
+      lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+          GetCommandInterpreter(), lldb::eSettingsNameCompletion, request,
+          nullptr);
       return;
     }
     arg = request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex());
@@ -267,9 +267,9 @@ class CommandObjectSettingsShow : public CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eSettingsNameCompletion, request,
+        nullptr);
   }
 
 protected:
@@ -511,9 +511,9 @@ class CommandObjectSettingsList : public CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eSettingsNameCompletion, request,
+        nullptr);
   }
 
 protected:
@@ -595,9 +595,9 @@ class CommandObjectSettingsRemove : public CommandObjectRaw {
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
     if (request.GetCursorIndex() < 2)
-      CommandCompletions::InvokeCommonCompletionCallbacks(
-          GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion,
-          request, nullptr);
+      lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+          GetCommandInterpreter(), lldb::eSettingsNameCompletion, request,
+          nullptr);
   }
 
 protected:
@@ -703,9 +703,9 @@ class CommandObjectSettingsReplace : public CommandObjectRaw {
                            OptionElementVector &opt_element_vector) override {
     // Attempting to complete variable name
     if (request.GetCursorIndex() < 2)
-      CommandCompletions::InvokeCommonCompletionCallbacks(
-          GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion,
-          request, nullptr);
+      lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+          GetCommandInterpreter(), lldb::eSettingsNameCompletion, request,
+          nullptr);
   }
 
 protected:
@@ -795,9 +795,9 @@ class CommandObjectSettingsInsertBefore : public CommandObjectRaw {
                            OptionElementVector &opt_element_vector) override {
     // Attempting to complete variable name
     if (request.GetCursorIndex() < 2)
-      CommandCompletions::InvokeCommonCompletionCallbacks(
-          GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion,
-          request, nullptr);
+      lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+          GetCommandInterpreter(), lldb::eSettingsNameCompletion, request,
+          nullptr);
   }
 
 protected:
@@ -891,9 +891,9 @@ class CommandObjectSettingsInsertAfter : public CommandObjectRaw {
                            OptionElementVector &opt_element_vector) override {
     // Attempting to complete variable name
     if (request.GetCursorIndex() < 2)
-      CommandCompletions::InvokeCommonCompletionCallbacks(
-          GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion,
-          request, nullptr);
+      lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+          GetCommandInterpreter(), lldb::eSettingsNameCompletion, request,
+          nullptr);
   }
 
 protected:
@@ -976,9 +976,9 @@ class CommandObjectSettingsAppend : public CommandObjectRaw {
                            OptionElementVector &opt_element_vector) override {
     // Attempting to complete variable name
     if (request.GetCursorIndex() < 2)
-      CommandCompletions::InvokeCommonCompletionCallbacks(
-          GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion,
-          request, nullptr);
+      lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+          GetCommandInterpreter(), lldb::eSettingsNameCompletion, request,
+          nullptr);
   }
 
 protected:
@@ -1051,9 +1051,9 @@ class CommandObjectSettingsClear : public CommandObjectParsed {
                            OptionElementVector &opt_element_vector) override {
     // Attempting to complete variable name
     if (request.GetCursorIndex() < 2)
-      CommandCompletions::InvokeCommonCompletionCallbacks(
-          GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion,
-          request, nullptr);
+      lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+          GetCommandInterpreter(), lldb::eSettingsNameCompletion, request,
+          nullptr);
   }
 
    Options *GetOptions() override { return &m_options; }

diff  --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index 0088211c49e37..dd4fbe84e5737 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -256,9 +256,8 @@ class CommandObjectTargetCreate : public CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eDiskFileCompletion, request, nullptr);
   }
 
 protected:
@@ -1846,9 +1845,8 @@ class CommandObjectTargetModulesModuleAutoComplete
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eModuleCompletion, request,
-        nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eModuleCompletion, request, nullptr);
   }
 };
 
@@ -1884,9 +1882,8 @@ class CommandObjectTargetModulesSourceFileAutoComplete
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eSourceFileCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eSourceFileCompletion, request, nullptr);
   }
 };
 
@@ -2531,9 +2528,8 @@ class CommandObjectTargetModulesAdd : public CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eDiskFileCompletion, request, nullptr);
   }
 
 protected:
@@ -4062,8 +4058,8 @@ class CommandObjectTargetSymbolsAdd : public CommandObjectParsed {
             "target symbols add <cmd-options> [<symfile>]",
             eCommandRequiresTarget),
         m_file_option(
-            LLDB_OPT_SET_1, false, "shlib", 's',
-            CommandCompletions::eModuleCompletion, eArgTypeShlibName,
+            LLDB_OPT_SET_1, false, "shlib", 's', lldb::eModuleCompletion,
+            eArgTypeShlibName,
             "Locate the debug symbols for the shared library specified by "
             "name."),
         m_current_frame_option(
@@ -4093,9 +4089,8 @@ class CommandObjectTargetSymbolsAdd : public CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eDiskFileCompletion, request, nullptr);
   }
 
   Options *GetOptions() override { return &m_option_group; }
@@ -4944,9 +4939,8 @@ class CommandObjectTargetStopHookDelete : public CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eStopHookIDCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eStopHookIDCompletion, request, nullptr);
   }
 
 protected:
@@ -5002,9 +4996,8 @@ class CommandObjectTargetStopHookEnableDisable : public CommandObjectParsed {
                            OptionElementVector &opt_element_vector) override {
     if (request.GetCursorIndex())
       return;
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eStopHookIDCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eStopHookIDCompletion, request, nullptr);
   }
 
 protected:

diff  --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp
index 851fc743f3895..66a33f5882c47 100644
--- a/lldb/source/Commands/CommandObjectThread.cpp
+++ b/lldb/source/Commands/CommandObjectThread.cpp
@@ -401,9 +401,9 @@ class CommandObjectThreadStepWithTypeAndScope : public CommandObjectParsed {
     if (request.GetCursorIndex())
       return;
 
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eThreadIndexCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eThreadIndexCompletion, request,
+        nullptr);
   }
 
   Options *GetOptions() override { return &m_all_options; }
@@ -664,9 +664,9 @@ class CommandObjectThreadContinue : public CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eThreadIndexCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eThreadIndexCompletion, request,
+        nullptr);
   }
 
   bool DoExecute(Args &command, CommandReturnObject &result) override {
@@ -1161,9 +1161,9 @@ class CommandObjectThreadSelect : public CommandObjectParsed {
     if (request.GetCursorIndex())
       return;
 
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eThreadIndexCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eThreadIndexCompletion, request,
+        nullptr);
   }
 
 protected:
@@ -1295,9 +1295,9 @@ class CommandObjectThreadInfo : public CommandObjectIterateOverThreads {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eThreadIndexCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eThreadIndexCompletion, request,
+        nullptr);
   }
 
   Options *GetOptions() override { return &m_options; }
@@ -1345,9 +1345,9 @@ class CommandObjectThreadException : public CommandObjectIterateOverThreads {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eThreadIndexCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eThreadIndexCompletion, request,
+        nullptr);
   }
 
   bool HandleOneThread(lldb::tid_t tid, CommandReturnObject &result) override {
@@ -1393,9 +1393,9 @@ class CommandObjectThreadSiginfo : public CommandObjectIterateOverThreads {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eThreadIndexCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eThreadIndexCompletion, request,
+        nullptr);
   }
 
   bool HandleOneThread(lldb::tid_t tid, CommandReturnObject &result) override {

diff  --git a/lldb/source/Commands/CommandObjectTrace.cpp b/lldb/source/Commands/CommandObjectTrace.cpp
index ba8289cb68d3e..52fb56ffc1fb7 100644
--- a/lldb/source/Commands/CommandObjectTrace.cpp
+++ b/lldb/source/Commands/CommandObjectTrace.cpp
@@ -96,9 +96,8 @@ class CommandObjectTraceSave : public CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eDiskFileCompletion, request, nullptr);
   }
 
   ~CommandObjectTraceSave() override = default;
@@ -186,9 +185,8 @@ class CommandObjectTraceLoad : public CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eDiskFileCompletion, request, nullptr);
   }
 
   ~CommandObjectTraceLoad() override = default;

diff  --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp
index b6c379bdb4342..e6dd63a6cb213 100644
--- a/lldb/source/Commands/CommandObjectType.cpp
+++ b/lldb/source/Commands/CommandObjectType.cpp
@@ -1767,9 +1767,9 @@ class CommandObjectTypeCategoryDefine : public CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(),
-        CommandCompletions::eTypeCategoryNameCompletion, request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eTypeCategoryNameCompletion, request,
+        nullptr);
   }
 
 protected:
@@ -1869,9 +1869,9 @@ class CommandObjectTypeCategoryEnable : public CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(),
-        CommandCompletions::eTypeCategoryNameCompletion, request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eTypeCategoryNameCompletion, request,
+        nullptr);
   }
 
 protected:
@@ -1937,9 +1937,9 @@ class CommandObjectTypeCategoryDelete : public CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(),
-        CommandCompletions::eTypeCategoryNameCompletion, request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eTypeCategoryNameCompletion, request,
+        nullptr);
   }
 
 protected:
@@ -2046,9 +2046,9 @@ class CommandObjectTypeCategoryDisable : public CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(),
-        CommandCompletions::eTypeCategoryNameCompletion, request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eTypeCategoryNameCompletion, request,
+        nullptr);
   }
 
 protected:
@@ -2111,9 +2111,9 @@ class CommandObjectTypeCategoryList : public CommandObjectParsed {
                            OptionElementVector &opt_element_vector) override {
     if (request.GetCursorIndex())
       return;
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(),
-        CommandCompletions::eTypeCategoryNameCompletion, request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eTypeCategoryNameCompletion, request,
+        nullptr);
   }
 
 protected:

diff  --git a/lldb/source/Commands/CommandObjectWatchpoint.cpp b/lldb/source/Commands/CommandObjectWatchpoint.cpp
index 14180f9b56d36..b73c9a2a89feb 100644
--- a/lldb/source/Commands/CommandObjectWatchpoint.cpp
+++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp
@@ -289,9 +289,9 @@ class CommandObjectWatchpointEnable : public CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eWatchPointIDCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eWatchpointIDCompletion, request,
+        nullptr);
   }
 
 protected:
@@ -365,9 +365,9 @@ class CommandObjectWatchpointDisable : public CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eWatchPointIDCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eWatchpointIDCompletion, request,
+        nullptr);
   }
 
 protected:
@@ -446,9 +446,9 @@ class CommandObjectWatchpointDelete : public CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eWatchPointIDCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eWatchpointIDCompletion, request,
+        nullptr);
   }
 
   Options *GetOptions() override { return &m_options; }
@@ -569,9 +569,9 @@ class CommandObjectWatchpointIgnore : public CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eWatchPointIDCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eWatchpointIDCompletion, request,
+        nullptr);
   }
 
   Options *GetOptions() override { return &m_options; }
@@ -694,9 +694,9 @@ class CommandObjectWatchpointModify : public CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
                            OptionElementVector &opt_element_vector) override {
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eWatchPointIDCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eWatchpointIDCompletion, request,
+        nullptr);
   }
 
   Options *GetOptions() override { return &m_options; }
@@ -846,9 +846,9 @@ corresponding to the byte size of the data type.");
                            OptionElementVector &opt_element_vector) override {
     if (request.GetCursorIndex() != 0)
       return;
-    CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), CommandCompletions::eVariablePathCompletion,
-        request, nullptr);
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+        GetCommandInterpreter(), lldb::eVariablePathCompletion, request,
+        nullptr);
   }
 
   Options *GetOptions() override { return &m_option_group; }

diff  --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index ea917f78841bb..04830b8b990ef 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -804,6 +804,9 @@ let Command = "script add" in {
     EnumArg<"ScriptedCommandSynchronicity">,
     Desc<"Set the synchronicity of this command's executions with regard to "
     "LLDB event system.">;
+  def completion_type : Option<"completion-type", "C">,
+  EnumArg<"CompletionType">,
+  Desc<"Specify which completion type the command should use - if none is specified, the command won't use auto-completion.">;
 }
 
 let Command = "container add" in {

diff  --git a/lldb/source/Core/IOHandler.cpp b/lldb/source/Core/IOHandler.cpp
index 95957b6948fc2..49f39f2ce492b 100644
--- a/lldb/source/Core/IOHandler.cpp
+++ b/lldb/source/Core/IOHandler.cpp
@@ -215,9 +215,9 @@ void IOHandlerDelegate::IOHandlerComplete(IOHandler &io_handler,
     io_handler.GetDebugger().GetCommandInterpreter().HandleCompletion(request);
     break;
   case Completion::Expression:
-    CommandCompletions::InvokeCommonCompletionCallbacks(
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
         io_handler.GetDebugger().GetCommandInterpreter(),
-        CommandCompletions::eVariablePathCompletion, request, nullptr);
+        lldb::eVariablePathCompletion, request, nullptr);
     break;
   }
 }

diff  --git a/lldb/source/Core/IOHandlerCursesGUI.cpp b/lldb/source/Core/IOHandlerCursesGUI.cpp
index a592f3f029165..e1bc56de4cdd7 100644
--- a/lldb/source/Core/IOHandlerCursesGUI.cpp
+++ b/lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -3821,7 +3821,7 @@ class SearcherWindowDelegate : public WindowDelegate {
 
 // This is a searcher delegate wrapper around CommandCompletions common
 // callbacks. The callbacks are only given the match string. The completion_mask
-// can be a combination of CommonCompletionTypes.
+// can be a combination of lldb::CompletionType.
 class CommonCompletionSearcherDelegate : public SearcherDelegate {
 public:
   typedef std::function<void(const std::string &)> CallbackType;
@@ -3840,7 +3840,7 @@ class CommonCompletionSearcherDelegate : public SearcherDelegate {
   void UpdateMatches(const std::string &text) override {
     CompletionResult result;
     CompletionRequest request(text.c_str(), text.size(), result);
-    CommandCompletions::InvokeCommonCompletionCallbacks(
+    lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
         m_debugger.GetCommandInterpreter(), m_completion_mask, request,
         nullptr);
     result.GetMatches(m_matches);
@@ -3852,7 +3852,7 @@ class CommonCompletionSearcherDelegate : public SearcherDelegate {
 
 protected:
   Debugger &m_debugger;
-  // A compound mask from CommonCompletionTypes.
+  // A compound mask from lldb::CompletionType.
   uint32_t m_completion_mask;
   // A callback to execute once the user selects a match. The match is passed to
   // the callback as a string.

diff  --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index 735f18dd5004b..3d3ab7b73b19f 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -616,9 +616,7 @@ void CommandInterpreter::LoadCommandDictionary() {
           "current file\n"
           "                                    // containing text 'break "
           "here'.\n",
-          CommandCompletions::eSymbolCompletion |
-              CommandCompletions::eSourceFileCompletion,
-          false));
+          lldb::eSymbolCompletion | lldb::eSourceFileCompletion, false));
 
   if (break_regex_cmd_up) {
     bool success = true;
@@ -669,9 +667,7 @@ void CommandInterpreter::LoadCommandDictionary() {
           "current file\n"
           "                                    // containing text 'break "
           "here'.\n",
-          CommandCompletions::eSymbolCompletion |
-              CommandCompletions::eSourceFileCompletion,
-          false));
+          lldb::eSymbolCompletion | lldb::eSourceFileCompletion, false));
 
   if (tbreak_regex_cmd_up) {
     bool success = true;
@@ -849,7 +845,7 @@ void CommandInterpreter::LoadCommandDictionary() {
           "_regexp-list 0x<address>     // List around specified address\n"
           "_regexp-list -[<count>]      // List previous <count> lines\n"
           "_regexp-list                 // List subsequent lines",
-          CommandCompletions::eSourceFileCompletion, false));
+          lldb::eSourceFileCompletion, false));
   if (list_regex_cmd_up) {
     if (list_regex_cmd_up->AddRegexCommand("^([0-9]+)[[:space:]]*$",
                                            "source list --line %1") &&

diff  --git a/lldb/source/Interpreter/OptionValueArch.cpp b/lldb/source/Interpreter/OptionValueArch.cpp
index 4d1e2c7869f3e..71a3627fbe5e5 100644
--- a/lldb/source/Interpreter/OptionValueArch.cpp
+++ b/lldb/source/Interpreter/OptionValueArch.cpp
@@ -66,7 +66,6 @@ Status OptionValueArch::SetValueFromString(llvm::StringRef value,
 
 void OptionValueArch::AutoComplete(CommandInterpreter &interpreter,
                                    CompletionRequest &request) {
-  CommandCompletions::InvokeCommonCompletionCallbacks(
-      interpreter, CommandCompletions::eArchitectureCompletion, request,
-      nullptr);
+  lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+      interpreter, lldb::eArchitectureCompletion, request, nullptr);
 }

diff  --git a/lldb/source/Interpreter/OptionValueFileColonLine.cpp b/lldb/source/Interpreter/OptionValueFileColonLine.cpp
index e500005a815d2..a68967b81797a 100644
--- a/lldb/source/Interpreter/OptionValueFileColonLine.cpp
+++ b/lldb/source/Interpreter/OptionValueFileColonLine.cpp
@@ -132,6 +132,6 @@ Status OptionValueFileColonLine::SetValueFromString(llvm::StringRef value,
 
 void OptionValueFileColonLine::AutoComplete(CommandInterpreter &interpreter,
                                             CompletionRequest &request) {
-  CommandCompletions::InvokeCommonCompletionCallbacks(
+  lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
       interpreter, m_completion_mask, request, nullptr);
 }

diff  --git a/lldb/source/Interpreter/OptionValueFileSpec.cpp b/lldb/source/Interpreter/OptionValueFileSpec.cpp
index f35a6b886f98a..35a1081dba1e1 100644
--- a/lldb/source/Interpreter/OptionValueFileSpec.cpp
+++ b/lldb/source/Interpreter/OptionValueFileSpec.cpp
@@ -84,7 +84,7 @@ Status OptionValueFileSpec::SetValueFromString(llvm::StringRef value,
 
 void OptionValueFileSpec::AutoComplete(CommandInterpreter &interpreter,
                                        CompletionRequest &request) {
-  CommandCompletions::InvokeCommonCompletionCallbacks(
+  lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
       interpreter, m_completion_mask, request, nullptr);
 }
 

diff  --git a/lldb/source/Interpreter/Options.cpp b/lldb/source/Interpreter/Options.cpp
index 7bfb88fb5ca11..acbde7660440b 100644
--- a/lldb/source/Interpreter/Options.cpp
+++ b/lldb/source/Interpreter/Options.cpp
@@ -714,8 +714,8 @@ void Options::HandleOptionArgumentCompletion(
     }
   }
 
-  if (completion_mask & CommandCompletions::eSourceFileCompletion ||
-      completion_mask & CommandCompletions::eSymbolCompletion) {
+  if (completion_mask & lldb::eSourceFileCompletion ||
+      completion_mask & lldb::eSymbolCompletion) {
     for (size_t i = 0; i < opt_element_vector.size(); i++) {
       int cur_defs_index = opt_element_vector[i].opt_defs_index;
 
@@ -748,7 +748,7 @@ void Options::HandleOptionArgumentCompletion(
     }
   }
 
-  CommandCompletions::InvokeCommonCompletionCallbacks(
+  lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
       interpreter, completion_mask, request, filter_up.get());
 }
 

diff  --git a/lldb/test/API/functionalities/completion/TestCompletion.py b/lldb/test/API/functionalities/completion/TestCompletion.py
index 22caebfe583f1..f25e1b408bbce 100644
--- a/lldb/test/API/functionalities/completion/TestCompletion.py
+++ b/lldb/test/API/functionalities/completion/TestCompletion.py
@@ -436,6 +436,47 @@ def test_target_modules_dump_line_table(self):
         self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
         self.complete_from_to("target modules dump line-table main.cp", ["main.cpp"])
 
+    def test_custom_command_completion(self):
+        """Tests completion in custom user provided commands."""
+        completion_types = [
+            "none",
+            "source-file",
+            "disk-file",
+            "disk-directory",
+            "symbol",
+            "module",
+            "settings-name",
+            "platform-plugin",
+            "architecture",
+            "variable-path",
+            "register",
+            "breakpoint",
+            "process-plugin",
+            "disassembly-flavor",
+            "type-language",
+            "frame-index",
+            "module-uuid",
+            "stophook-id",
+            "thread-index",
+            "watchpoint-id",
+            "breakpoint-name",
+            "process-id",
+            "process-name",
+            "remote-disk-file",
+            "remote-disk-directory",
+            "type-category-name",
+            "custom",
+        ]
+        self.completions_contain("command script add -C ", completion_types)
+
+        source_path = os.path.join(self.getSourceDir(), "my_test_cmd.py")
+        self.runCmd("command script import '%s'" % (source_path))
+        self.runCmd(
+            "command script add -C disk-file -f my_test_cmd.my_test_cmd my_test_cmd"
+        )
+        self.complete_from_to("my_test_cmd main.cp", ["main.cpp"])
+        self.expect("my_test_cmd main.cpp", substrs=["main.cpp"])
+
     def test_target_modules_load_aout(self):
         """Tests modules completion by completing the target modules load argument."""
         self.build()

diff  --git a/lldb/test/API/functionalities/completion/my_test_cmd.py b/lldb/test/API/functionalities/completion/my_test_cmd.py
new file mode 100644
index 0000000000000..f1e81493248b2
--- /dev/null
+++ b/lldb/test/API/functionalities/completion/my_test_cmd.py
@@ -0,0 +1,2 @@
+def my_test_cmd(debugger, command, exe_ctx, result, dict):
+    result.Print(command)

diff  --git a/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp b/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp
index d73f0a2914c1e..b936b8fd653b3 100644
--- a/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp
+++ b/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp
@@ -120,12 +120,11 @@ static void emitOption(const CommandOption &O, raw_ostream &OS) {
   if (!O.Completions.empty()) {
     std::vector<std::string> CompletionArgs;
     for (llvm::StringRef Completion : O.Completions)
-      CompletionArgs.push_back("CommandCompletions::e" + Completion.str() +
-                               "Completion");
+      CompletionArgs.push_back("e" + Completion.str() + "Completion");
 
     OS << llvm::join(CompletionArgs.begin(), CompletionArgs.end(), " | ");
   } else
-    OS << "CommandCompletions::eNoCompletion";
+    OS << "CompletionType::eNoCompletion";
 
   // Add the argument type.
   OS << ", eArgType";


        


More information about the lldb-commits mailing list