[Lldb-commits] [PATCH] D82382: [lldb][NFC] Replace most uses of StringConvert in LLDB with LLVM's to_integer

2020-06-24 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/source/Host/common/Socket.cpp:286
   host_str = host_str.substr(1, host_str.size() - 2);
-bool ok = false;
-port = StringConvert::ToUInt32(port_str.c_str(), UINT32_MAX, 10, );
+bool ok = llvm::to_integer(port_str, port);
 if (ok && port <= UINT16_MAX) {

Consider inlining the call?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D82382



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D82382: [lldb][NFC] Replace most uses of StringConvert in LLDB with LLVM's to_integer

2020-06-23 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added inline comments.



Comment at: lldb/source/Interpreter/OptionValueArray.cpp:209
   for (i = 0; i < argc; ++i) {
-const size_t idx =
-StringConvert::ToSInt32(args.GetArgumentAtIndex(i), INT32_MAX);
-if (idx >= size) {
+size_t idx;
+if (!llvm::to_integer(args.GetArgumentAtIndex(i), idx) || idx >= size) 
{

I am curious why we are using `size_t` here but it looks like we are using 
`uint32_t` in other places. 



Comment at: lldb/source/Interpreter/OptionValueFileSpecList.cpp:132
   size_t i;
+  const std::size_t size = m_current_value.GetSize();
   for (i = 0; all_indexes_valid && i < argc; ++i) {

We use `uint32_t` to hold the result of `m_current_value.GetSize()` above, but 
`size_t` here. 

These should be consistent.



Comment at: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp:4643
+  if (!llvm::to_integer(main_lm, list.m_link_map))
+list.m_link_map = 0;
 }

Should this be `LLDB_INVALID_ADDRESS`?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D82382



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D82382: [lldb][NFC] Replace most uses of StringConvert in LLDB with LLVM's to_integer

2020-06-23 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor marked an inline comment as done.
teemperor added inline comments.



Comment at: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp:1508
 // thread in big endian hex
-tid = StringConvert::ToUInt64(value.c_str(), LLDB_INVALID_THREAD_ID, 16);
-if (tid != LLDB_INVALID_THREAD_ID)
+if (llvm::to_integer(value.c_str(), tid, 16))
   m_thread_ids.push_back(tid);

Just to get ahead of people pointing this `c_str()` call out: This is just used 
as we keep inserting null terminators into the `value` string (as a replacement 
for doing `substr()`), so we actually only want to pass this new substring to 
`to_integer` and not all of `value`. I'll clean this (and the similar code 
below) up in a follow-up patch.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D82382



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D82382: [lldb][NFC] Replace most uses of StringConvert in LLDB with LLVM's to_integer

2020-06-23 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: LLDB.
Herald added subscribers: JDevlieghere, abidh.
teemperor edited the summary of this revision.

This replaces most uses of LLDB's own String to int/float conversion 
implementation with
LLVM's to_integer. The only remaining code in LLDB that now still uses 
StringConvert is
debugserver which can't use LLVM code, so I'll leave that part for a future 
commit.

Unlike the other StringConvert patch this doesn't try to add any missing error 
handling
but just does a NFC refactoring to `to_integer`.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D82382

Files:
  lldb/source/Host/common/Socket.cpp
  lldb/source/Host/common/XML.cpp
  lldb/source/Interpreter/OptionValueArray.cpp
  lldb/source/Interpreter/OptionValueFileSpecList.cpp
  lldb/source/Interpreter/OptionValuePathMappings.cpp
  lldb/source/Interpreter/OptionValueSInt64.cpp
  lldb/source/Interpreter/OptionValueUInt64.cpp
  lldb/source/Interpreter/Property.cpp
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
  lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Symbol/SymbolContext.cpp
  lldb/source/Target/UnixSignals.cpp
  lldb/unittests/debugserver/RNBSocketTest.cpp

Index: lldb/unittests/debugserver/RNBSocketTest.cpp
===
--- lldb/unittests/debugserver/RNBSocketTest.cpp
+++ lldb/unittests/debugserver/RNBSocketTest.cpp
@@ -15,7 +15,6 @@
 #include "RNBDefs.h"
 #include "RNBSocket.h"
 #include "lldb/Host/Socket.h"
-#include "lldb/Host/StringConvert.h"
 #include "lldb/Host/common/TCPSocket.h"
 #include "llvm/Testing/Support/Error.h"
 
Index: lldb/source/Target/UnixSignals.cpp
===
--- lldb/source/Target/UnixSignals.cpp
+++ lldb/source/Target/UnixSignals.cpp
@@ -12,7 +12,6 @@
 #include "Plugins/Process/Utility/MipsLinuxSignals.h"
 #include "Plugins/Process/Utility/NetBSDSignals.h"
 #include "lldb/Host/HostInfo.h"
-#include "lldb/Host/StringConvert.h"
 #include "lldb/Utility/ArchSpec.h"
 
 using namespace lldb_private;
@@ -162,9 +161,8 @@
   return pos->first;
   }
 
-  const int32_t signo =
-  StringConvert::ToSInt32(name, LLDB_INVALID_SIGNAL_NUMBER, 0);
-  if (signo != LLDB_INVALID_SIGNAL_NUMBER)
+  int32_t signo;
+  if (llvm::to_integer(name, signo))
 return signo;
   return LLDB_INVALID_SIGNAL_NUMBER;
 }
Index: lldb/source/Symbol/SymbolContext.cpp
===
--- lldb/source/Symbol/SymbolContext.cpp
+++ lldb/source/Symbol/SymbolContext.cpp
@@ -11,7 +11,6 @@
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleSpec.h"
 #include "lldb/Host/Host.h"
-#include "lldb/Host/StringConvert.h"
 #include "lldb/Symbol/Block.h"
 #include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/ObjectFile.h"
@@ -972,12 +971,12 @@
 m_type |= eFileSpecified;
 break;
   case eLineStartSpecified:
-m_start_line = StringConvert::ToSInt32(spec_string, 0, 0, _value);
+return_value = llvm::to_integer(spec_string, m_start_line);
 if (return_value)
   m_type |= eLineStartSpecified;
 break;
   case eLineEndSpecified:
-m_end_line = StringConvert::ToSInt32(spec_string, 0, 0, _value);
+return_value = llvm::to_integer(spec_string, m_end_line);
 if (return_value)
   m_type |= eLineEndSpecified;
 break;
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -9,7 +9,6 @@
 #include "DWARFUnit.h"
 
 #include "lldb/Core/Module.h"
-#include "lldb/Host/StringConvert.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Utility/LLDBAssert.h"
 #include "lldb/Utility/StreamString.h"
@@ -616,12 +615,12 @@
 llvm::SmallVector matches;
 if (g_clang_version_regex.Execute(llvm::StringRef(producer_cstr),
   )) {
-  m_producer_version_major =
-  StringConvert::ToUInt32(matches[1].str().c_str(), UINT32_MAX, 10);
-  m_producer_version_minor =
-  StringConvert::ToUInt32(matches[2].str().c_str(), UINT32_MAX, 10);
-  m_producer_version_update =
-  StringConvert::ToUInt32(matches[3].str().c_str(), UINT32_MAX, 10);
+  if (!llvm::to_integer(matches[1], m_producer_version_major))
+m_producer_version_major = UINT32_MAX;
+  if (!llvm::to_integer(matches[2], m_producer_version_minor))
+m_producer_version_minor = UINT32_MAX;
+  if (!llvm::to_integer(matches[3],