diff options
Diffstat (limited to 'lldb/source/Interpreter')
-rw-r--r-- | lldb/source/Interpreter/CommandObject.cpp | 2 | ||||
-rw-r--r-- | lldb/source/Interpreter/OptionValue.cpp | 7 | ||||
-rw-r--r-- | lldb/source/Interpreter/OptionValueArch.cpp | 2 | ||||
-rw-r--r-- | lldb/source/Interpreter/OptionValueBoolean.cpp | 40 | ||||
-rw-r--r-- | lldb/source/Interpreter/OptionValueEnumeration.cpp | 4 | ||||
-rw-r--r-- | lldb/source/Interpreter/OptionValueFileSpec.cpp | 8 | ||||
-rw-r--r-- | lldb/source/Interpreter/OptionValueFormatEntity.cpp | 2 | ||||
-rw-r--r-- | lldb/source/Interpreter/OptionValueUUID.cpp | 6 |
8 files changed, 29 insertions, 42 deletions
diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp index 4c6ec8e4ba6..36fcea0a9c2 100644 --- a/lldb/source/Interpreter/CommandObject.cpp +++ b/lldb/source/Interpreter/CommandObject.cpp @@ -1023,7 +1023,7 @@ static llvm::StringRef arch_helper() { static StreamString g_archs_help; if (g_archs_help.Empty()) { StringList archs; - ArchSpec::AutoComplete(nullptr, archs); + ArchSpec::AutoComplete(llvm::StringRef(), archs); g_archs_help.Printf("These are the supported architecture names:\n"); archs.Join("\n", g_archs_help); } diff --git a/lldb/source/Interpreter/OptionValue.cpp b/lldb/source/Interpreter/OptionValue.cpp index bacdbc59791..446fb8e656d 100644 --- a/lldb/source/Interpreter/OptionValue.cpp +++ b/lldb/source/Interpreter/OptionValue.cpp @@ -573,9 +573,10 @@ bool OptionValue::DumpQualifiedName(Stream &strm) const { return dumped_something; } -size_t OptionValue::AutoComplete(CommandInterpreter &interpreter, const char *s, - int match_start_point, int max_return_elements, - bool &word_complete, StringList &matches) { +size_t OptionValue::AutoComplete(CommandInterpreter &interpreter, + llvm::StringRef s, int match_start_point, + int max_return_elements, bool &word_complete, + StringList &matches) { word_complete = false; matches.Clear(); return matches.GetSize(); diff --git a/lldb/source/Interpreter/OptionValueArch.cpp b/lldb/source/Interpreter/OptionValueArch.cpp index 81d458ffe01..3e41300a418 100644 --- a/lldb/source/Interpreter/OptionValueArch.cpp +++ b/lldb/source/Interpreter/OptionValueArch.cpp @@ -74,7 +74,7 @@ lldb::OptionValueSP OptionValueArch::DeepCopy() const { } size_t OptionValueArch::AutoComplete(CommandInterpreter &interpreter, - const char *s, int match_start_point, + llvm::StringRef s, int match_start_point, int max_return_elements, bool &word_complete, StringList &matches) { word_complete = false; diff --git a/lldb/source/Interpreter/OptionValueBoolean.cpp b/lldb/source/Interpreter/OptionValueBoolean.cpp index bd988fa5750..85799fe3cd4 100644 --- a/lldb/source/Interpreter/OptionValueBoolean.cpp +++ b/lldb/source/Interpreter/OptionValueBoolean.cpp @@ -76,35 +76,23 @@ lldb::OptionValueSP OptionValueBoolean::DeepCopy() const { return OptionValueSP(new OptionValueBoolean(*this)); } -size_t OptionValueBoolean::AutoComplete(CommandInterpreter &interpreter, - const char *s, int match_start_point, - int max_return_elements, - bool &word_complete, - StringList &matches) { +size_t OptionValueBoolean::AutoComplete( + CommandInterpreter &interpreter, llvm::StringRef s, int match_start_point, + int max_return_elements, bool &word_complete, StringList &matches) { word_complete = false; matches.Clear(); - struct StringEntry { - const char *string; - const size_t length; - }; - static const StringEntry g_autocomplete_entries[] = { - {"true", 4}, {"false", 5}, {"on", 2}, {"off", 3}, - {"yes", 3}, {"no", 2}, {"1", 1}, {"0", 1}, - }; - const size_t k_num_autocomplete_entries = - llvm::array_lengthof(g_autocomplete_entries); + static const llvm::StringRef g_autocomplete_entries[] = { + "true", "false", "on", "off", "yes", "no", "1", "0"}; - if (s && s[0]) { - const size_t s_len = strlen(s); - for (size_t i = 0; i < k_num_autocomplete_entries; ++i) { - if (s_len <= g_autocomplete_entries[i].length) - if (::strncasecmp(s, g_autocomplete_entries[i].string, s_len) == 0) - matches.AppendString(g_autocomplete_entries[i].string); - } - } else { - // only suggest "true" or "false" by default - for (size_t i = 0; i < 2; ++i) - matches.AppendString(g_autocomplete_entries[i].string); + auto entries = llvm::makeArrayRef(g_autocomplete_entries); + + // only suggest "true" or "false" by default + if (s.empty()) + entries = entries.take_front(2); + + for (auto entry : entries) { + if (entry.startswith_lower(s)) + matches.AppendString(entry); } return matches.GetSize(); } diff --git a/lldb/source/Interpreter/OptionValueEnumeration.cpp b/lldb/source/Interpreter/OptionValueEnumeration.cpp index 3ec2829c094..679b5ccbaa6 100644 --- a/lldb/source/Interpreter/OptionValueEnumeration.cpp +++ b/lldb/source/Interpreter/OptionValueEnumeration.cpp @@ -111,13 +111,13 @@ lldb::OptionValueSP OptionValueEnumeration::DeepCopy() const { } size_t OptionValueEnumeration::AutoComplete( - CommandInterpreter &interpreter, const char *s, int match_start_point, + CommandInterpreter &interpreter, llvm::StringRef s, int match_start_point, int max_return_elements, bool &word_complete, StringList &matches) { word_complete = false; matches.Clear(); const uint32_t num_enumerators = m_enumerations.GetSize(); - if (s && s[0]) { + if (!s.empty()) { for (size_t i = 0; i < num_enumerators; ++i) { llvm::StringRef name = m_enumerations.GetCStringAtIndex(i); if (name.startswith(s)) diff --git a/lldb/source/Interpreter/OptionValueFileSpec.cpp b/lldb/source/Interpreter/OptionValueFileSpec.cpp index f5c292d6f49..a6eb5375851 100644 --- a/lldb/source/Interpreter/OptionValueFileSpec.cpp +++ b/lldb/source/Interpreter/OptionValueFileSpec.cpp @@ -101,11 +101,9 @@ lldb::OptionValueSP OptionValueFileSpec::DeepCopy() const { return OptionValueSP(new OptionValueFileSpec(*this)); } -size_t OptionValueFileSpec::AutoComplete(CommandInterpreter &interpreter, - const char *s, int match_start_point, - int max_return_elements, - bool &word_complete, - StringList &matches) { +size_t OptionValueFileSpec::AutoComplete( + CommandInterpreter &interpreter, llvm::StringRef s, int match_start_point, + int max_return_elements, bool &word_complete, StringList &matches) { word_complete = false; matches.Clear(); CommandCompletions::InvokeCommonCompletionCallbacks( diff --git a/lldb/source/Interpreter/OptionValueFormatEntity.cpp b/lldb/source/Interpreter/OptionValueFormatEntity.cpp index 29c3b404806..03f077cf9e8 100644 --- a/lldb/source/Interpreter/OptionValueFormatEntity.cpp +++ b/lldb/source/Interpreter/OptionValueFormatEntity.cpp @@ -108,7 +108,7 @@ lldb::OptionValueSP OptionValueFormatEntity::DeepCopy() const { } size_t OptionValueFormatEntity::AutoComplete( - CommandInterpreter &interpreter, const char *s, int match_start_point, + CommandInterpreter &interpreter, llvm::StringRef s, int match_start_point, int max_return_elements, bool &word_complete, StringList &matches) { return FormatEntity::AutoComplete(s, match_start_point, max_return_elements, word_complete, matches); diff --git a/lldb/source/Interpreter/OptionValueUUID.cpp b/lldb/source/Interpreter/OptionValueUUID.cpp index 18132238118..bd6858cee67 100644 --- a/lldb/source/Interpreter/OptionValueUUID.cpp +++ b/lldb/source/Interpreter/OptionValueUUID.cpp @@ -68,7 +68,7 @@ lldb::OptionValueSP OptionValueUUID::DeepCopy() const { } size_t OptionValueUUID::AutoComplete(CommandInterpreter &interpreter, - const char *s, int match_start_point, + llvm::StringRef s, int match_start_point, int max_return_elements, bool &word_complete, StringList &matches) { word_complete = false; @@ -79,8 +79,8 @@ size_t OptionValueUUID::AutoComplete(CommandInterpreter &interpreter, const size_t num_modules = target->GetImages().GetSize(); if (num_modules > 0) { UUID::ValueType uuid_bytes; - const size_t num_bytes_decoded = - UUID::DecodeUUIDBytesFromCString(s, uuid_bytes, nullptr); + llvm::StringRef rest = UUID::DecodeUUIDBytesFromString(s, uuid_bytes); + const size_t num_bytes_decoded = s.size() - rest.size(); for (size_t i = 0; i < num_modules; ++i) { ModuleSP module_sp(target->GetImages().GetModuleAtIndex(i)); if (module_sp) { |