[llvm-commits] [llvm] r100341 - /llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp

Chris Lattner sabre at nondot.org
Sun Apr 4 11:42:19 PDT 2010


Author: lattner
Date: Sun Apr  4 13:42:18 2010
New Revision: 100341

URL: http://llvm.org/viewvc/llvm-project?rev=100341&view=rev
Log:
use stringref instead of strtol to avoid errno gymnastics.

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp?rev=100341&r1=100340&r2=100341&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp Sun Apr  4 13:42:18 2010
@@ -22,7 +22,6 @@
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"
-#include <cerrno>  // FIXME: Stop using this.
 using namespace llvm;
 
 /// EmitInlineAsm - Emit a blob of inline asm to the output streamer.
@@ -168,13 +167,13 @@
       }
             
       const char *IDStart = LastEmitted;
-      char *IDEnd;
-      errno = 0;
-      long Val = strtol(IDStart, &IDEnd, 10); // We only accept numbers for IDs.
-      if (!isdigit(*IDStart) || (Val == 0 && errno == EINVAL)) {
+      const char *IDEnd = IDStart;
+      while (*IDEnd >= '0' && *IDEnd <= '9') ++IDEnd;      
+      
+      unsigned Val;
+      if (StringRef(IDStart, IDEnd-IDStart).getAsInteger(10, Val))
         llvm_report_error("Bad $ operand number in inline asm string: '" 
                           + std::string(AsmStr) + "'");
-      }
       LastEmitted = IDEnd;
       
       char Modifier[2] = { 0, 0 };
@@ -200,7 +199,7 @@
         ++LastEmitted;    // Consume '}' character.
       }
       
-      if ((unsigned)Val >= NumOperands-1) {
+      if (Val >= NumOperands-1) {
         llvm_report_error("Invalid $ operand number in inline asm string: '" 
                           + std::string(AsmStr) + "'");
       }





More information about the llvm-commits mailing list