[llvm] r200159 - AsmParser: improve diagnostics for invalid variants
Saleem Abdulrasool
compnerd at compnerd.org
Sun Jan 26 14:29:43 PST 2014
Author: compnerd
Date: Sun Jan 26 16:29:43 2014
New Revision: 200159
URL: http://llvm.org/viewvc/llvm-project?rev=200159&view=rev
Log:
AsmParser: improve diagnostics for invalid variants
An emitted diagnostic for an invalid relocation variant would place the caret on
the token following the relocation variant indicator or at the end of the line
if there was no following token. This change corrects the placement of the
caret to point to the token.
Added:
llvm/trunk/test/MC/AsmParser/variant-diagnostics-2.s
llvm/trunk/test/MC/AsmParser/variant-diagnostics.s
Modified:
llvm/trunk/lib/MC/MCParser/AsmParser.cpp
Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=200159&r1=200158&r2=200159&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Sun Jan 26 16:29:43 2014
@@ -836,7 +836,8 @@ bool AsmParser::parsePrimaryExpr(const M
Variant = MCSymbolRefExpr::VK_None;
} else {
Variant = MCSymbolRefExpr::VK_None;
- return TokError("invalid variant '" + Split.second + "'");
+ return Error(SMLoc::getFromPointer(Split.second.begin()),
+ "invalid variant '" + Split.second + "'");
}
}
Added: llvm/trunk/test/MC/AsmParser/variant-diagnostics-2.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/variant-diagnostics-2.s?rev=200159&view=auto
==============================================================================
--- llvm/trunk/test/MC/AsmParser/variant-diagnostics-2.s (added)
+++ llvm/trunk/test/MC/AsmParser/variant-diagnostics-2.s Sun Jan 26 16:29:43 2014
@@ -0,0 +1,11 @@
+# RUN: not llvm-mc -triple i386-linux-gnu -filetype asm -o /dev/null 2>&1 %s \
+# RUN: | FileCheck %s
+
+ .text
+
+function:
+ call external at invalid
+
+# CHECK: error: invalid variant 'invalid'
+# CHECK: call external at invalid
+# CHECK: ^
Added: llvm/trunk/test/MC/AsmParser/variant-diagnostics.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/variant-diagnostics.s?rev=200159&view=auto
==============================================================================
--- llvm/trunk/test/MC/AsmParser/variant-diagnostics.s (added)
+++ llvm/trunk/test/MC/AsmParser/variant-diagnostics.s Sun Jan 26 16:29:43 2014
@@ -0,0 +1,13 @@
+@ RUN: not llvm-mc -triple armv7-linux-eabi -filetype asm -o /dev/null 2>&1 %s \
+@ RUN: | FileCheck %s
+
+ .arch armv7
+
+ .type invalid_variant,%function
+invalid_variant:
+ bx target(invalid)
+
+@ CHECK: error: invalid variant 'invalid'
+@ CHECK: bx target(invalid)
+@ CHECK: ^
+
More information about the llvm-commits
mailing list