[PATCH] D26728: [AsmParser] Reject empty symbol for .set directive

Weiming Zhao via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 15 18:21:09 PST 2016


weimingz created this revision.
weimingz added a subscriber: llvm-commits.
weimingz set the repository for this revision to rL LLVM.

Reject empty symbol to avoid hitting assertion in MCContext::getOrCreateSymbol


Repository:
  rL LLVM

https://reviews.llvm.org/D26728

Files:
  lib/MC/MCParser/AsmParser.cpp
  test/MC/AsmParser/equ.s


Index: test/MC/AsmParser/equ.s
===================================================================
--- test/MC/AsmParser/equ.s
+++ test/MC/AsmParser/equ.s
@@ -5,5 +5,6 @@
 .set	a, 1
 .equ	a, 2
 .equiv	a, 3
+.set  b, ""
 // CHECK: error: redefinition of 'a'
-
+// CHECK: error: missing expression in '.set' directive
Index: lib/MC/MCParser/AsmParser.cpp
===================================================================
--- lib/MC/MCParser/AsmParser.cpp
+++ lib/MC/MCParser/AsmParser.cpp
@@ -973,6 +973,9 @@
 
     // This is a symbol reference.
     StringRef SymbolName = Identifier;
+    if (SymbolName.empty())
+      return true;
+
     MCSymbolRefExpr::VariantKind Variant = MCSymbolRefExpr::VK_None;
 
     // Lookup the symbol variant if used.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26728.78121.patch
Type: text/x-patch
Size: 753 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161116/df477e63/attachment.bin>


More information about the llvm-commits mailing list