[Lldb-commits] [PATCH] D110391: [lldb] [Host] Refactor Socket::DecodeHostAndPort() to use LLVM API
Michał Górny via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Fri Sep 24 04:20:13 PDT 2021
mgorny marked 2 inline comments as done.
mgorny added inline comments.
================
Comment at: lldb/source/Host/common/Socket.cpp:305
- port_str.clear();
- if (to_integer(host_and_port, port, 10) && port < UINT16_MAX) {
- port_str = std::string(host_and_port);
----------------
labath wrote:
> Actually, `to_integer` is already an llvm API (accessed via ADL here :P), and overall I'd prefer to standardize on that, as the most common error with `getAsInteger` is to get the return value backwards.
>
> (to_integer will also do an implicit StringRef conversion, so you can call it on a std::string without manual casts).
Well, I personally prefer object-based API but sure, either way is fine.
================
Comment at: lldb/tools/lldb-server/Acceptor.cpp:101-103
+ if (llvm::Error decode_error = Socket::DecodeHostAndPort(name, host_str, port_str, port))
+ llvm::consumeError(std::move(decode_error));
+ else
----------------
labath wrote:
> `if (!errorToBool(Socket::DecodeHostAndPort(...)))`
Note to self: if something takes more than two lines of code, LLVM probably has a helper ;-).
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D110391/new/
https://reviews.llvm.org/D110391
More information about the lldb-commits
mailing list