[llvm] edb18ea - [AsmParser] Recognize more escaped characters between single quotes
via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 8 00:59:45 PDT 2021
Author: LemonBoy
Date: 2021-04-08T09:59:37+02:00
New Revision: edb18ea5a9132a8e359ce0c0b103286d15244b8a
URL: https://github.com/llvm/llvm-project/commit/edb18ea5a9132a8e359ce0c0b103286d15244b8a
DIFF: https://github.com/llvm/llvm-project/commit/edb18ea5a9132a8e359ce0c0b103286d15244b8a.diff
LOG: [AsmParser] Recognize more escaped characters between single quotes
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.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D99609
Added:
Modified:
llvm/lib/MC/MCParser/AsmLexer.cpp
llvm/test/MC/AsmParser/directive_values.s
Removed:
################################################################################
diff --git a/llvm/lib/MC/MCParser/AsmLexer.cpp b/llvm/lib/MC/MCParser/AsmLexer.cpp
index 62631cedd82c..f8e8eea9c2a0 100644
--- a/llvm/lib/MC/MCParser/AsmLexer.cpp
+++ b/llvm/lib/MC/MCParser/AsmLexer.cpp
@@ -597,6 +597,8 @@ AsmToken AsmLexer::LexSingleQuote() {
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];
diff --git a/llvm/test/MC/AsmParser/directive_values.s b/llvm/test/MC/AsmParser/directive_values.s
index 6941a1a59409..125f348db002 100644
--- a/llvm/test/MC/AsmParser/directive_values.s
+++ b/llvm/test/MC/AsmParser/directive_values.s
@@ -1,22 +1,22 @@
# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
-# CHECK: .byte 0
+# CHECK-NEXT: .byte 0
TEST0:
.byte 0
# CHECK: TEST1:
-# CHECK: .short 3
+# CHECK-NEXT: .short 3
TEST1:
.short 3
# CHECK: TEST2:
-# CHECK: .long 8
+# CHECK-NEXT: .long 8
TEST2:
.long 8
# CHECK: TEST3:
-# CHECK: .quad 9
+# CHECK-NEXT: .quad 9
TEST3:
.quad 9
@@ -29,17 +29,17 @@ TEST4:
.quad 4294967295LL+1
.quad 0b10LL + 07ULL + 0x42AULL
# CHECK: TEST4
-# CHECK: .quad 4
-# CHECK: .quad 4294967295
-# CHECK: .quad 4294967296
-# CHECK: .quad 4294967296
-# CHECK: .quad 1075
+# CHECK-NEXT: .quad 4
+# CHECK-NEXT: .quad 4294967295
+# CHECK-NEXT: .quad 4294967296
+# CHECK-NEXT: .quad 4294967296
+# CHECK-NEXT: .quad 1075
TEST5:
.value 8
# CHECK: TEST5:
-# CHECK: .short 8
+# CHECK-NEXT: .short 8
TEST6:
.byte 'c'
@@ -48,18 +48,25 @@ TEST6:
.byte '\#'
.byte '\t'
.byte '\n'
+ .byte '\r'
+ .byte '\f'
+ .byte '\"'
# CHECK: TEST6
-# CHECK: .byte 99
-# CHECK: .byte 39
-# CHECK: .byte 92
-# CHECK: .byte 35
-# CHECK: .byte 9
-# CHECK: .byte 10
+# CHECK-NEXT: .byte 99
+# CHECK-NEXT: .byte 39
+# CHECK-NEXT: .byte 92
+# CHECK-NEXT: .byte 35
+# CHECK-NEXT: .byte 9
+# CHECK-NEXT: .byte 10
+# CHECK-NEXT: .byte 13
+# CHECK-NEXT: .byte 12
+# CHECK-NEXT: .byte 34
TEST7:
.byte 1, 2, 3, 4
-# CHECK: .byte 1
+# CHECK: TEST7
+# CHECK-NEXT: .byte 1
# CHECK-NEXT: .byte 2
# CHECK-NEXT: .byte 3
# CHECK-NEXT: .byte 4
@@ -67,17 +74,18 @@ TEST7:
TEST8:
.long 0x200000UL+1
.long 0x200000L+1
-# CHECK: .long 2097153
-# CHECK: .long 2097153
+# CHECK: TEST8
+# CHECK-NEXT: .long 2097153
+# CHECK-NEXT: .long 2097153
TEST9:
.octa 0x1234567812345678abcdef, 340282366920938463463374607431768211455
.octa 0b00111010010110100101101001011010010110100101101001011010010110100101101001011010010110100101101001011010010110100101101001011010
# CHECK: TEST9
-# CHECK: .quad 8652035380128501231
-# CHECK: .quad 1193046
-# CHECK: .quad -1
-# CHECK: .quad -1
-# CHECK: .quad 6510615555426900570
-# CHECK: .quad 4204772546213206618
+# CHECK-NEXT: .quad 8652035380128501231
+# CHECK-NEXT: .quad 1193046
+# CHECK-NEXT: .quad -1
+# CHECK-NEXT: .quad -1
+# CHECK-NEXT: .quad 6510615555426900570
+# CHECK-NEXT: .quad 4204772546213206618
More information about the llvm-commits
mailing list