[lld] r221648 - [Gnu][Driver] Use StringRef conversion functions

Shankar Easwaran shankare at codeaurora.org
Mon Nov 10 16:40:33 PST 2014


Author: shankare
Date: Mon Nov 10 18:40:32 2014
New Revision: 221648

URL: http://llvm.org/viewvc/llvm-project?rev=221648&view=rev
Log:
[Gnu][Driver] Use StringRef conversion functions

Modified:
    lld/trunk/lib/Driver/GnuLdDriver.cpp

Modified: lld/trunk/lib/Driver/GnuLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdDriver.cpp?rev=221648&r1=221647&r2=221648&view=diff
==============================================================================
--- lld/trunk/lib/Driver/GnuLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/GnuLdDriver.cpp Mon Nov 10 18:40:32 2014
@@ -15,7 +15,6 @@
 
 #include "lld/Driver/Driver.h"
 #include "lld/Driver/GnuLdInputGraph.h"
-#include "lld/Support/NumParse.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
@@ -158,12 +157,8 @@ static bool parseZOption(StringRef opt,
   if (equalPos == 0 || equalPos == StringRef::npos)
     return false;
   StringRef value = opt.substr(equalPos + 1);
-  ErrorOr<uint64_t> parsedVal = lld::parseNum(value, false /*No Extensions*/);
-  if (!parsedVal)
-    return false;
-  // Dont allow a value of 0 for max-page-size.
-  val = parsedVal.get();
-  if (!val)
+  val = 0;
+  if (value.getAsInteger(0, val) || !val)
     return false;
   return true;
 }
@@ -595,15 +590,14 @@ bool GnuLdDriver::parse(int argc, const
       break;
 
     case OPT_image_base: {
-      ErrorOr<uint64_t> baseAddress =
-          lld::parseNum(inputArg->getValue(), false);
-      if (baseAddress && baseAddress.get())
-        ctx->setBaseAddress(baseAddress.get());
-      else {
-        diagnostics << "invalid value for image base " << inputArg->getValue()
+      uint64_t baseAddress = 0;
+      StringRef inputValue = inputArg->getValue();
+      if ((inputValue.getAsInteger(0, baseAddress)) || !baseAddress) {
+        diagnostics << "invalid value for image base " << inputValue
                     << "\n";
         return false;
       }
+      ctx->setBaseAddress(baseAddress);
       break;
     }
 





More information about the llvm-commits mailing list