[PATCH] D52645: [AsmParser] Return an error in the case of empty symbol ref in an expression

Francis Visoiu Mistrih via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 28 04:13:20 PDT 2018


thegameg created this revision.
thegameg added reviewers: weimingz, rengolin, eli.friedman, t.p.northover.
Herald added a reviewer: javed.absar.

The following instruction:

  str q28, [x0, #1*6*4*@]

contains a `@` which is parsed as an empty symbol. The parser returns true but has no error, so the assembler continues by ignoring the instruction.

This check was introduced by https://reviews.llvm.org/D26728 to avoid asserting.


https://reviews.llvm.org/D52645

Files:
  lib/MC/MCParser/AsmParser.cpp
  test/MC/AArch64/expr-bad-symbol.s


Index: test/MC/AArch64/expr-bad-symbol.s
===================================================================
--- /dev/null
+++ test/MC/AArch64/expr-bad-symbol.s
@@ -0,0 +1,6 @@
+// RUN: not llvm-mc -triple aarch64-- %s 2>&1 | FileCheck %s
+
+  .text
+_foo:
+  str q28, [x0, #1*6*4*@]
+// CHECK: error: expected a symbol reference
Index: lib/MC/MCParser/AsmParser.cpp
===================================================================
--- lib/MC/MCParser/AsmParser.cpp
+++ lib/MC/MCParser/AsmParser.cpp
@@ -1103,7 +1103,7 @@
     // This is a symbol reference.
     StringRef SymbolName = Identifier;
     if (SymbolName.empty())
-      return true;
+      return Error(getLexer().getLoc(), "expected a symbol reference");
 
     MCSymbolRefExpr::VariantKind Variant = MCSymbolRefExpr::VK_None;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52645.167449.patch
Type: text/x-patch
Size: 797 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180928/618d4395/attachment.bin>


More information about the llvm-commits mailing list