[PATCH] D99609: [AsmParser] Recognize more escaped characters between single quotes

LemonBoy via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 30 10:12:58 PDT 2021


LemonBoy created this revision.
Herald added a subscriber: hiraditya.
LemonBoy requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The GNU AS manual states the following about single-character constants enclosed within single quotes:

> Some backslash escapes apply to characters, \b, \f, \n, \r, \t, and \" with the same meaning as for strings, plus \' for a single quote.

Add two more characters to the switch handling this case to match GAS behaviour, plus a test to make sure nothing regresses.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99609

Files:
  llvm/lib/MC/MCParser/AsmLexer.cpp
  llvm/test/MC/AsmParser/directive_values.s


Index: llvm/test/MC/AsmParser/directive_values.s
===================================================================
--- llvm/test/MC/AsmParser/directive_values.s
+++ llvm/test/MC/AsmParser/directive_values.s
@@ -48,6 +48,9 @@
         .byte '\#'
         .byte '\t'
         .byte '\n'
+        .byte '\r'
+        .byte '\f'
+        .byte '\"'
 
 # CHECK: TEST6
 # CHECK:        .byte   99
@@ -56,6 +59,9 @@
 # CHECK:        .byte   35
 # CHECK:        .byte   9
 # CHECK:        .byte   10
+# CHECK:        .byte   13
+# CHECK:        .byte   12
+# CHECK:        .byte   34
 
 TEST7:
         .byte 1, 2, 3, 4
Index: llvm/lib/MC/MCParser/AsmLexer.cpp
===================================================================
--- llvm/lib/MC/MCParser/AsmLexer.cpp
+++ llvm/lib/MC/MCParser/AsmLexer.cpp
@@ -569,6 +569,8 @@
       case 't': Value = '\t'; break;
       case 'n': Value = '\n'; break;
       case 'b': Value = '\b'; break;
+      case 'f': Value = '\f'; break;
+      case 'r': Value = '\r'; break;
     }
   } else
     Value = TokStart[1];


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99609.334209.patch
Type: text/x-patch
Size: 1052 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210330/d6e4bb92/attachment.bin>


More information about the llvm-commits mailing list