Index: lib/Target/ARM/AsmParser/ARMAsmParser.cpp =================================================================== --- lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -3404,13 +3404,13 @@ /// parse for a specific register type. bool ARMAsmParser::tryParseRegisterWithWriteBack(OperandVector &Operands) { MCAsmParser &Parser = getParser(); - const AsmToken &RegTok = Parser.getTok(); + SMLoc RegStartLoc = Parser.getTok().getLoc(); + SMLoc RegEndLoc = Parser.getTok().getEndLoc(); int RegNo = tryParseRegister(); if (RegNo == -1) return true; - Operands.push_back(ARMOperand::CreateReg(RegNo, RegTok.getLoc(), - RegTok.getEndLoc())); + Operands.push_back(ARMOperand::CreateReg(RegNo, RegStartLoc, RegEndLoc)); const AsmToken &ExclaimTok = Parser.getTok(); if (ExclaimTok.is(AsmToken::Exclaim)) { Index: test/MC/ARM/register-token-source-loc.s =================================================================== --- /dev/null +++ test/MC/ARM/register-token-source-loc.s @@ -0,0 +1,12 @@ +// RUN: not llvm-mc -triple armv6m--none-eabi < %s 2>&1 | FileCheck %s + +// Some of these CHECK lines need to uses regexes to that the amount of +// whitespace between the start of the line and the caret is significant. + + add sp, r0, #4 +// CHECK: error: invalid instruction, multiple near-miss encodings found +// CHECK: note: for one encoding: instruction requires: thumb2 +// CHECK: note: for one encoding: invalid operand for instruction +// CHECK-NEXT: {{^ add sp, r0, #4}} +// CHECK-NEXT: {{^ \^}} +// CHECK: note: for one encoding: too many operands for instruction