[Lldb-commits] [lldb] r295091 - Use StringRef and APFloat instead of lldb/StringConvert.h

Zachary Turner via lldb-commits lldb-commits at lists.llvm.org
Tue Feb 14 11:07:01 PST 2017


Author: zturner
Date: Tue Feb 14 13:07:01 2017
New Revision: 295091

URL: http://llvm.org/viewvc/llvm-project?rev=295091&view=rev
Log:
Use StringRef and APFloat instead of lldb/StringConvert.h

Modified:
    lldb/trunk/source/Utility/JSON.cpp

Modified: lldb/trunk/source/Utility/JSON.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/JSON.cpp?rev=295091&r1=295090&r2=295091&view=diff
==============================================================================
--- lldb/trunk/source/Utility/JSON.cpp (original)
+++ lldb/trunk/source/Utility/JSON.cpp Tue Feb 14 13:07:01 2017
@@ -9,7 +9,9 @@
 
 #include "lldb/Utility/JSON.h"
 
-#include "lldb/Host/StringConvert.h"
+#include "llvm/ADT/APFloat.h"
+#include "llvm/ADT/StringRef.h"
+
 #include "lldb/Utility/StreamString.h"
 #include "llvm/Support/ErrorHandling.h"
 #include <limits.h>
@@ -512,23 +514,20 @@ JSONValue::SP JSONParser::ParseJSONValue
 
   case JSONParser::Token::Integer: {
     if (value.front() == '-') {
-      bool success = false;
-      int64_t sval = StringConvert::ToSInt64(value.c_str(), 0, 0, &success);
-      if (success)
+      int64_t sval = 0;
+      if (!llvm::StringRef(value).getAsInteger(0, sval))
         return JSONValue::SP(new JSONNumber(sval));
     } else {
-      bool success = false;
-      uint64_t uval = StringConvert::ToUInt64(value.c_str(), 0, 0, &success);
-      if (success)
+      uint64_t uval = 0;
+      if (!llvm::StringRef(value).getAsInteger(0, uval))
         return JSONValue::SP(new JSONNumber(uval));
     }
   } break;
 
   case JSONParser::Token::Float: {
-    bool success = false;
-    double val = StringConvert::ToDouble(value.c_str(), 0.0, &success);
-    if (success)
-      return JSONValue::SP(new JSONNumber(val));
+    double D;
+    if (!llvm::StringRef(value).getAsDouble(D))
+      return JSONValue::SP(new JSONNumber(D));
   } break;
 
   case JSONParser::Token::String:




More information about the lldb-commits mailing list