forked from OSchip/llvm-project
Tidy up, fix and simplify a few of the SMLocs. Prior to r179109 the Start SMLoc
wasn't always the start of the operand. If there was a symbol reference, then Start pointed to that token. It's very likely there are other places that need to be updated. llvm-svn: 179210
This commit is contained in:
parent
9dea0955ce
commit
70f47596b7
|
@ -1127,7 +1127,8 @@ X86Operand *X86AsmParser::ParseIntelBracExpression(unsigned SegReg,
|
||||||
|
|
||||||
// Try to handle '[' 'Symbol' ']'
|
// Try to handle '[' 'Symbol' ']'
|
||||||
if (getLexer().is(AsmToken::Identifier)) {
|
if (getLexer().is(AsmToken::Identifier)) {
|
||||||
if (ParseRegister(TmpReg, Start, End)) {
|
SMLoc Loc = Tok.getLoc();
|
||||||
|
if (ParseRegister(TmpReg, Loc, End)) {
|
||||||
const MCExpr *Disp;
|
const MCExpr *Disp;
|
||||||
SMLoc IdentStart = Tok.getLoc();
|
SMLoc IdentStart = Tok.getLoc();
|
||||||
if (getParser().parseExpression(Disp, End))
|
if (getParser().parseExpression(Disp, End))
|
||||||
|
@ -1137,7 +1138,7 @@ X86Operand *X86AsmParser::ParseIntelBracExpression(unsigned SegReg,
|
||||||
return Err;
|
return Err;
|
||||||
|
|
||||||
if (getLexer().isNot(AsmToken::RBrac))
|
if (getLexer().isNot(AsmToken::RBrac))
|
||||||
return ErrorOperand(Parser.getTok().getLoc(), "Expected ']' token!");
|
return ErrorOperand(Tok.getLoc(), "Expected ']' token!");
|
||||||
|
|
||||||
unsigned Len = Tok.getLoc().getPointer() - IdentStart.getPointer();
|
unsigned Len = Tok.getLoc().getPointer() - IdentStart.getPointer();
|
||||||
StringRef SymName(IdentStart.getPointer(), Len);
|
StringRef SymName(IdentStart.getPointer(), Len);
|
||||||
|
@ -1178,7 +1179,8 @@ X86Operand *X86AsmParser::ParseIntelBracExpression(unsigned SegReg,
|
||||||
}
|
}
|
||||||
case AsmToken::Identifier: {
|
case AsmToken::Identifier: {
|
||||||
// This could be a register or a displacement expression.
|
// This could be a register or a displacement expression.
|
||||||
if(!ParseRegister(TmpReg, Start, End)) {
|
SMLoc Loc = Tok.getLoc();
|
||||||
|
if(!ParseRegister(TmpReg, Loc, End)) {
|
||||||
SM.onRegister(TmpReg);
|
SM.onRegister(TmpReg);
|
||||||
UpdateLocLex = false;
|
UpdateLocLex = false;
|
||||||
break;
|
break;
|
||||||
|
@ -1220,7 +1222,7 @@ X86Operand *X86AsmParser::ParseIntelBracExpression(unsigned SegReg,
|
||||||
if (ParseIntelDotOperator(Disp, &NewDisp, Err))
|
if (ParseIntelDotOperator(Disp, &NewDisp, Err))
|
||||||
return ErrorOperand(Tok.getLoc(), Err);
|
return ErrorOperand(Tok.getLoc(), Err);
|
||||||
|
|
||||||
End = Parser.getTok().getEndLoc();
|
End = Tok.getEndLoc();
|
||||||
Parser.Lex(); // Eat the field.
|
Parser.Lex(); // Eat the field.
|
||||||
Disp = NewDisp;
|
Disp = NewDisp;
|
||||||
}
|
}
|
||||||
|
@ -1297,11 +1299,10 @@ X86Operand *X86AsmParser::ParseIntelMemOperand(unsigned SegReg,
|
||||||
|
|
||||||
// Parse ImmDisp [ BaseReg + Scale*IndexReg + Disp ].
|
// Parse ImmDisp [ BaseReg + Scale*IndexReg + Disp ].
|
||||||
if (getLexer().is(AsmToken::Integer)) {
|
if (getLexer().is(AsmToken::Integer)) {
|
||||||
const AsmToken &IntTok = Parser.getTok();
|
|
||||||
if (isParsingInlineAsm())
|
if (isParsingInlineAsm())
|
||||||
InstInfo->AsmRewrites->push_back(AsmRewrite(AOK_ImmPrefix,
|
InstInfo->AsmRewrites->push_back(AsmRewrite(AOK_ImmPrefix,
|
||||||
IntTok.getLoc()));
|
Tok.getLoc()));
|
||||||
uint64_t ImmDisp = IntTok.getIntVal();
|
uint64_t ImmDisp = Tok.getIntVal();
|
||||||
Parser.Lex(); // Eat the integer.
|
Parser.Lex(); // Eat the integer.
|
||||||
if (getLexer().isNot(AsmToken::LBrac))
|
if (getLexer().isNot(AsmToken::LBrac))
|
||||||
return ErrorOperand(Start, "Expected '[' token!");
|
return ErrorOperand(Start, "Expected '[' token!");
|
||||||
|
@ -1341,7 +1342,7 @@ X86Operand *X86AsmParser::ParseIntelMemOperand(unsigned SegReg,
|
||||||
bool X86AsmParser::ParseIntelDotOperator(const MCExpr *Disp,
|
bool X86AsmParser::ParseIntelDotOperator(const MCExpr *Disp,
|
||||||
const MCExpr **NewDisp,
|
const MCExpr **NewDisp,
|
||||||
SmallString<64> &Err) {
|
SmallString<64> &Err) {
|
||||||
AsmToken Tok = *&Parser.getTok();
|
const AsmToken &Tok = Parser.getTok();
|
||||||
uint64_t OrigDispVal, DotDispVal;
|
uint64_t OrigDispVal, DotDispVal;
|
||||||
|
|
||||||
// FIXME: Handle non-constant expressions.
|
// FIXME: Handle non-constant expressions.
|
||||||
|
@ -1468,8 +1469,9 @@ X86Operand *X86AsmParser::ParseIntelOperator(unsigned OpKind) {
|
||||||
}
|
}
|
||||||
|
|
||||||
X86Operand *X86AsmParser::ParseIntelOperand() {
|
X86Operand *X86AsmParser::ParseIntelOperand() {
|
||||||
SMLoc Start = Parser.getTok().getLoc(), End;
|
const AsmToken &Tok = Parser.getTok();
|
||||||
StringRef AsmTokStr = Parser.getTok().getString();
|
SMLoc Start = Tok.getLoc(), End;
|
||||||
|
StringRef AsmTokStr = Tok.getString();
|
||||||
|
|
||||||
// Offset, length, type and size operators.
|
// Offset, length, type and size operators.
|
||||||
if (isParsingInlineAsm()) {
|
if (isParsingInlineAsm()) {
|
||||||
|
@ -1497,7 +1499,7 @@ X86Operand *X86AsmParser::ParseIntelOperand() {
|
||||||
|
|
||||||
// Only positive immediates are valid.
|
// Only positive immediates are valid.
|
||||||
if (!isInteger) {
|
if (!isInteger) {
|
||||||
Error(Parser.getTok().getLoc(), "expected a positive immediate "
|
Error(Tok.getLoc(), "expected a positive immediate "
|
||||||
"displacement before bracketed expr.");
|
"displacement before bracketed expr.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue