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.

llvm-svn: 200159
This commit is contained in:
Saleem Abdulrasool 2014-01-26 22:29:43 +00:00
parent 077fd251fd
commit a25e1e4ebe
3 changed files with 26 additions and 1 deletions

View File

@ -836,7 +836,8 @@ bool AsmParser::parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) {
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 + "'");
}
}

View File

@ -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@invalid
# CHECK: error: invalid variant 'invalid'
# CHECK: call external@invalid
# CHECK: ^

View File

@ -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: ^