[PATCH] D14781: Recognize 0X and 0B as a valid radix characters.

Sid Manning via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 18 10:11:09 PST 2015


sidneym created this revision.
sidneym added reviewers: colinl, shankar.easwaran, rafael.
sidneym added a subscriber: llvm-commits.
sidneym set the repository for this revision to rL LLVM.

llvm-mc doesn't recognize the upper case equivalents of 0x# and 0b#.  

Repository:
  rL LLVM

http://reviews.llvm.org/D14781

Files:
  lib/MC/MCParser/AsmLexer.cpp
  lib/Support/StringRef.cpp
  test/MC/AsmParser/uppercase-hex.s

Index: test/MC/AsmParser/uppercase-hex.s
===================================================================
--- /dev/null
+++ 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: lib/Support/StringRef.cpp
===================================================================
--- lib/Support/StringRef.cpp
+++ 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;
   }
Index: lib/MC/MCParser/AsmLexer.cpp
===================================================================
--- lib/MC/MCParser/AsmLexer.cpp
+++ lib/MC/MCParser/AsmLexer.cpp
@@ -280,7 +280,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])) {
@@ -309,7 +309,7 @@
     return intToken(Result, Value);
   }
 
-  if (*CurPtr == 'x') {
+  if ((*CurPtr == 'x') || (*CurPtr == 'X')) {
     ++CurPtr;
     const char *NumStart = CurPtr;
     while (isxdigit(CurPtr[0]))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14781.40530.patch
Type: text/x-patch
Size: 1469 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151118/b9739180/attachment.bin>


More information about the llvm-commits mailing list