diff options
Diffstat (limited to 'lldb/source/Interpreter/CommandInterpreter.cpp')
| -rw-r--r-- | lldb/source/Interpreter/CommandInterpreter.cpp | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index bd03f18b47c0..59c23716bf89 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -2259,13 +2259,15 @@ static void GetHomeInitFile(llvm::SmallVectorImpl<char> &init_file, FileSystem::Instance().Resolve(init_file); } -static void GetHomeREPLInitFile(llvm::SmallVectorImpl<char> &init_file) { - LanguageSet repl_languages = Language::GetLanguagesSupportingREPLs(); - LanguageType language = eLanguageTypeUnknown; - if (auto main_repl_language = repl_languages.GetSingularLanguage()) - language = *main_repl_language; - else - return; +static void GetHomeREPLInitFile(llvm::SmallVectorImpl<char> &init_file, + LanguageType language) { + if (language == eLanguageTypeUnknown) { + LanguageSet repl_languages = Language::GetLanguagesSupportingREPLs(); + if (auto main_repl_language = repl_languages.GetSingularLanguage()) + language = *main_repl_language; + else + return; + } std::string init_file_name = (llvm::Twine(".lldbinit-") + @@ -2355,7 +2357,7 @@ void CommandInterpreter::SourceInitFileHome(CommandReturnObject &result, llvm::SmallString<128> init_file; if (is_repl) - GetHomeREPLInitFile(init_file); + GetHomeREPLInitFile(init_file, GetDebugger().GetREPLLanguage()); if (init_file.empty()) GetHomeInitFile(init_file); @@ -2839,12 +2841,10 @@ void CommandInterpreter::OutputHelpText(Stream &strm, llvm::StringRef word_text, void CommandInterpreter::FindCommandsForApropos( llvm::StringRef search_word, StringList &commands_found, - StringList &commands_help, CommandObject::CommandMap &command_map) { - CommandObject::CommandMap::const_iterator pos; - - for (pos = command_map.begin(); pos != command_map.end(); ++pos) { - llvm::StringRef command_name = pos->first; - CommandObject *cmd_obj = pos->second.get(); + StringList &commands_help, const CommandObject::CommandMap &command_map) { + for (const auto &pair : command_map) { + llvm::StringRef command_name = pair.first; + CommandObject *cmd_obj = pair.second.get(); const bool search_short_help = true; const bool search_long_help = false; @@ -2854,14 +2854,19 @@ void CommandInterpreter::FindCommandsForApropos( cmd_obj->HelpTextContainsWord(search_word, search_short_help, search_long_help, search_syntax, search_options)) { - commands_found.AppendString(cmd_obj->GetCommandName()); + commands_found.AppendString(command_name); commands_help.AppendString(cmd_obj->GetHelp()); } - if (cmd_obj->IsMultiwordObject()) { - CommandObjectMultiword *cmd_multiword = cmd_obj->GetAsMultiwordCommand(); - FindCommandsForApropos(search_word, commands_found, commands_help, - cmd_multiword->GetSubcommandDictionary()); + if (auto *multiword_cmd = cmd_obj->GetAsMultiwordCommand()) { + StringList subcommands_found; + FindCommandsForApropos(search_word, subcommands_found, commands_help, + multiword_cmd->GetSubcommandDictionary()); + for (const auto &subcommand_name : subcommands_found) { + std::string qualified_name = + (command_name + " " + subcommand_name).str(); + commands_found.AppendString(qualified_name); + } } } } |
