[PATCH] D142321: [llvm-ml] Disallow '{' and '}' at the start of a statement
Sergei Barannikov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 22 17:58:48 PST 2023
barannikov88 created this revision.
Herald added subscribers: pengfei, hiraditya.
Herald added a project: All.
barannikov88 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
'{', '}' and (conditionally) '*' were allowed at the start of a
statement. This behavior was copied from AsmParser, where they were
added to support Hexagon bundles (braces) and BFP memory instructions
(the star).
MASM dialect is x86-specific and does not allow these symbols to be
used at the beginning of an instruction.
Worth noting that '{' is a valid first character in AT&T syntax
(e.g. "{vex} vpmadd52huq ..."); MASM variant is to omit the braces.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D142321
Files:
llvm/lib/MC/MCParser/MasmParser.cpp
llvm/test/tools/llvm-ml/label_errors.asm
Index: llvm/test/tools/llvm-ml/label_errors.asm
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-ml/label_errors.asm
@@ -0,0 +1,7 @@
+; RUN: not llvm-ml -filetype=s %s /Fo - 2>&1 | FileCheck %s --implicit-check-not=error:
+
+.code
+
+# These used to be valid label names.
+{: ; CHECK: [[@LINE]]:1: error: unexpected token at start of statement
+}: ; CHECK: [[@LINE]]:1: error: unexpected token at start of statement
Index: llvm/lib/MC/MCParser/MasmParser.cpp
===================================================================
--- llvm/lib/MC/MCParser/MasmParser.cpp
+++ llvm/lib/MC/MCParser/MasmParser.cpp
@@ -2125,20 +2125,6 @@
// Treat '.' as a valid identifier in this context.
Lex();
IDVal = ".";
- } else if (Lexer.is(AsmToken::LCurly)) {
- // Treat '{' as a valid identifier in this context.
- Lex();
- IDVal = "{";
-
- } else if (Lexer.is(AsmToken::RCurly)) {
- // Treat '}' as a valid identifier in this context.
- Lex();
- IDVal = "}";
- } else if (Lexer.is(AsmToken::Star) &&
- getTargetParser().starIsStartOfStatement()) {
- // Accept '*' as a valid start of statement.
- Lex();
- IDVal = "*";
} else if (Lexer.is(AsmToken::Real)) {
// Treat ".<number>" as a valid identifier in this context.
IDVal = getTok().getString();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142321.491216.patch
Type: text/x-patch
Size: 1363 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230123/bdcf9831/attachment.bin>
More information about the llvm-commits
mailing list