[MCParser] Accept uppercase radix variants 0X and 0B
authorColin LeMahieu <colinl@codeaurora.org>
Fri, 18 Mar 2016 18:22:07 +0000 (18:22 +0000)
committerColin LeMahieu <colinl@codeaurora.org>
Fri, 18 Mar 2016 18:22:07 +0000 (18:22 +0000)
Differential Revision: http://reviews.llvm.org/D14781

llvm-svn: 263802

llvm/lib/MC/MCParser/AsmLexer.cpp
llvm/lib/Support/StringRef.cpp
llvm/test/MC/AsmParser/uppercase-hex.s [new file with mode: 0644]

index 424c8ae..9b057c2 100644 (file)
@@ -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]))
index 7ecff29..8a9da5e 100644 (file)
@@ -351,12 +351,12 @@ size_t StringRef::count(StringRef Str) const {
 }
 
 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;
   }
diff --git a/llvm/test/MC/AsmParser/uppercase-hex.s b/llvm/test/MC/AsmParser/uppercase-hex.s
new file mode 100644 (file)
index 0000000..721fc7f
--- /dev/null
@@ -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