[PATCH] D14781: Recognize 0X and 0B as a valid radix characters.
Colin LeMahieu via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 18 11:27:08 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL263802: [MCParser] Accept uppercase radix variants 0X and 0B (authored by colinl).
Changed prior to commit:
http://reviews.llvm.org/D14781?vs=40530&id=51047#toc
Repository:
rL LLVM
http://reviews.llvm.org/D14781
Files:
llvm/trunk/lib/MC/MCParser/AsmLexer.cpp
llvm/trunk/lib/Support/StringRef.cpp
llvm/trunk/test/MC/AsmParser/uppercase-hex.s
Index: llvm/trunk/test/MC/AsmParser/uppercase-hex.s
===================================================================
--- llvm/trunk/test/MC/AsmParser/uppercase-hex.s
+++ llvm/trunk/test/MC/AsmParser/uppercase-hex.s
@@ -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
Index: llvm/trunk/lib/MC/MCParser/AsmLexer.cpp
===================================================================
--- llvm/trunk/lib/MC/MCParser/AsmLexer.cpp
+++ llvm/trunk/lib/MC/MCParser/AsmLexer.cpp
@@ -284,7 +284,7 @@
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 @@
return intToken(Result, Value);
}
- if (*CurPtr == 'x') {
+ if ((*CurPtr == 'x') || (*CurPtr == 'X')) {
++CurPtr;
const char *NumStart = CurPtr;
while (isxdigit(CurPtr[0]))
Index: llvm/trunk/lib/Support/StringRef.cpp
===================================================================
--- llvm/trunk/lib/Support/StringRef.cpp
+++ llvm/trunk/lib/Support/StringRef.cpp
@@ -351,12 +351,12 @@
}
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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14781.51047.patch
Type: text/x-patch
Size: 1592 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160318/c43a6f74/attachment.bin>
More information about the llvm-commits
mailing list