[llvm] r288390 - [AsmParser] Diagnose empty symbol for .set directive
Weiming Zhao via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 1 10:00:36 PST 2016
Author: weimingz
Date: Thu Dec 1 12:00:36 2016
New Revision: 288390
URL: http://llvm.org/viewvc/llvm-project?rev=288390&view=rev
Log:
[AsmParser] Diagnose empty symbol for .set directive
Summary: Diagnose empty symbol to avoid hitting assertion in MCContext::getOrCreateSymbol
Reviewers: eli.friedman, rengolin
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D26728
Modified:
llvm/trunk/lib/MC/MCParser/AsmParser.cpp
llvm/trunk/test/MC/AsmParser/equ.s
Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=288390&r1=288389&r2=288390&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Thu Dec 1 12:00:36 2016
@@ -973,6 +973,9 @@ bool AsmParser::parsePrimaryExpr(const M
// 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.
Modified: llvm/trunk/test/MC/AsmParser/equ.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/equ.s?rev=288390&r1=288389&r2=288390&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/equ.s (original)
+++ llvm/trunk/test/MC/AsmParser/equ.s Thu Dec 1 12:00:36 2016
@@ -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
More information about the llvm-commits
mailing list