[llvm-commits] [llvm] r94167 - /llvm/trunk/lib/MC/MCParser/AsmLexer.cpp
Chris Lattner
sabre at nondot.org
Thu Jan 21 23:34:12 PST 2010
Author: lattner
Date: Fri Jan 22 01:34:12 2010
New Revision: 94167
URL: http://llvm.org/viewvc/llvm-project?rev=94167&view=rev
Log:
stop using strtoll, it gives windows heartburn.
Modified:
llvm/trunk/lib/MC/MCParser/AsmLexer.cpp
Modified: llvm/trunk/lib/MC/MCParser/AsmLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmLexer.cpp?rev=94167&r1=94166&r2=94167&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmLexer.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmLexer.cpp Fri Jan 22 01:34:12 2010
@@ -136,8 +136,13 @@
if (CurPtr[-1] != '0') {
while (isdigit(*CurPtr))
++CurPtr;
- return AsmToken(AsmToken::Integer, StringRef(TokStart, CurPtr - TokStart),
- strtoll(TokStart, 0, 10));
+
+ StringRef Result(TokStart, CurPtr - TokStart);
+
+ long long Value;
+ if (Result.getAsInteger(10, Value))
+ return ReturnError(TokStart, "Invalid decimal number");
+ return AsmToken(AsmToken::Integer, Result, Value);
}
if (*CurPtr == 'b') {
@@ -148,9 +153,15 @@
// Requires at least one binary digit.
if (CurPtr == NumStart)
- return ReturnError(CurPtr-2, "Invalid binary number");
- return AsmToken(AsmToken::Integer, StringRef(TokStart, CurPtr - TokStart),
- strtoll(NumStart, 0, 2));
+ return ReturnError(TokStart, "Invalid binary number");
+
+ StringRef Result(TokStart, CurPtr - TokStart);
+
+ long long Value;
+ if (Result.getAsInteger(2, Value))
+ return ReturnError(TokStart, "Invalid binary number");
+
+ return AsmToken(AsmToken::Integer, Result, Value);
}
if (*CurPtr == 'x') {
@@ -165,7 +176,7 @@
unsigned long long Result;
if (StringRef(TokStart, CurPtr - TokStart).getAsInteger(0, Result))
- return ReturnError(CurPtr-2, "Invalid hexadecimal number");
+ return ReturnError(TokStart, "Invalid hexadecimal number");
return AsmToken(AsmToken::Integer, StringRef(TokStart, CurPtr - TokStart),
(int64_t)Result);
@@ -174,8 +185,13 @@
// Must be an octal number, it starts with 0.
while (*CurPtr >= '0' && *CurPtr <= '7')
++CurPtr;
- return AsmToken(AsmToken::Integer, StringRef(TokStart, CurPtr - TokStart),
- strtoll(TokStart, 0, 8));
+
+ StringRef Result(TokStart, CurPtr - TokStart);
+ long long Value;
+ if (Result.getAsInteger(8, Value))
+ return ReturnError(TokStart, "Invalid octal number");
+
+ return AsmToken(AsmToken::Integer, Result, Value);
}
/// LexQuote: String: "..."
More information about the llvm-commits
mailing list