Skip to content

Commit 25752a4

Browse files
v01dXYZv01dxyz
andauthored
[X86AsmParser] IntelExpression: End of Statement should check for valid end state (#95677)
The following commit bfb7099 added a special case for End of Statement that doesn't check if the state machine is rightfully in a state where ending is valid. This PR suggest to revert this change to make `EndOfStatement` processed as any other tokens that are not consumable by the state machine. Fixes #94446 --------- Co-authored-by: v01dxyz <v01dxyz@v01d.xyz>
1 parent 9e52a9e commit 25752a4

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,9 @@ class X86AsmParser : public MCTargetAsmParser {
475475
unsigned getLength() const { return CurType.Length; }
476476
int64_t getImm() { return Imm + IC.execute(); }
477477
bool isValidEndState() const {
478-
return State == IES_RBRAC || State == IES_INTEGER;
478+
return State == IES_RBRAC || State == IES_RPAREN ||
479+
State == IES_INTEGER || State == IES_REGISTER ||
480+
State == IES_OFFSET;
479481
}
480482

481483
// Is the intel expression appended after an operand index.
@@ -1898,9 +1900,6 @@ bool X86AsmParser::ParseIntelExpression(IntelExprStateMachine &SM, SMLoc &End) {
18981900
case AsmToken::Error:
18991901
return Error(getLexer().getErrLoc(), getLexer().getErr());
19001902
break;
1901-
case AsmToken::EndOfStatement:
1902-
Done = true;
1903-
break;
19041903
case AsmToken::Real:
19051904
// DotOperator: [ebx].0
19061905
UpdateLocLex = false;

llvm/test/MC/X86/intel-syntax-expr.s

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: not llvm-mc -triple x86_64-unknown-unknown -x86-asm-syntax=intel %s 2>&1 | FileCheck %s
2+
3+
// When the intel syntax is enabled, to parse an operand, X86AsmParser doesn't use the method parseExpression from AsmParser
4+
// but ParseIntelExpr which was not processing well an end of statement.
5+
6+
// CHECK: error: unknown token in expression
7+
test:
8+
i-

0 commit comments

Comments
 (0)