mgorny created this revision.
mgorny added reviewers: labath, teemperor, krytarowski, emaste, JDevlieghere,
jasonmolenda.
mgorny requested review of this revision.
The StringConvert API is no longer used anywhere but in debugserver.
Since debugserver does not use LLVM API, we cannot replace it with
llvm::to_integer() and llvm::to_float() there. Let's just move
the sources into debugserver.
(note: this commit message assumes merging the other parent diffs)
https://reviews.llvm.org/D110478
Files:
lldb/include/lldb/Host/StringConvert.h
lldb/include/lldb/module.modulemap
lldb/source/Host/CMakeLists.txt
lldb/source/Host/common/StringConvert.cpp
lldb/tools/debugserver/source/CMakeLists.txt
lldb/tools/debugserver/source/JSON.cpp
lldb/tools/debugserver/source/StringConvert.cpp
lldb/tools/debugserver/source/StringConvert.h
Index: lldb/tools/debugserver/source/StringConvert.h
===================================================================
--- lldb/tools/debugserver/source/StringConvert.h
+++ lldb/tools/debugserver/source/StringConvert.h
@@ -6,24 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_HOST_STRINGCONVERT_H
-#define LLDB_HOST_STRINGCONVERT_H
+#ifndef LLDB_TOOLS_DEBUGSERVER_SOURCE_STRINGCONVERT_H
+#define LLDB_TOOLS_DEBUGSERVER_SOURCE_STRINGCONVERT_H
#include <cstdint>
-namespace lldb_private {
-
namespace StringConvert {
-/// \namespace StringConvert StringConvert.h "lldb/Host/StringConvert.h"
-/// Utility classes for converting strings into Integers
-
-int32_t ToSInt32(const char *s, int32_t fail_value = 0, int base = 0,
- bool *success_ptr = nullptr);
-
-uint32_t ToUInt32(const char *s, uint32_t fail_value = 0, int base = 0,
- bool *success_ptr = nullptr);
-
int64_t ToSInt64(const char *s, int64_t fail_value = 0, int base = 0,
bool *success_ptr = nullptr);
@@ -32,7 +21,7 @@
double ToDouble(const char *s, double fail_value = 0.0,
bool *success_ptr = nullptr);
+
} // namespace StringConvert
-} // namespace lldb_private
#endif
Index: lldb/tools/debugserver/source/StringConvert.cpp
===================================================================
--- lldb/tools/debugserver/source/StringConvert.cpp
+++ lldb/tools/debugserver/source/StringConvert.cpp
@@ -8,43 +8,10 @@
#include <cstdlib>
-#include "lldb/Host/StringConvert.h"
+#include "StringConvert.h"
-namespace lldb_private {
namespace StringConvert {
-int32_t ToSInt32(const char *s, int32_t fail_value, int base,
- bool *success_ptr) {
- if (s && s[0]) {
- char *end = nullptr;
- const long sval = ::strtol(s, &end, base);
- if (*end == '\0') {
- if (success_ptr)
- *success_ptr = ((sval <= INT32_MAX) && (sval >= INT32_MIN));
- return (int32_t)sval; // All characters were used, return the result
- }
- }
- if (success_ptr)
- *success_ptr = false;
- return fail_value;
-}
-
-uint32_t ToUInt32(const char *s, uint32_t fail_value, int base,
- bool *success_ptr) {
- if (s && s[0]) {
- char *end = nullptr;
- const unsigned long uval = ::strtoul(s, &end, base);
- if (*end == '\0') {
- if (success_ptr)
- *success_ptr = (uval <= UINT32_MAX);
- return (uint32_t)uval; // All characters were used, return the result
- }
- }
- if (success_ptr)
- *success_ptr = false;
- return fail_value;
-}
-
int64_t ToSInt64(const char *s, int64_t fail_value, int base,
bool *success_ptr) {
if (s && s[0]) {
@@ -91,5 +58,5 @@
*success_ptr = false;
return fail_value;
}
-}
-}
+
+} // namespace StringConvert
Index: lldb/tools/debugserver/source/JSON.cpp
===================================================================
--- lldb/tools/debugserver/source/JSON.cpp
+++ lldb/tools/debugserver/source/JSON.cpp
@@ -13,12 +13,10 @@
#include <climits>
// C++ includes
-#include "lldb/Host/StringConvert.h"
+#include "StringConvert.h"
#include <iomanip>
#include <sstream>
-using namespace lldb_private;
-
std::string JSONString::json_string_quote_metachars(const std::string &s) {
if (s.find('"') == std::string::npos)
return s;
Index: lldb/tools/debugserver/source/CMakeLists.txt
===================================================================
--- lldb/tools/debugserver/source/CMakeLists.txt
+++ lldb/tools/debugserver/source/CMakeLists.txt
@@ -206,8 +206,8 @@
DNBThreadResumeActions.cpp
JSON.cpp
StdStringExtractor.cpp
+ StringConvert.cpp
# JSON reader depends on the following LLDB-common files
- ${LLDB_SOURCE_DIR}/source/Host/common/StringConvert.cpp
${LLDB_SOURCE_DIR}/source/Host/common/SocketAddress.cpp
# end JSON reader dependencies
libdebugserver.cpp
Index: lldb/source/Host/CMakeLists.txt
===================================================================
--- lldb/source/Host/CMakeLists.txt
+++ lldb/source/Host/CMakeLists.txt
@@ -37,7 +37,6 @@
common/PseudoTerminal.cpp
common/SocketAddress.cpp
common/Socket.cpp
- common/StringConvert.cpp
common/TCPSocket.cpp
common/Terminal.cpp
common/ThreadLauncher.cpp
Index: lldb/include/lldb/module.modulemap
===================================================================
--- lldb/include/lldb/module.modulemap
+++ lldb/include/lldb/module.modulemap
@@ -48,7 +48,6 @@
module SafeMachO { header "Host/SafeMachO.h" export * }
module SocketAddress { header "Host/SocketAddress.h" export * }
module Socket { header "Host/Socket.h" export * }
- module StringConvert { textual header "Host/StringConvert.h" export * }
module Terminal { header "Host/Terminal.h" export * }
module ThreadLauncher { header "Host/ThreadLauncher.h" export * }
module Time { header "Host/Time.h" export * }
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits