diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-10-23 17:53:01 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-10-23 17:53:01 +0000 |
commit | ead246455adf1a215ec2715dad6533073a6beb4e (patch) | |
tree | f3f97a47d77053bf96fe74cdbd6fae74380e8a92 /source/Interpreter/OptionValueUUID.cpp | |
parent | fdb00c4408990a0a63ef7f496d809ce59f263bc5 (diff) |
Notes
Diffstat (limited to 'source/Interpreter/OptionValueUUID.cpp')
-rw-r--r-- | source/Interpreter/OptionValueUUID.cpp | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/source/Interpreter/OptionValueUUID.cpp b/source/Interpreter/OptionValueUUID.cpp index f39b66b77bb0f..7a6bc65b25a40 100644 --- a/source/Interpreter/OptionValueUUID.cpp +++ b/source/Interpreter/OptionValueUUID.cpp @@ -62,30 +62,24 @@ lldb::OptionValueSP OptionValueUUID::DeepCopy() const { return OptionValueSP(new OptionValueUUID(*this)); } -size_t OptionValueUUID::AutoComplete(CommandInterpreter &interpreter, - CompletionRequest &request) { - request.SetWordComplete(false); +void OptionValueUUID::AutoComplete(CommandInterpreter &interpreter, + CompletionRequest &request) { ExecutionContext exe_ctx(interpreter.GetExecutionContext()); Target *target = exe_ctx.GetTargetPtr(); - if (target) { - auto prefix = request.GetCursorArgumentPrefix(); - llvm::SmallVector<uint8_t, 20> uuid_bytes; - if (UUID::DecodeUUIDBytesFromString(prefix, uuid_bytes).empty()) { - const size_t num_modules = target->GetImages().GetSize(); - for (size_t i = 0; i < num_modules; ++i) { - ModuleSP module_sp(target->GetImages().GetModuleAtIndex(i)); - if (module_sp) { - const UUID &module_uuid = module_sp->GetUUID(); - if (module_uuid.IsValid()) { - llvm::ArrayRef<uint8_t> module_bytes = module_uuid.GetBytes(); - if (module_bytes.size() >= uuid_bytes.size() && - module_bytes.take_front(uuid_bytes.size()).equals(uuid_bytes)) { - request.AddCompletion(module_uuid.GetAsString()); - } - } - } - } - } + if (!target) + return; + auto prefix = request.GetCursorArgumentPrefix(); + llvm::SmallVector<uint8_t, 20> uuid_bytes; + if (!UUID::DecodeUUIDBytesFromString(prefix, uuid_bytes).empty()) + return; + const size_t num_modules = target->GetImages().GetSize(); + for (size_t i = 0; i < num_modules; ++i) { + ModuleSP module_sp(target->GetImages().GetModuleAtIndex(i)); + if (!module_sp) + continue; + const UUID &module_uuid = module_sp->GetUUID(); + if (!module_uuid.IsValid()) + continue; + request.TryCompleteCurrentArg(module_uuid.GetAsString()); } - return request.GetNumberOfMatches(); } |