aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-04-04 18:42:18 +0000
committerChris Lattner <sabre@nondot.org>2010-04-04 18:42:18 +0000
commit65eeaad91d78b2a677ca889eaff60f6d807c7030 (patch)
tree9dc71530f76639e155d57e3aa64c8e057e1c286e /lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
parent736e31d0cfd8a28c31741f39be606a11e7fc0036 (diff)
use stringref instead of strtol to avoid errno gymnastics.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100341 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp')
-rw-r--r--lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp b/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
index d776351a35..a85e97f2e2 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
@@ -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 @@ void AsmPrinter::EmitInlineAsm(const MachineInstr *MI) const {
}
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 @@ void AsmPrinter::EmitInlineAsm(const MachineInstr *MI) const {
++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) + "'");
}