[llvm] r263802 - [MCParser] Accept uppercase radix variants 0X and 0B
Colin LeMahieu via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 18 11:22:08 PDT 2016
Author: colinl
Date: Fri Mar 18 13:22:07 2016
New Revision: 263802
URL: http://llvm.org/viewvc/llvm-project?rev=263802&view=rev
Log:
[MCParser] Accept uppercase radix variants 0X and 0B
Differential Revision: http://reviews.llvm.org/D14781
Added:
llvm/trunk/test/MC/AsmParser/uppercase-hex.s
Modified:
llvm/trunk/lib/MC/MCParser/AsmLexer.cpp
llvm/trunk/lib/Support/StringRef.cpp
Modified: llvm/trunk/lib/MC/MCParser/AsmLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmLexer.cpp?rev=263802&r1=263801&r2=263802&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmLexer.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmLexer.cpp Fri Mar 18 13:22:07 2016
@@ -284,7 +284,7 @@ AsmToken AsmLexer::LexDigit() {
return intToken(Result, Value);
}
- if (*CurPtr == 'b') {
+ if ((*CurPtr == 'b') || (*CurPtr == 'B')) {
++CurPtr;
// See if we actually have "0b" as part of something like "jmp 0b\n"
if (!isdigit(CurPtr[0])) {
@@ -313,7 +313,7 @@ AsmToken AsmLexer::LexDigit() {
return intToken(Result, Value);
}
- if (*CurPtr == 'x') {
+ if ((*CurPtr == 'x') || (*CurPtr == 'X')) {
++CurPtr;
const char *NumStart = CurPtr;
while (isxdigit(CurPtr[0]))
Modified: llvm/trunk/lib/Support/StringRef.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/StringRef.cpp?rev=263802&r1=263801&r2=263802&view=diff
==============================================================================
--- llvm/trunk/lib/Support/StringRef.cpp (original)
+++ llvm/trunk/lib/Support/StringRef.cpp Fri Mar 18 13:22:07 2016
@@ -351,12 +351,12 @@ size_t StringRef::count(StringRef Str) c
}
static unsigned GetAutoSenseRadix(StringRef &Str) {
- if (Str.startswith("0x")) {
+ if (Str.startswith("0x") || Str.startswith("0X")) {
Str = Str.substr(2);
return 16;
}
- if (Str.startswith("0b")) {
+ if (Str.startswith("0b") || Str.startswith("0B")) {
Str = Str.substr(2);
return 2;
}
Added: llvm/trunk/test/MC/AsmParser/uppercase-hex.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/uppercase-hex.s?rev=263802&view=auto
==============================================================================
--- llvm/trunk/test/MC/AsmParser/uppercase-hex.s (added)
+++ llvm/trunk/test/MC/AsmParser/uppercase-hex.s Fri Mar 18 13:22:07 2016
@@ -0,0 +1,7 @@
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
+
+foo:
+.short 0X1
+# CHECK: .short 1
+.short 0B1
+# CHECK: .short 1
More information about the llvm-commits
mailing list