[Lldb-commits] [PATCH] D110391: [lldb] [Host] Refactor Socket::DecodeHostAndPort() to use LLVM API

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Sep 24 02:53:21 PDT 2021


labath accepted this revision.
labath added inline comments.
This revision is now accepted and ready to land.


================
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);
----------------
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).


================
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
----------------
`if (!errorToBool(Socket::DecodeHostAndPort(...)))`


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110391/new/

https://reviews.llvm.org/D110391



More information about the lldb-commits mailing list