Skip to content

Commit

Permalink
[AArch64][AsmParser] NFC: Parser.getTok().getLoc() -> getLoc()
Browse files Browse the repository at this point in the history
Reviewed By: tmatheson

Differential Revision: https://reviews.llvm.org/D106635
  • Loading branch information
c-rhodes committed Jul 26, 2021
1 parent 0aff179 commit e6ff917
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
28 changes: 13 additions & 15 deletions llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2904,9 +2904,8 @@ AArch64AsmParser::tryParseImmWithOptionalShift(OperandVector &Operands) {
if (parseSymbolicImmVal(Imm))
return MatchOperand_ParseFail;
else if (Parser.getTok().isNot(AsmToken::Comma)) {
SMLoc E = Parser.getTok().getLoc();
Operands.push_back(
AArch64Operand::CreateImm(Imm, S, E, getContext()));
AArch64Operand::CreateImm(Imm, S, getLoc(), getContext()));
return MatchOperand_Success;
}

Expand All @@ -2916,7 +2915,7 @@ AArch64AsmParser::tryParseImmWithOptionalShift(OperandVector &Operands) {
// The optional operand must be "lsl #N" where N is non-negative.
if (!Parser.getTok().is(AsmToken::Identifier) ||
!Parser.getTok().getIdentifier().equals_insensitive("lsl")) {
Error(Parser.getTok().getLoc(), "only 'lsl #+N' valid after immediate");
Error(getLoc(), "only 'lsl #+N' valid after immediate");
return MatchOperand_ParseFail;
}

Expand All @@ -2926,28 +2925,27 @@ AArch64AsmParser::tryParseImmWithOptionalShift(OperandVector &Operands) {
parseOptionalToken(AsmToken::Hash);

if (Parser.getTok().isNot(AsmToken::Integer)) {
Error(Parser.getTok().getLoc(), "only 'lsl #+N' valid after immediate");
Error(getLoc(), "only 'lsl #+N' valid after immediate");
return MatchOperand_ParseFail;
}

int64_t ShiftAmount = Parser.getTok().getIntVal();

if (ShiftAmount < 0) {
Error(Parser.getTok().getLoc(), "positive shift amount required");
Error(getLoc(), "positive shift amount required");
return MatchOperand_ParseFail;
}
Parser.Lex(); // Eat the number

// Just in case the optional lsl #0 is used for immediates other than zero.
if (ShiftAmount == 0 && Imm != nullptr) {
SMLoc E = Parser.getTok().getLoc();
Operands.push_back(AArch64Operand::CreateImm(Imm, S, E, getContext()));
Operands.push_back(
AArch64Operand::CreateImm(Imm, S, getLoc(), getContext()));
return MatchOperand_Success;
}

SMLoc E = Parser.getTok().getLoc();
Operands.push_back(AArch64Operand::CreateShiftedImm(Imm, ShiftAmount,
S, E, getContext()));
Operands.push_back(AArch64Operand::CreateShiftedImm(Imm, ShiftAmount, S,
getLoc(), getContext()));
return MatchOperand_Success;
}

Expand Down Expand Up @@ -3150,7 +3148,7 @@ AArch64AsmParser::tryParseOptionalShiftExtend(OperandVector &Operands) {

// Make sure we do actually have a number, identifier or a parenthesized
// expression.
SMLoc E = Parser.getTok().getLoc();
SMLoc E = getLoc();
if (!Parser.getTok().is(AsmToken::Integer) &&
!Parser.getTok().is(AsmToken::LParen) &&
!Parser.getTok().is(AsmToken::Identifier)) {
Expand Down Expand Up @@ -4058,8 +4056,8 @@ bool AArch64AsmParser::parseOperand(OperandVector &Operands, bool isCondCode,
return false;
}
case AsmToken::LBrac: {
SMLoc Loc = Parser.getTok().getLoc();
Operands.push_back(AArch64Operand::CreateToken("[", Loc, getContext()));
Operands.push_back(
AArch64Operand::CreateToken("[", getLoc(), getContext()));
Parser.Lex(); // Eat '['

// There's no comma after a '[', so we can parse the next operand
Expand All @@ -4070,8 +4068,8 @@ bool AArch64AsmParser::parseOperand(OperandVector &Operands, bool isCondCode,
if (!parseNeonVectorList(Operands))
return false;

SMLoc Loc = Parser.getTok().getLoc();
Operands.push_back(AArch64Operand::CreateToken("{", Loc, getContext()));
Operands.push_back(
AArch64Operand::CreateToken("{", getLoc(), getContext()));
Parser.Lex(); // Eat '{'

// There's no comma after a '{', so we can parse the next operand
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/MC/AArch64/shift_extend_op_w_symbol.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: not llvm-mc -triple aarch64-none-linux-gnu < %s > %t1 2> %t2
// RUN: FileCheck < %t1 %s
// RUN: FileCheck --check-prefix=CHECK-ERROR < %t2 %s
// RUN: FileCheck --match-full-lines --strict-whitespace --check-prefix=CHECK-ERROR < %t2 %s

.globl _func
_func:
Expand Down Expand Up @@ -37,6 +37,6 @@ _func:

add w1, w2, w3, lsl #IMM3

// CHECK-ERROR: error: expected constant '#imm' after shift specifier
// CHECK-ERROR:{{.*}}error: expected constant '#imm' after shift specifier
// CHECK-ERROR: add w1, w2, w3, lsl #IMM3
// CHECK-ERROR: ^

0 comments on commit e6ff917

Please sign in to comment.